<keep_learning>
but getting unbounded module error when evaluating the buffer using C-c C-b.
<keep_learning>
I would like to use Ocaml for development in interactive mode, but most of the time I am stuck with unbounded module. I am wondering if you can suggest me some project manager for running Ocaml projects in interactive mode.
<keep_learning>
I am getting error in Ocaml code Fatal error: exception Match_failure("main.ml", 22, 14)
miggsd has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ryanartecona has joined #ocaml
<dinosaure>
keep_learning: if I look the haskell code, the good translation is "let f = function A -> b1 | B -> b2 | C -> b3 | D -> b4 in f"
moei has joined #ocaml
<dinosaure>
when you write "let f A = b1", you make a function to take an argument and try to destruct this argument in only one case (the A case). It's why OCaml said "the pattern matching is not exhaustive", because you miss B, C, and D.
<dinosaure>
then you remake a __new__ function f (which replaces the old function "let f A = b1") and take an argument and only destruct with the B case
<dinosaure>
and again, ocaml said, the pattern is not exhaustive
<dinosaure>
so, yes, ocaml is not like haskell with a lazy construction ...
<keep_learning>
I am trying to file process_input "example-votes.txt";;
<keep_learning>
and I want to change ["(A,3)"; "(B,1)"; "(C,2)"; "(D,4)"] of type string list to [(A,3);(B,1);(C,2);(D,4)] (cand*int) list
<keep_learning>
Any idea how to to do this ?
MercurialAlchemi has quit [Ping timeout: 240 seconds]
nullcatxxx_ has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
ryanartecona has joined #ocaml
cantstanya has joined #ocaml
MercurialAlchemi has joined #ocaml
xaimus has quit [Remote host closed the connection]
spew has quit [Quit: foobar]
<dinosaure>
keep_learning: you have different ways to "deserialize" your input. You can handle this by the hand (and create your deserialization, Scanf can be a solution) or use a serialization/deserialization library (like sexp or yojson with ppx_deriving). The advantage of the last solution is that the serialization/deserialization is generated automatically (like in haskell when you use 'deriving Show') but the
<dinosaure>
disadvantage is you are contraint to use the 'format" of this library (for sexp, it's s-expression, for yojson, is JSON)
<dinosaure>
the disadvantage of the first solution is when you extand your 'cand' type, you need to modify your deserialization
ryanartecona has quit [Quit: ryanartecona]
<dinosaure>
then, lot of documentation already exists about sexp and ppx_deriving_yojson
<dinosaure>
may be the problem will be the compilation with ppx but it depends of what you use (ocamlbuild, jbuilder, make ...)
<Drup>
(tbf, mlsub is a prototype implementation of state-of-the-art research in type system, so ...)
<mrvn>
just going by the amount of code I'm sure there is something bad in there. No way to not compromise sometimes. :)
<Cheery>
one thing is that I'm not familiar with all the idioms and ideas of ML.
<octachron>
Cheery, I am quite sceptical of language-independent ideas on code beauty
<Cheery>
but I'm familiar with python and have noticed there's quite some things that matter a lot to other's ability to figure out what's going on.
<Cheery>
or to your ability when you've done with it and return back to it after forgotten how it went.
<mrvn>
python is a completly different idea than ml
<Cheery>
one thing is that I pack quite lot into single files these days and order them such that the stuff above uses the stuff below.
<Drup>
Well, you see, I find that particular idiom (present in many languages) absolutely horrible :p
<Cheery>
so you get the top down idea of what's going on as you read from the start
<octachron>
this kind of "langauge-independent" criteria is often abstracted from a specific taxon of programming languages in isolation of all other existing programming languages
<Drup>
So, I'm tempted to say you are just used to the pythonic way, and OCaml code is not like python code
<Cheery>
that could be.. but consider all the options through and you do yourself a favor.
<mrvn>
Cheery: like "a = b if c"? I hate those backward control flows in perl and python.
<Cheery>
mrvn: unfortunately that doesn't exist in python.. I also find the python's x if c else y annoying though.
<Cheery>
but the kind of single line conditional guards such as expr if condition are nice.
<mrvn>
Cheery: what's wrong with "if condition: expr"?
<thizanne>
it's not an expression
spew has joined #ocaml
<Drup>
thizanne: that's a language problem
<mrvn>
right, pythons stupid separation of statement and expression.
<Cheery>
oh it's an expression if you just look at it the right way. But the problem is that it's not linear.
<Cheery>
the simplest program to read and reason abouet is a linear flow that starts and then goes through without loops or anything.
<thizanne>
Drup: but that's « what's wrong » with if condition: expr and prevents you from using this order when you're in python
<Drup>
thizanne: sure, but the question was really "why is "expr if condition" better
<Cheery>
and the way how you've structured the if in that case matters, because it changes the layout of the code.
<Cheery>
if the expr becomes long enough, then the traditional if is better.
<Drup>
Cheery: you would like avionics code
tane has quit [Quit: Leaving]
<Cheery>
one important thing about this is that your ability to handle things depend on what you've learned.
<Drup>
(I feel that you also probably don't consult types when you read the code)
<Drup>
(which is logical, if you have mostly wrote python)
<Drup>
(you can get a quite good approximation of what a function will do just by the type)
<Cheery>
and I do think that things that are unreadable to someone because he doesn't know some concept, should just learn the concepts. It's quite logical thing to do with say.. differential equations and vector arithmetic.
<Cheery>
Drup: actually it's quite weird.
<Cheery>
Drup: types sometimes tell surprising things.
<Cheery>
but yeah. I usually read the code if I need to figure out what it does.
<Cheery>
the problem I've had with trying to understand the mlsub source is that it does lot of jumps from place to another.
<Cheery>
I've not entirely understood which parts are coming from the system and from the language because I'm not familiar with the language.
<Drup>
that's a bit of a general thing with typecheckers
<Drup>
typecheckers are basically a big nest of mutually recursive relations, there is no real way around that
<Cheery>
Then there are places where the important ideas kind of vanish into the description and I got no clear idea of where it goes. Had to run a debugger to figure it out and it's still not clear what the code does.
<Drup>
(additionally, we do like to use abstraction a lot in the OCaml community, so yeah, if you ignore signatures and always follow definitions, you don't get any benefits from carefully packaged modules)
<thizanne>
Cheery: maybe you should just learn the concepts ;)
<Cheery>
thizanne: I've triead to find the manual point where they are described.
<Cheery>
for example that is one hell to figure out what it's doing specifically. I finally figured out that it just throws the state transitions into the another.
<Drup>
that's ... not so complicated
<Drup>
if you know what <- is, of course
<Cheery>
one problem is that I was expecting it to remain as a deterministic finite state machine
<Cheery>
when it at that point turns into nondeterministic because there will be more than one of each edge.
<Cheery>
Drup: but it's still got a surprise in there.
<Cheery>
Drup: ask yourself, why does it take the polarity in?
<Cheery>
it has something in the thesis written about this.
<Cheery>
the type components specifically
sh0t has joined #ocaml
<Cheery>
"We define two operations te and ue on sets of head constructors. Both of
<Cheery>
these are simply set union, with the invariant of at most one record type
<Cheery>
maintained by reducing"
<Cheery>
okay. so the both operations are union
<Cheery>
but they do intersection/union on type heads that are available on both.
<Cheery>
checked the notation. Yeah. when negative, take union. when positive, intersect.
NaCl has joined #ocaml
NaCl has joined #ocaml
NaCl has quit [Changing host]
NaCl has left #ocaml [#ocaml]
<Cheery>
consistent with the polarity of types.
jabesed has quit [Ping timeout: 260 seconds]
<Cheery>
Drup: that work is quite brilliant.
<Cheery>
the transform it makes, makes it easier to understand.
<Cheery>
but you got to convert the types back because they become hard to read in type automaton.
<Cheery>
the work leaves me wondering what the unification algorithm would be in a type automaton.
richi235 has quit [Ping timeout: 252 seconds]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
richi235 has joined #ocaml
<Cheery>
seems cool. I've already written the NFA -> DFA step.
solidsalvia has joined #ocaml
rom1504 has joined #ocaml
ryanartecona has joined #ocaml
<mrvn>
Cheery: I would think that unification would build the intersection of states in the NFA
al-damiri has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
jnavila has joined #ocaml
copy` has joined #ocaml
MercurialAlchemi has joined #ocaml
freechips has joined #ocaml
shinnya has joined #ocaml
spew has quit [Ping timeout: 252 seconds]
richi235 has quit [Ping timeout: 260 seconds]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
ryanartecona has quit [Quit: ryanartecona]
foo30303 has quit [Ping timeout: 258 seconds]
foo30303 has joined #ocaml
foo30303 has quit [Client Quit]
spew has joined #ocaml
srcerer_ has joined #ocaml
<companion_cube>
containers 1.2 on its way!
freechips has quit [Quit: WeeChat 1.7]
mcfiredr1ll has joined #ocaml
gallais_ has joined #ocaml
m4farrel_ has joined #ocaml
k1000_ has joined #ocaml
<reynir>
\o/
jnavila has quit [*.net *.split]
hashpuppy has quit [*.net *.split]
srcerer has quit [*.net *.split]
gallais has quit [*.net *.split]
k1000 has quit [*.net *.split]
igitoor has quit [*.net *.split]
gjaldon__ has quit [*.net *.split]
twold has quit [*.net *.split]
mehdib has quit [*.net *.split]
m4farrel has quit [*.net *.split]
mcfiredrill has quit [*.net *.split]
hashpuppy has joined #ocaml
shinnya has quit [Ping timeout: 240 seconds]
maarhart has joined #ocaml
twold has joined #ocaml
maarhart has quit [Client Quit]
gjaldon__ has joined #ocaml
nullcatxxx_ has joined #ocaml
spew has quit [Ping timeout: 260 seconds]
eh_eff has joined #ocaml
jao has joined #ocaml
MercurialAlchemi has joined #ocaml
spew has joined #ocaml
ryanartecona has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
nullcatxxx_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nullcatxxx_ has joined #ocaml
igitoor has joined #ocaml
mehdib has joined #ocaml
jao has joined #ocaml
igitoor has quit [Changing host]
igitoor has joined #ocaml
AlexDenisov has joined #ocaml
<orbifx[m]>
:) companion_cube
leah2 has quit [Quit: trotz alledem!]
leah2 has joined #ocaml
tobiasBora has quit [Ping timeout: 245 seconds]
Fistine has quit [Ping timeout: 260 seconds]
_y has quit [Ping timeout: 260 seconds]
tobiasBora has joined #ocaml
nomicflux has joined #ocaml
_y has joined #ocaml
Fistine has joined #ocaml
octachron has quit [Quit: Leaving]
nomicflux has quit [Ping timeout: 260 seconds]
madroach has joined #ocaml
nullcatxxx_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
al-damiri has quit [Quit: Connection closed for inactivity]
mengu has joined #ocaml
alphor has quit [Quit: Bye!]
eh_eff has quit [Ping timeout: 260 seconds]
MercurialAlchemi has quit [Ping timeout: 260 seconds]
richi235 has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
madroach has joined #ocaml
richi235 has quit [Ping timeout: 276 seconds]
richi235 has joined #ocaml
larhat has joined #ocaml
kakadu has joined #ocaml
kakadu has quit [Client Quit]
nullcatxxx_ has joined #ocaml
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nullcatxxx_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
larhat has quit [Quit: Leaving.]
|jbrown| has quit [Ping timeout: 240 seconds]
eh_eff has joined #ocaml
richi235 has quit [Ping timeout: 276 seconds]
SpiceGuid has joined #ocaml
SpiceGuid has quit [Client Quit]
nullcatxxx_ has joined #ocaml
|jbrown| has joined #ocaml
richi235 has joined #ocaml
solidsalvia has quit [Ping timeout: 260 seconds]
AlexRussia has joined #ocaml
nullcatxxx_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nullcatxxx_ has joined #ocaml
AlexDenisov has joined #ocaml
miggsd has joined #ocaml
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
larhat has joined #ocaml
al-damiri has joined #ocaml
nullcatxxx_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nullcatxxx_ has joined #ocaml
miggsd has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
larhat has quit [Quit: Leaving.]
mengu has quit [Quit: Leaving...]
Simn has quit [Quit: Leaving]
ryanartecona has quit [Quit: ryanartecona]
<orbifx[m]>
is there a way to put all fields of a record in the scope?
<copy`>
orbifx[m]: I don't you can without opening the module
<orbifx[m]>
how would opening the module help?
<copy`>
Then the record fields are in scope (if the record is defined in the module)
Muzer has quit [Ping timeout: 260 seconds]
<mrvn>
orbifx[m]: record.{ ... }?
<mrvn>
M.( ... ) exists too
<orbifx[m]>
So records behave like modules if used like record.{ .. } ?
<orbifx[m]>
I was aware of the M.( .. ) expression.
AlexDenisov has joined #ocaml
tobiasBora has quit [Ping timeout: 246 seconds]
<madroach>
You can do M.{ }, too. It is usually recommended to put each record type in a separate module.
Fistine has quit [Ping timeout: 276 seconds]
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<orbifx[m]>
Yes, bit would that let me do something like: record.{ print_string name }
tobiasBora has joined #ocaml
<orbifx[m]>
where name is a field of record
mfp has quit [Ping timeout: 268 seconds]
Fistine has joined #ocaml
<orbifx[m]>
that's what I mean by putting the field name in the scope; I wish to eliminate repetition of the using identifiers on a record's value.
<Drup>
orbifx[m]: if I understand what you want, it's just deconstruction: let { foo ; bar } = r in ...
sz0 has joined #ocaml
<orbifx[m]>
ow, cool, yeah that would work Drup
<Drup>
("putting fields in scope" is an extremly misleading way to phrase that)
<orbifx[m]>
All that came to mind.. how would you put it?
<Drup>
well, deconstructing :)
<orbifx[m]>
Also can that deconstruction be partial (only take some of the fields) ?
<Drup>
yes
<Drup>
just omit fields
<orbifx[m]>
never though of it as deconstructing. Takes some time to realise what is special and what isn't ^^
<orbifx[m]>
that helps though, thanks :D
<Drup>
the thing is that "putting fields in scope" usually refer to the fields as function operating on a type, not as the values that are the field of a specific record
<Drup>
(hence all the answers about modules ...)
jmiven has quit [Quit: WeeChat 1.7.1]
jmiven has joined #ocaml
Muzer has joined #ocaml
<orbifx[m]>
"fields as function operating on type" ?
<Drup>
".foo"
sh0t has quit [Remote host closed the connection]
average has quit [Quit: leaving]
<orbifx[m]>
I though identifiers were not functions?
<orbifx[m]>
Which brings to something else I need validation. I've been presuming that record identifiers are lost after compilation, which is why they can't be stored as values. Is that correct?
<Drup>
yes
<orbifx[m]>
Is the ultimate cost of doing `v.foo` the same as `let foo v = v.foo in foo v` ?
<orbifx[m]>
or does one incur a function call, where as the other doesn't?
<Drup>
it's pretty much the same
<copy`>
It does incur a function call, which will likely be inlined
<Drup>
huh, no.
<Drup>
there are no functions
<orbifx[m]>
any final takers? :P
average has joined #ocaml
<orbifx[m]>
Anyway, thanks Drup :)
infinity0_ has joined #ocaml
infinity0_ has quit [Changing host]
infinity0 has joined #ocaml
infinity0 has quit [Killed (hitchcock.freenode.net (Nickname regained by services))]
infinity0 has quit [Remote host closed the connection]