<malc_>
Khady: *** TarVanimelde (~TarVanime@nusnet-228-34.dynip.nus.edu.sg) has joined
<malc_>
<malc_>
channel #ocaml [14:16]
<TarVanimelde>
I only learned OCaml for the compiler design class I'm doing this semester
<Khady>
TarVanimelde: do you have an email of a teacher I could contact?
noddy has joined #ocaml
brunoro_ has joined #ocaml
freusque has joined #ocaml
libertas has quit [Read error: Connection reset by peer]
Algebr` has joined #ocaml
brunoro_ has quit [Ping timeout: 256 seconds]
sepp2k has joined #ocaml
brunoro_ has joined #ocaml
brunoro_ has quit [Ping timeout: 248 seconds]
ryanartecona has joined #ocaml
switchnode has joined #ocaml
cpdean has joined #ocaml
ryanartecona has quit [Ping timeout: 260 seconds]
<switchnode>
Is it possible to 'unwrap' a value nested in an arbitrary number of options into a single option?
<switchnode>
I thought I could do this with a recursive function (http://hastebin.com/apowokilug.ml), but it gives me a syntax error--even if I specify thatthe recursive call is on an option, it's not the _same_ type of option as I started with, so the interpreter balks.
cpdean has quit [Ping timeout: 260 seconds]
<flux>
switchnode, can you express the type you want for the function?
brunoro_ has joined #ocaml
<Algebr`>
switchnode: probably the syntax error is from doing (x)
<flux>
it's not, though, (x) is fine
<Algebr`>
so its a tuple of one element?
<flux>
no, it's just the same as x
<flux>
there is no one-tuple in ocaml
<Algebr`>
oh wow, TIL x is the same as (x)
<Algebr`>
oh wait, I guess that sort of makes sense.
<Enjolras>
flux: i think it is still theorically possible. But not trivial
<switchnode>
flux: uh, hmm. I guess the base case and recursive cases have different typings here.
<flux>
switchnode, I think so too.. but maybe enjolras has an idea :
<flux>
switchnode, in any case, sometimes you need to annotate explicitly polymorphism in recursive functions
<flux>
but I think that doesn't help here
<Enjolras>
A theorical idea. But real code you want to write
brunoro_ has quit [Ping timeout: 248 seconds]
<switchnode>
Enjolras: this isn't real code anyway, so I'm game
<Enjolras>
i *suspect* you can do that with objects
<Enjolras>
lemme think about it a bit more
<flux>
how about with a special option made with gadts?
<flux>
so I think this is the same as the question "how to flatten an arbitrary deep (Some (Some (Some .. (Some x)))) into (Some x) in OCaml"
<switchnode>
Yes
brunoro_ has joined #ocaml
<Algebr`>
does core have like Option.join?
<Drup>
probably, it's a monad
<Drup>
containers doesn't, though.
<Drup>
companion_cube!
<Enjolras>
all i managed to do is to infinite loop
Algebr` has quit [Ping timeout: 260 seconds]
<Drup>
recursive flattening of options (or lists) is not possible in OCaml, except by having an extra GADT argument, and it's not really worth it
orbifx has joined #ocaml
<switchnode>
Drup: how would you build that GADT? this is a toy and won't ever actually be used, so
<Enjolras>
duh. The only thing i managed to write is actually a non terminating fixpoint
<Enjolras>
which actually makes sens :)
<Enjolras>
it unwraps an arbitrary number of options until it loops.
<Enjolras>
class recursive = object (self) method recurse : 'a 'b. ( ( 'a -> 'b )- >( 'a -> 'b ) ) -> ( 'a -> 'b ) = fun fix n -> fix (self#recurse fix) n end let unwrap = function | Some (Some x) -> Some x | Some None -> None | None -> None in let unwrap_rec unwrap = function None -> None | x -> unwrap x let unwrap_fox = (new recursive)#recurse unwrap_rec. There is no way to make this fixpoint terminate i gue
<Enjolras>
ss ?
<Drup>
Enjolras: why would objects help you here ?
<Drup>
in term of type signatures, you can't expression "??? -> 'a option" with ???? being an arbitrary nesting of options. It's just not expressible in OCaml, the fact that you use objects underneath doesn't help.
<Drup>
express*
Algebr` has joined #ocaml
<switchnode>
Drup: that doesn't help you any, though, does it? if you have to supply an additional argument with the same structure, you know the level of nesting and might as well just call get however many times.
<Drup>
switchnode: that was my point, you need an extra argument
<Drup>
you can't do it type safely in any other way
<switchnode>
i see. there's no way to, say, wrap the options themselves in a gadt so that you can return an option of either lower or the same level as your input?
<Drup>
switchnode: you will need to give the structure in the gadt, one way or another
AlexDenisov has joined #ocaml
<switchnode>
OK, thank you.
<Drup>
(note that you can do a type unsafe version, by looking at the memory representaiton, but ...)
jao has joined #ocaml
copy` has joined #ocaml
<companion_cube>
Drup: CCOpt.flat_map
<companion_cube>
(are you kidding, of course I wrote that)
<Drup>
companion_cube: but no join!
<companion_cube>
ah, this
<Drup>
'a 'a t -> 'a t
<companion_cube>
you mena flatten?
<Drup>
hum, no
<companion_cube>
PR/issue welcome
<Drup>
'a t t -> 'a t
<companion_cube>
indeed, I forgot this one
<Drup>
in monad parlance, it's called join
hellofunk has joined #ocaml
<Drup>
you should add a MONAD signature :3
dhil has quit [Ping timeout: 260 seconds]
<Enjolras>
Drup: right. My attempt with fixpoint is obviously broken. It is less general
<switchnode>
Drup: hey, is there a way to construct the unary representation from an int value? the recursion seems obvious enough, but the gadt syntax is somewhat obscure to me
freusque has quit [Ping timeout: 250 seconds]
AlexRussia has joined #ocaml
<Drup>
nope :p
<companion_cube>
Drup: nope
<companion_cube>
(and I don't care for monad parlance, `bind` is too generic a term)
<companion_cube>
(even if I had a MONAD signature, it would probably not include join)
<switchnode>
ah, bother
TarVanimelde has quit [Quit: TarVanimelde]
jwatzman|work has joined #ocaml
aphprentice has quit [Quit: Connection closed for inactivity]
TarVanimelde has joined #ocaml
nomicflux has joined #ocaml
octachron has joined #ocaml
TarVanimelde has quit [Read error: Connection reset by peer]
hellofunk has quit [Remote host closed the connection]
orbifx has joined #ocaml
<orbifx>
kakadu: what's the configure parameters for Lablqt to install it locally?
douglascorrea has joined #ocaml
<Drup>
switchnode: the gadt is not (only) here for the value/recursion, it's here for the typing
<kakadu>
define locally, orbifx
<orbifx>
in my ~/.opam
<orbifx>
I want to run: make install, but it tries to install it in the system
<orbifx>
I remember this is controlled by ./configure
TarVanimelde has joined #ocaml
<kakadu>
see Makefile.install
<octachron>
kakadu, concerning your higher kinded type puzzle of yesterday, I think you are missing some lemma/primitives
d0nn1e has quit [Ping timeout: 260 seconds]
agarwal1975 has quit [Quit: agarwal1975]
d0nn1e has joined #ocaml
<kakadu>
Also I'm missing extra IQ
<kakadu>
Which is embarassing
<kakadu>
Maybe I need some another variation of this stuff
hellofunk has joined #ocaml
<kakadu>
like an ability to write cons: ('a,'b) fancy -> (('a,'c)llist as 'c, (('b,'d)llist as 'd)logic) fancy -> (('a,'c)llist as 'c, (('b,'d)llist as 'd)logic) fancy
xavierm02 has joined #ocaml
freehck has joined #ocaml
xavierm02 has quit [Ping timeout: 260 seconds]
xavierm02 has joined #ocaml
<xavierm02>
Hi. I'm trying to represent functions with GADTs but I can't get things to typecheck. "The type constructor c#29 would escace its scope" http://pastebin.com/H7dQ6zQX
<xavierm02>
I tried to add (type c) as parameter for the function but it didn't help.
<flux>
no problem! whatcha doing with that data structure, btw?
ryanartecona has quit [Ping timeout: 256 seconds]
<freehck>
flux: Why does ocaml even allow to define the new type as "('a, 'b) t" if it uses 'c in one type constructor? I thought it's invalid. What is the use case?
<flux>
hmm, you can just refer to 'c and then it's unified to whatever suitable. naming a type 'c doesn't say it's going to be different from 'a or 'b
cpdean has quit [Ping timeout: 252 seconds]
<kakadu>
Can I define a Fix-like functor to get from types like `'self intalist` the types like `type intlist = intlist intalist` ?
<octachron>
flux: Is 'c not an existential type here?
<flux>
yes, it is. maybe I'm not understanding the question.
freusque has joined #ocaml
<freehck>
flux: I mean why type is "('a, 'b) t"? It seems that it must be "('a, 'b, 'c) t".
<flux>
well it can even be plain t, the ('a, ..) are there just to help you extract type information out of it
<flux>
I suppose in that case it reduces to the same as regular sum types?
dhil has joined #ocaml
<octachron>
freehck: the 'c is an existential type, a simpler example will be " type printable = Printable of 'a * 'a -> unit"
<flux>
actually that must either be a record or a gadt :)
<flux>
so that's an excellent example :)
jlongster has joined #ocaml
<octachron>
here the type 'a that appears in the right hand side of the definition means that for any Printable (x,p), it exists a type 'a such that a:'a, p:'a -> unit
underscore has quit [Ping timeout: 250 seconds]
<octachron>
so you can do "print (Printable (x,f)) = f x"
<xavierm02>
flux: I need to use maps as finite (support) functions. But when composing, (un)currying etc., I don't want to recompute the new map because it's super expensive and most likely just to use it once so I'm trying to define lazy maps.
noddy has quit [Ping timeout: 265 seconds]
agarwal1975 has joined #ocaml
<flux>
octachron, can you think of a sane example where the existential type variable would be exactly once?
<octachron>
flux: it can be useful to suppress a phantom type for instance
<xavierm02>
(I could do that with just normal functions, but I need to keep track of the domain too)
<flux>
octachron, hmm, I don't think it's existential in phantom types?
<flux>
the phantom type is like type 'phantom x = int, but I'm talking about type foo = Foo: 't -> foo
<freehck>
octachron: thx
<octachron>
flux, imagine that I have a "type 'sign int = private int " with 'sign = positive or negative
<octachron>
then I want to have a list of int were I don't care for the sign
tvynr has quit [Ping timeout: 248 seconds]
<octachron>
I can define "type unsign_int = Unsign of 'a int"
<flux>
you can't do write that, though, can you?
<flux>
unbound parameter 'a
<octachron>
flux, sorry "type unsign_int = Unsign: 'a int -> unsign_int"
cnu- has quit [Ping timeout: 258 seconds]
<flux>
octachron, so what can you do with that?
<flux>
the 'a is inside, it's pretty much inaccessible?-o
<octachron>
well, the point is that there are functions that works on (∀a. a int), so there are useful function of unsigned_int
cnu- has joined #ocaml
cnu- has quit [Excess Flood]
cnu- has joined #ocaml
<octachron>
for instance: "let print (n:'a sint) = Printf.printf "%d" (n:_ sint :>int);;" (renaming 'a int to 'a sint here)
<octachron>
then "let print' (Unsigned n) = print n" works
<flux>
but I don't get to make use of the type.. ?
zpe has quit [Remote host closed the connection]
douglascorrea has quit [Remote host closed the connection]
douglascorrea has joined #ocaml
noddy has joined #ocaml
<octachron>
flux, well once the type is hidden in the existential, you cannot use it without extra information. And if it appears only once, there is no way to obtain extra information
cext has quit [Quit: Page closed]
douglascorrea has quit [Ping timeout: 240 seconds]
yomimono has joined #ocaml
minn has quit [Ping timeout: 265 seconds]
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
AlexDenisov has joined #ocaml
sepp2k has quit [Ping timeout: 245 seconds]
xavierm02 has quit [Quit: Page closed]
hellofunk has quit [Remote host closed the connection]
hellofunk has joined #ocaml
cpdean has joined #ocaml
tvynr has joined #ocaml
gjaldon has joined #ocaml
underscore has joined #ocaml
marsam has joined #ocaml
sepp2k has joined #ocaml
al-damiri has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 250 seconds]
rgrinberg has quit [Remote host closed the connection]
orbifx has joined #ocaml
noddy has quit [Ping timeout: 265 seconds]
gjaldon has quit []
<orbifx>
kakadu: what's the threading model for lablqt?
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sh0t has joined #ocaml
<kakadu>
em?
AlexDenisov has joined #ocaml
okuu has quit [Quit: Unyu~? brb]
shinnya has joined #ocaml
freehck has quit [Remote host closed the connection]
okuu has joined #ocaml
douglascorrea has joined #ocaml
minn has joined #ocaml
<orbifx>
If there are more than one callbacks, potentially simultaneous from the C++ runtime, how does the OCaml runtime receive them?
switchnode has left #ocaml [#ocaml]
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<kakadu>
sequentially
ryanartecona has joined #ocaml
<kakadu>
I think
<kakadu>
I have only many ocaml threads that call C++ in demos list
<orbifx>
I'm wondering how to have multiple callbacks from QML to OCaml.
<orbifx>
Also I have an idea which allows the use of QtObjects directly without the use explicit intermediary PropertyMaps
AlexDenisov has joined #ocaml
tvynr has quit [Ping timeout: 244 seconds]
<kakadu>
orbifx: I'm not sure why multiple callbacks should not work as is
<orbifx>
Didn't say they wouldn't work, they seem to work fine; I'm just asking what the current concurrency approach is
rgrinberg has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
veggie_ has joined #ocaml
shinnya has quit [Ping timeout: 258 seconds]
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Algebr` has quit [Ping timeout: 245 seconds]
minn has joined #ocaml
jnavila has quit [Quit: It was time]
dave_tucker has joined #ocaml
alienbot has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
alienbot has quit [Remote host closed the connection]
alienbot has joined #ocaml
alienbot has quit [Read error: Connection reset by peer]
<Bluddy[m]>
orbifx: does the OCaml runtime take a real mutex? I can't find any, which means that if you call it from multiple threads, you'll have bad things happen
<orbifx>
Bluddy[m]: I think there is an external mutex. I haven't written that bit. Kakadu might have a clear idea over it
NingaLeaf has joined #ocaml
kakadu has joined #ocaml
<Bluddy[m]>
if there's no mutex, you could easily create one before calling the OCaml code
<Bluddy[m]>
i mean create one and then take it before running OCaml code
octachron has quit [Quit: Page closed]
dhil has quit [Ping timeout: 260 seconds]
Algebr` has joined #ocaml
tane has joined #ocaml
frefity has quit [Ping timeout: 248 seconds]
orbifx1 has joined #ocaml
orbifx1 has quit [Client Quit]
<orbifx>
Bluddy[m]: I know what you mean and I think it's being done already
seangrove has quit [Remote host closed the connection]
seangrove has joined #ocaml
noddy has quit [Ping timeout: 260 seconds]
okuu has quit [Ping timeout: 256 seconds]
marsam has quit [Ping timeout: 250 seconds]
TarVanimelde has quit [Quit: TarVanimelde]
frefity has joined #ocaml
noddy has joined #ocaml
brunoro_ has quit [Ping timeout: 258 seconds]
ryanartecona has quit [Quit: ryanartecona]
jcelerier has quit [Quit: WeeChat 1.6]
dhil has joined #ocaml
jao has quit [Ping timeout: 256 seconds]
jnavila has joined #ocaml
ryanartecona has joined #ocaml
jao has joined #ocaml
zpe has joined #ocaml
tane has quit [Quit: Leaving]
zpe has quit [Remote host closed the connection]
brunoro_ has joined #ocaml
seangrove has quit [Ping timeout: 258 seconds]
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
Piczel has joined #ocaml
<Piczel>
hi guys, which book do u recommend for learning 'from scratch' ?
jsgrant has joined #ocaml
brunoro_ has quit [Ping timeout: 246 seconds]
<Drup>
Piczel: do you have programming experience ?
AltGr has left #ocaml [#ocaml]
<Piczel>
a little with java and c
<Drup>
http://ocaml.org/learn/books.html here are a list of ocaml books. "OCaml from the very beginning" is good if you have not previous experience at all
brunoro_ has joined #ocaml
<Drup>
no*
<Piczel>
ok, i'll give it a try ! thx
orbifx has quit [Ping timeout: 244 seconds]
brunoro_ has quit [Ping timeout: 260 seconds]
brunoro_ has joined #ocaml
brunoro_ has quit [Ping timeout: 250 seconds]
brunoro_ has joined #ocaml
jao has quit [Ping timeout: 256 seconds]
noddy has quit [Ping timeout: 250 seconds]
zpe has joined #ocaml
jsgrant has quit [Quit: Konversation terminated!]
brunoro_ has quit [Ping timeout: 250 seconds]
jsgrant has joined #ocaml
jnavila has quit [Ping timeout: 256 seconds]
dhil has quit [Ping timeout: 268 seconds]
underscore has joined #ocaml
ontologiae has quit [Ping timeout: 256 seconds]
agarwal1975 has quit [Quit: agarwal1975]
_andre has quit [Quit: leaving]
orbifx has joined #ocaml
brunoro_ has joined #ocaml
AlexDenisov has joined #ocaml
zpe has quit [Remote host closed the connection]
jnavila has joined #ocaml
malc_ has quit [Remote host closed the connection]
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 248 seconds]
veggie_ has quit [Ping timeout: 260 seconds]
zaquest has quit [Quit: Leaving]
demonimin has quit [Remote host closed the connection]
brunoro_ has quit [Ping timeout: 258 seconds]
demonimin has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
jsgrant has quit [Quit: Konversation terminated!]
veggie_ has joined #ocaml
jsgrant has joined #ocaml
jnavila has quit [Ping timeout: 256 seconds]
octachron has joined #ocaml
okuu has joined #ocaml
noddy has joined #ocaml
larhat has joined #ocaml
douglascorrea has quit [Remote host closed the connection]
douglascorrea has joined #ocaml
douglascorrea has quit [Ping timeout: 256 seconds]
brunoro_ has joined #ocaml
brunoro_ has quit [Ping timeout: 245 seconds]
brunoro_ has joined #ocaml
ontologiae has joined #ocaml
ryanartecona has joined #ocaml
Algebr` has quit [Ping timeout: 260 seconds]
cpdean_ has joined #ocaml
brunoro_ has quit [Ping timeout: 268 seconds]
cpdean has quit [Ping timeout: 260 seconds]
underscore has quit [Ping timeout: 250 seconds]
sepp2k has quit [Quit: Leaving.]
MercurialAlchemi has quit [Ping timeout: 258 seconds]
veggie_ has quit [Ping timeout: 250 seconds]
underscore has joined #ocaml
veggie_ has joined #ocaml
noddy has quit [Ping timeout: 268 seconds]
alexelcu has joined #ocaml
alexelcu has quit [Client Quit]
brunoro_ has joined #ocaml
chindy has joined #ocaml
pierpa has quit [Ping timeout: 256 seconds]
brunoro_ has quit [Ping timeout: 240 seconds]
octachron has quit [Quit: Leaving]
underscore has quit [Ping timeout: 240 seconds]
noddy has joined #ocaml
clockish has quit [Quit: bye]
clockish has joined #ocaml
rgrinberg has quit [Remote host closed the connection]
brunoro_ has joined #ocaml
brunoro_ has quit [Ping timeout: 245 seconds]
brunoro_ has joined #ocaml
brunoro_ has quit [Ping timeout: 260 seconds]
minn has quit [Quit: Leaving]
brunoro_ has joined #ocaml
brunoro_ has quit [Ping timeout: 248 seconds]
FreeBirdLjj has joined #ocaml
veggie_ has quit [Quit: WeeChat 1.5]
brunoro_ has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
brunoro_ has quit [Ping timeout: 260 seconds]
Simn has quit [Read error: Connection reset by peer]
jao has joined #ocaml
brunoro_ has joined #ocaml
kakadu has quit [Remote host closed the connection]
brunoro_ has quit [Ping timeout: 248 seconds]
bbc has quit [Read error: Connection reset by peer]
bbc_ has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
douglascorrea has joined #ocaml
chindy has quit [Remote host closed the connection]