<ollehar>
then include the A object file when compiling B
<ggole>
The expansion of the .mly might not make those identifiers available
tmtwd has quit [Remote host closed the connection]
<ollehar>
right, symbol_table should be in a separate module, maybe
<gpietro>
mmm
<ggole>
I seem to recall somebody else having this problem, and the solution was to use a third module
<gpietro>
ok i'll try to put symbol table in another module
<gpietro>
and then include it
<gpietro>
where i need it
<gpietro>
let's see
<ggole>
OK, I tried it: an .mli is produced with only the rules (and data type) being exported
<gpietro>
so I created a file env.ml with theonly line: let symbol_table = Hashtbl.create 16
<ggole>
That's why the identifier is unbound.
<gpietro>
and ii included it wherever i need it but now i get:
<gpietro>
Error: The type of this expression, ('_a, '_b) Hashtbl.t,
<gpietro>
contains type variables that cannot be generalized
<ggole>
Give it a type
<ggole>
let symbol_table : (foo, bar) Hashtbl.t = Hashtbl.create 16
<gpietro>
oh
QuanticPotato has quit [Ping timeout: 264 seconds]
<ggole>
(That is a really bad error message.)
<gpietro>
bad in which sense?
<ggole>
It's not really helpful to people seeing it for the first time.
<gpietro>
well I am very new of ocaml and i think the error messages are one of the things i like less in it. I find em pretty obscure most of the times.
ollehar has quit [Ping timeout: 244 seconds]
<ggole>
Yep, pretty much
<gpietro>
thanks ggole now it worsa
<gpietro>
*works
<ggole>
Great.
<ggole>
By the way, this type variable problem shows up when you have weak type variables (the ones that are printed like _'a) that would be visible outside a module
<flux>
if you're not planning to export anything at all, you can create an empty .mli file
<flux>
this way it doesn't matter if you have weak type variables or not
<ggole>
Yeah, but in this case the .ml exists exactly to make this table visible.
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
l1x has joined #ocaml
strmpnk has joined #ocaml
<gpietro>
mmm
<gpietro>
i see
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
IbnFirnas has joined #ocaml
mcorbin has joined #ocaml
AltGr has left #ocaml [#ocaml]
<vbmithr>
hi
<vbmithr>
anybody using Async_ssl ?
mankyKitty has joined #ocaml
sspi has joined #ocaml
QuanticPotato has joined #ocaml
ggherdov has joined #ocaml
mankyKitty has quit [Ping timeout: 252 seconds]
l1x has quit [Ping timeout: 246 seconds]
IbnFirnas has quit [Ping timeout: 244 seconds]
strmpnk has quit [Ping timeout: 244 seconds]
sspi has quit [Ping timeout: 246 seconds]
ggherdov has quit [Ping timeout: 250 seconds]
QuanticPotato has quit [Quit: Leaving]
mcorbin has quit [Ping timeout: 244 seconds]
ely-se has joined #ocaml
k1000 has quit [Ping timeout: 250 seconds]
k1000 has joined #ocaml
jeffmo has joined #ocaml
grouzen has quit [Ping timeout: 252 seconds]
tmtwd has joined #ocaml
igoroliveira has joined #ocaml
darkf has quit [Quit: Leaving]
darkf has joined #ocaml
l1x has joined #ocaml
strmpnk has joined #ocaml
ivali has quit []
ely-se has quit [Quit: leaving]
IbnFirnas has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nullcatxxx_ has joined #ocaml
tane has joined #ocaml
nullcatxxx_ has quit [Client Quit]
nullcatxxx_ has joined #ocaml
kushal has joined #ocaml
mankyKitty has joined #ocaml
sspi has joined #ocaml
ggherdov has joined #ocaml
BhavyaM has quit [Quit: Quit the channel]
govg has joined #ocaml
strmpnk has quit [Ping timeout: 245 seconds]
strmpnk has joined #ocaml
samrat has joined #ocaml
govg has quit [Quit: leaving]
sepp2k has joined #ocaml
Tom___ has joined #ocaml
jeffmo has quit [Quit: jeffmo]
<Tom___>
I have a line of code: let _ = Sys.command script.sh in ...
<Tom___>
I want to get sure that scripts terminates before I move to the next line
<Tom___>
is that possible?
tmtwd has quit [Ping timeout: 246 seconds]
<ggole>
You want to exit? Sys.exit
<ggole>
Er, just exit
<dsheets>
Tom___, Sys.command returns the exit code of the command
<ggole>
Oh never mind, I misunderstood
<dsheets>
so at least the parent process you start will have exited by the time the function returns
<Tom___>
that means it already does what I am looking for, am I right?
<Tom___>
it is like: let _ = Sys.command script.sh in Lwt.return ()
<dsheets>
Tom___, I would not recommend using normal blocking calls in conjunction with lwt
<dsheets>
Tom___, use something like Lwt_unix.system if you are using lwt
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Algebr has quit [Remote host closed the connection]
Algebr has joined #ocaml
<gpietro>
hey guys can you do overloading of constructors in ocaml_
<gpietro>
?
<Tom___>
great, so what be the equivalent for Sys.command?
<gpietro>
like...type A= Constructor of float | COnstructor of in
<gpietro>
t
<def`>
gpietro: no
<gpietro>
i see
ollehar has joined #ocaml
<gpietro>
thanks def`
<dsheets>
Tom___, Lwt_unix.system
<Tom___>
awesome! :)
<Tom___>
Thanks
<def`>
no overloading in ocaml, the closest thing would be disambiguation, that's recent and not very in the ML spirit
tnguyen1 has joined #ocaml
<gpietro>
def`, because i have this problem I am trying to write an interpreter for a simple language which has both float and int (and other types). So in defining the arithmetic expression in ast.ml i found myself obliged in definitng two constructors (for both int and flaot) for everyoperator like: <=, +, -...and so on
<gpietro>
two constructos with different names...
tmtwd has joined #ocaml
<ggole>
Have +=, < etc take an argument indicating which type they are
jeffmo has joined #ocaml
<gpietro>
mmm ggole i don't think i understand
<gpietro>
like i have something like: type int_exp= Plus of int_exp * int_exp | ....etc...
<gpietro>
and i also need to have type float_exp = Plus of float_exp * float_exp
<gpietro>
and so on...
<gpietro>
i am sure this is a very common """problem"""
<ggole>
type binop = Add | Sub | ... type ty = TyInt | TyFloat type expr = Int of int | Float of float | BinOp of binop * ty * expr * expr
<ggole>
Oh, you want to segregate expressions by type
noplamodo_ has joined #ocaml
<ggole>
Consider not doing that?
tmtwd has quit [Ping timeout: 244 seconds]
grouzen has joined #ocaml
<gpietro>
ggole, what do you mean by segreagting expression by type...i would be happy to have only "one" kind of expression
<gpietro>
i am trying to understand what u did there
tnguyen has quit [*.net *.split]
haesbaert has quit [*.net *.split]
martintrojer has quit [*.net *.split]
noplamodo has quit [*.net *.split]
nicoo has quit [*.net *.split]
jerith has quit [*.net *.split]
gustav_ has quit [*.net *.split]
martintrojer has joined #ocaml
<gpietro>
i see that but then you can fill BinOp with TyInt and giving it a float
<ggole>
You have to not do that :)
<gpietro>
i see
<ggole>
That's the downside of untyped ASTs like this
<ggole>
The design is simple but the types let you do things that don't make sense
<gpietro>
and what if i did something like
<dsheets>
gpietro, type _ ty = TyInt : int ty | TyFloat : float ty type op = BinOp of 'a ty * 'a exp * 'a exp?
<gpietro>
mm dsheets this is getting a bit too much for me let me try to decode it
<dsheets>
err with an op constr too
ollehar has quit [Ping timeout: 265 seconds]
<ggole>
Well, GADTs were exactly what I didn't want to suggest
<dsheets>
yes, but they address exactly this problem... gpietro can stay untyped and simple but error-prone or learn about gadts
<gpietro>
i think i'll go for gadts...after all i am doing this to learn ocaml
<gpietro>
:)
<gpietro>
thanks guys
<dsheets>
(and quantification, and type equality, and explicit polymorphism)
<gpietro>
just one thing
haesbaert has joined #ocaml
<gpietro>
are gadts the standard way
<gpietro>
to solve my issue?
<gpietro>
if there is a standard way
<gpietro>
...
<ggole>
There's no standard way, designs differ widely
<ggole>
What are you going to be using the AST for?
<gpietro>
mm i guess traversing it
<gpietro>
for interpretaion
<gpietro>
?
<gpietro>
i mean without the '?'
<gpietro>
i am trying to implement an intepreter for a simple language (not that simple actually)
<gpietro>
.
<ggole>
GADTs aren't bad for that
<gpietro>
ok!
<ggole>
It's when you start wanting type indexed maps (eg, for optimisations like value numbering) that things start getting hairy
slicefd_ has joined #ocaml
mcorbin has joined #ocaml
ollehar has joined #ocaml
<gpietro>
i don't think i'll need that ggole
jerith has joined #ocaml
gustav_ has joined #ocaml
slicefd has quit [Ping timeout: 260 seconds]
<gpietro>
dsheets, can you please explain that line you wrote there?
<dsheets>
gpietro, which? the types? type _ ty = TyInt : int ty | TyFloat : float ty makes a parameterized type with two 0-ary constructors which 'carry' or represent the ocaml int and float types
<gpietro>
ok i don't get the '_' there
<gpietro>
(sorry for the very basic questions)
<dsheets>
_ could be 'a but it just means a type parameter that i decline to name
nicoo has joined #ocaml
<gpietro>
ok
<dsheets>
(and it's valid syntax)
slash^ has joined #ocaml
<gpietro>
dsheets, i am trying those lines on the environment
<gpietro>
but i get error like:
<gpietro>
# type op = BinOp of 'a ty * 'a exp * 'a exp;;
<gpietro>
Error: Unbound type parameter 'a
darkf has quit [Quit: Leaving]
<ggole>
You'll need to GADTify that type too
<dsheets>
gpietro, oops, you're right, sorry, you can do type op = BinOp : 'a ty * oper * 'a exp * 'a exp -> op
<ggole>
type _ op = BinOp : 'a ty * 'a exp * 'a exp -> 'a op
<dsheets>
oh, indeed, you shouldn't existentialize
<dsheets>
ggole has it right
<ggole>
(Plus the operation argument, which I forgot.)
<ggole>
And the disease spreads >:)
<dsheets>
eh, you can wrap it up with an existential at the top :-p
<rks`>
what's the point of the 'a ty ?
<gpietro>
haha ok i need to learn more theory here...
mcorbin has quit [Remote host closed the connection]
<ggole>
Means you can tell the type of the operation without traversing arbitrary amounts of AST to find it
<dsheets>
rks`, not strictly necessary but in this case introduces a type equality when matching the BinOp so you have restricted the lhs and rhs
<ggole>
If you were willing to do that, and all operations gave a concrete type (which they may not), I guess you could dispense with it.
<dsheets>
the oper could also be parameterized with type (say division is only valid on floats)
<ggole>
Yeah, that could work
tmtwd has joined #ocaml
Simn has quit [Quit: Leaving]
slicefd_ has quit [Quit: Leaving]
sspi has quit [Remote host closed the connection]
mankyKitty has quit [Remote host closed the connection]
IbnFirnas has quit [Remote host closed the connection]
l1x has quit [Remote host closed the connection]
strmpnk has quit [Remote host closed the connection]
ggherdov has quit [Remote host closed the connection]
<gpietro>
and then what about 'a exp? I should also have type 'a exp= 'a | Plus of 'a exp * 'a exp...and so on?
<gpietro>
or am I confusing everything?
l1x has joined #ocaml
<ggole>
I would put binop under exp
strmpnk has joined #ocaml
<gpietro>
type 'a exp = Val of 'a | Plus of 'a exp * 'a exp;;
<gpietro>
something like that
zpe has quit [Remote host closed the connection]
<ggole>
Yeah
<ggole>
Variables are a bit tricky though
<gpietro>
were i able to do what i want i'd save so many lines :)
<ggole>
Which is what?
<gpietro>
mmm i am just trying to create the the type for ast (for expressions) which can handle at the same time int and floats
<gpietro>
without doing like i was doing before, namely...
<gpietro>
for every operators which int and float share...define a constructor for both the types. For instance: type f_expression= FPLus... f_expression * f_expression
<gpietro>
type i_expression= IPlus i_expression*i_expression
<ggole>
You can cheat like that if you like
<ggole>
type 'a term = Val : 'a -> 'a term | BinOp : ('a -> 'a -> 'a) * 'a term * 'a term -> 'a term
<gpietro>
is it cheating?
<ggole>
And then you just use the OCaml (+), (-) etc for the function argument
IbnFirnas has joined #ocaml
<gpietro>
oh
<dsheets>
(+) and (-) aren't polymorphic...
<ggole>
And thenlet rec eval : type a . a term -> a = function | Val x -> x | BinOp (f, a, b) -> f (eval a) (eval b)
<ggole>
No, you'd use them like BinOp ((+.), Val 1.0, Val 2.0)
<ggole>
Or BinOp ((^), "like", "this")
<dsheets>
ah, sure, but then you can't do much analysis, eh?
<ggole>
Like I said, cheating :)
<ggole>
Indeed
<flux>
== :-)
<flux>
cool would be to have the constructor for binary op there, and then another function to just perform (return) the function to do it?
<ggole>
Hmm, that would make printing the ast etc possible
MercurialAlchemi has joined #ocaml
<gpietro>
I don't understand this BinOp thing...
ollehar has quit [Quit: ollehar]
ollehar has joined #ocaml
<gpietro>
i have the operator as a constructor...of an expression
<gpietro>
does it make sense?
<ggole>
BinOp is short for binary operator: you'd use it for +, -, *, etc
<ggole>
(I might have gone a bit overboard with the typeclass-like arguments)
ygrek has joined #ocaml
<gpietro>
mmm i'' study that..can I ask you to read what I wrote and tell me what you think thw flaws are...because I kindof can do what I want to and i cannot do what I don't want to do it seems like Plus(Val(4), Val(5.7))
<ggole>
That won't type check with a GADT
<ggole>
Val 4 is int expr, Val 5.7 is float expr, and they have to be the same (since they are given the same variable in the GADT)
<gpietro>
yes
<gpietro>
that's good right!
<gpietro>
i'll handle subtyping (or how it's called) later maybe
<gpietro>
but for now int/float are separeted
ollehar has quit [Remote host closed the connection]
creichert has joined #ocaml
<ggole>
Subtyping in what sense?
tmtwd has quit [Ping timeout: 245 seconds]
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
zpe has joined #ocaml
<gpietro>
mmm sorry i think i am using the wrong name maybe i meant casting or something like a value of one type to behave well with another type. For instance you would like 4 + 5.7 to be 9.7. But for now I just want 4 + 5.7 to not typecheck...where that + is my Plus constructor.
<gpietro>
ggole,
nullcatxxx_ has joined #ocaml
<ggole>
Hmm
<ggole>
You could add an explicit conversion
nullcatxxx_ has quit [Client Quit]
<gpietro>
like?
<ggole>
Just like ocaml's float_of_int, int_of_float
<ggole>
| FofI : int expr -> float expr
nullcatxxx_ has joined #ocaml
ollehar has joined #ocaml
tmtwd has joined #ocaml
nullcatxxx_ has quit [Client Quit]
jao has joined #ocaml
tmtwd has quit [Ping timeout: 260 seconds]
paradoja has quit [Ping timeout: 260 seconds]
samrat has quit [Ping timeout: 272 seconds]
tmtwd has joined #ocaml
Haudegen has quit [Ping timeout: 255 seconds]
<gpietro>
ah ok
<gpietro>
sure that makes sense..
tmtwd has quit [Ping timeout: 245 seconds]
Haudegen has joined #ocaml
samrat has joined #ocaml
jwatzman|work has joined #ocaml
ygrek has quit [Ping timeout: 255 seconds]
grouzen has quit [Ping timeout: 252 seconds]
kushal has quit [Quit: Leaving]
dsheets has quit [Ping timeout: 240 seconds]
nullcatxxx_ has joined #ocaml
<MercurialAlchemi>
how can we have "State of the OCaml ecosystem" without a "Standard libraries" section?
<MercurialAlchemi>
OCaml is all about creating standard libraries, the rest is incidental
psy_ has quit [Ping timeout: 264 seconds]
MrScout has joined #ocaml
ygrek has joined #ocaml
dsheets has joined #ocaml
yomimono has quit [Ping timeout: 244 seconds]
psy_ has joined #ocaml
ggole has quit []
Guest38 has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
tmtwd has joined #ocaml
ivali218 has joined #ocaml
kakadu has quit [Quit: Page closed]
tmtwd has quit [Ping timeout: 240 seconds]
BitPuffin has quit [Ping timeout: 264 seconds]
ivali218 has quit [Ping timeout: 256 seconds]
AlexRussia_ has quit [Ping timeout: 244 seconds]
ivali218 has joined #ocaml
tmtwd has joined #ocaml
ollehar has quit [Ping timeout: 260 seconds]
tmtwd has quit [Ping timeout: 245 seconds]
Anarchos has joined #ocaml
ygrek has quit [Remote host closed the connection]
ollehar has joined #ocaml
ygrek has joined #ocaml
tmtwd has joined #ocaml
kakadu has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
tmtwd has quit [Ping timeout: 246 seconds]
izaak has joined #ocaml
izaak has quit [Client Quit]
nullcatx_ has joined #ocaml
nullcatxxx_ has quit [Ping timeout: 255 seconds]
ivali218 has quit [Ping timeout: 265 seconds]
tmtwd has joined #ocaml
tane has quit [Quit: Verlassend]
samrat has quit [Ping timeout: 252 seconds]
<S11001001>
MercurialAlchemi: needs a subdivision "latest standard libraries" "standard standard libraries"
ollehar has quit [Ping timeout: 240 seconds]
<Algebr>
There's only 2, maybe 3, of consequence.
<Drup>
4
<Drup>
core, batteries, containers, extlib
tmtwd has quit [Ping timeout: 245 seconds]
zpe has quit [Remote host closed the connection]
sh0t has joined #ocaml
nullcatxxx_ has joined #ocaml
nullcatx_ has quit [Ping timeout: 250 seconds]
jbrown has quit [Ping timeout: 250 seconds]
jbrown has joined #ocaml
The_Mad_Pirate has joined #ocaml
BitPuffin has joined #ocaml
tmtwd has joined #ocaml
The_Mad_Pirate has quit [Quit: Konversation terminated!]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
izaak has joined #ocaml
_andre has quit [Quit: leaving]
mcorbin has joined #ocaml
The_Mad_Pirate has joined #ocaml
izaak has quit [Quit: izaak]
MercurialAlchemi has quit [Ping timeout: 250 seconds]
profan has quit [Ping timeout: 244 seconds]
ivali218 has joined #ocaml
sh0t has quit [Ping timeout: 272 seconds]
profan has joined #ocaml
ivali218 has quit [Ping timeout: 260 seconds]
claudiuc has joined #ocaml
claudiuc has quit [Remote host closed the connection]
claudiuc has joined #ocaml
mcorbin has quit [Remote host closed the connection]
claudiuc has quit [Ping timeout: 246 seconds]
profan has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
profan has joined #ocaml
BitPuffin|osx has joined #ocaml
shinnya has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nullcatxxx_ has joined #ocaml
nullcatxxx_ has quit [Client Quit]
ivali218 has joined #ocaml
ivali218 has quit [Ping timeout: 240 seconds]
ollehar has quit [Quit: ollehar]
tmtwd has quit [Ping timeout: 245 seconds]
claudiuc has joined #ocaml
xificurC has quit [Ping timeout: 244 seconds]
ygrek has quit [Ping timeout: 244 seconds]
sepp2k has quit [Quit: Leaving.]
malc_ has joined #ocaml
systmkor has quit [Ping timeout: 272 seconds]
tristero has quit [Quit: tristero]
ygrek has joined #ocaml
systmkor has joined #ocaml
tmtwd has joined #ocaml
grouzen has joined #ocaml
kakadu has quit [Remote host closed the connection]
tmtwd has quit [Remote host closed the connection]
tmtwd has joined #ocaml
tmtwd has quit [Remote host closed the connection]
malc_ has quit [Ping timeout: 264 seconds]
malc_ has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
<Algebr>
has anything from the stdlib ever been successfully deprecated