adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml MOOC http://1149.fr/ocaml-mooc | OCaml 4.02.3 announced http://ocaml.org/releases/4.02.html | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
damason has joined #ocaml
grai has quit [Ping timeout: 255 seconds]
badon has quit [Quit: Leaving]
grai has joined #ocaml
lobo has quit [Quit: leaving]
madroach has quit [Ping timeout: 246 seconds]
madroach has joined #ocaml
jackweirdy has joined #ocaml
badon has joined #ocaml
mcint has quit [Quit: hibernating...]
teknozulu has quit [Ping timeout: 260 seconds]
jackweirdy has quit [Quit: Textual IRC Client: www.textualapp.com]
Guest23894 has joined #ocaml
teratorn has joined #ocaml
teratorn has quit [Ping timeout: 272 seconds]
nullcatxxx_ has joined #ocaml
teratorn has joined #ocaml
mcint has joined #ocaml
mcmillhj has quit [Quit: Lost terminal]
ril has joined #ocaml
ril is now known as ril[away]
ril[away] has quit [Client Quit]
ril has joined #ocaml
ncthom91 has joined #ocaml
groovy2shoes has joined #ocaml
Guest23894 is now known as Algebr
Algebr is now known as Guest24313
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
FreeBirdLjj has joined #ocaml
ncthom91 has joined #ocaml
mcint has quit [Quit: hibernating...]
mcint has joined #ocaml
ncthom91 has quit [Quit: Textual IRC Client: www.textualapp.com]
cody` has joined #ocaml
struk|desk|away is now known as struk|desk
<Guest24313> When I create a thread with Lwt.wait, I get a thread of 'a Lwt.t. which say is named sleeper. Now in the function that I created this, say I Want to give back a hashtbl.t lwt.t, how can I give back that hashtbl and the sleeper? I want to give back sleeper since I created this for a Lwt_timeout
Guest92020 has quit [Ping timeout: 256 seconds]
<Guest24313> the type definitions seems odd because the Lwt.wakeup take a Lwt.u and a 'a which I then can pick whatever, so I guess I also want to know how I can set the 'a of the corresponding Lwt.t created by Lwt.wait
damason has quit [Remote host closed the connection]
damason has joined #ocaml
johnelse has joined #ocaml
johnelse is now known as Guest78389
Sorella has quit [Quit: Connection closed for inactivity]
Bahman has joined #ocaml
<struk|desk> Guest24313: still there? what do you mean by set the 'a? You can pass any type as a second argument, when that happens, 'a is then fixed to that type, but not before then
<Guest24313> if you do let (sleeper, wakeup) = Lwt.wait (), then you can do Lwt.wakeup wakeup (), and () becomes the 'a for the wakeup in the initial pair. I'm asking how I can set the 'a of the sleeper thread.
<struk|desk> Guest24313: you set the alpha when it wakes up. that is the semantic. Do "Lwt.wakeup wakeup my_hashtbl" Then "Lwt.state sleeper" will contain it
<struk|desk> having said that, I don't use lwt extensively
<Guest24313> I see, so to set the 'a of sleeper I have to go through the wakeup
<Guest24313> yep, clear now, thanks
<struk|desk> Guest24313: awesome, glad to help, Mr 24313, or should I call you Guest?
<Guest24313> ah, you can call be Algebr. erc is messing up and I'm being lazy
pierpa has quit [Ping timeout: 260 seconds]
<struk|desk> Guest24313: ah I remember you. hi again
Ravana has joined #ocaml
teknozulu has joined #ocaml
<Guest24313> I'm trying to find the best way to say that want a thread to only run for x period of time and playing with Lwt_unix.with_timeout and Lwt_timeout.*
ril has quit [Ping timeout: 264 seconds]
MercurialAlchemi has joined #ocaml
darkf has joined #ocaml
struk|desk is now known as struk|desk|away
pyon has quit [Quit: WeeChat 1.3]
ril has joined #ocaml
ril has quit [Ping timeout: 250 seconds]
struktured has joined #ocaml
<Guest24313> Does a larger default buffer size for Lwt_io make a difference? Say one uses 8192 instead of the default 4096.
JacobEdelman has quit [Quit: Connection closed for inactivity]
<teknozulu> Trying to use Core's Set with a string * string. What should my comparator look like?
<teknozulu> actually Set.Poly.t is probably the move here
Mercuria1Alchemi has joined #ocaml
zpe has joined #ocaml
<Guest24313> Using Lwt_daemon.daemonize but my program doesn't dameonize, it just exits with no exceptions...this was in a Lwt.t thread.
grai has quit [Ping timeout: 240 seconds]
slash^ has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
mcint has quit [Quit: hibernating...]
palomer has quit [Quit: palomer]
palomer has joined #ocaml
Bahman has quit [Read error: Connection reset by peer]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
lazyMonster has joined #ocaml
lazyMonster is now known as lzyMnster
lzyMnster has left #ocaml [#ocaml]
zpe has quit [Ping timeout: 260 seconds]
palomer has quit [Quit: palomer]
mcint has joined #ocaml
Bahman has joined #ocaml
lzyMnster has joined #ocaml
lzyMnster has quit []
lzyMnster has joined #ocaml
lzyMnster has left #ocaml [#ocaml]
damason has quit [Ping timeout: 256 seconds]
Simn has joined #ocaml
Haudegen has quit [Ping timeout: 272 seconds]
cody` has quit [Quit: Connection closed for inactivity]
Haudegen has joined #ocaml
Mercuria1Alchemi has quit [Ping timeout: 260 seconds]
Mercuria1Alchemi has joined #ocaml
ely-se has joined #ocaml
ely-se has quit [Client Quit]
ely-se has joined #ocaml
teknozulu has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Bye.]
zpe has joined #ocaml
BitPuffin|osx has quit [Ping timeout: 255 seconds]
freehck has joined #ocaml
Maelan has quit [Ping timeout: 250 seconds]
tobiasBora has quit [Ping timeout: 272 seconds]
sgnb has quit [Read error: Connection reset by peer]
sgnb has joined #ocaml
Bahman has quit [Remote host closed the connection]
Bahman has joined #ocaml
Guest24313 has quit [Remote host closed the connection]
slash^ has quit [Quit: Leaving.]
freehck has quit [Quit: rcirc on GNU Emacs 24.4.1]
freehck has joined #ocaml
ggole has joined #ocaml
Madars has quit [Ping timeout: 260 seconds]
yomimono has joined #ocaml
lolisa has joined #ocaml
inr_ has joined #ocaml
patronus has joined #ocaml
c-c_ has joined #ocaml
bernardo1pc has joined #ocaml
Mandus_ has joined #ocaml
haelix_ has joined #ocaml
sivoais_ has joined #ocaml
Snark_ has joined #ocaml
tvaalen_ has joined #ocaml
hnrgrgr_ has joined #ocaml
yomimono has quit [Quit: Leaving]
profan_ has joined #ocaml
artart78_ has joined #ocaml
artart78_ has joined #ocaml
eagleflo_ has joined #ocaml
boegel|quassel has joined #ocaml
octachron has joined #ocaml
edwin2 has joined #ocaml
Bahman has quit [Remote host closed the connection]
alpen- has joined #ocaml
julienXX_ has joined #ocaml
Bahman has joined #ocaml
Intensity has quit [*.net *.split]
profan has quit [*.net *.split]
edwin has quit [*.net *.split]
dmiller has quit [*.net *.split]
Mandus has quit [*.net *.split]
patronus_ has quit [*.net *.split]
Snark has quit [*.net *.split]
boegel has quit [*.net *.split]
srax has quit [*.net *.split]
haelix has quit [*.net *.split]
cantstanya has quit [*.net *.split]
yawnt has quit [*.net *.split]
hnrgrgr has quit [*.net *.split]
inr has quit [*.net *.split]
c-c has quit [*.net *.split]
sivoais has quit [*.net *.split]
tvaalen has quit [*.net *.split]
julienXX has quit [*.net *.split]
eagleflo has quit [*.net *.split]
artart78 has quit [*.net *.split]
bernardofpc has quit [*.net *.split]
jave has quit [*.net *.split]
iZsh has quit [*.net *.split]
alpen has quit [*.net *.split]
edwin2 is now known as edwin
julienXX_ is now known as julienXX
yawnt has joined #ocaml
Bahman has quit [Remote host closed the connection]
iZsh has joined #ocaml
tvaalen_ has quit [Changing host]
tvaalen_ has joined #ocaml
tvaalen_ is now known as tvaalen
sivoais_ has quit [Ping timeout: 272 seconds]
jave has joined #ocaml
sivoais has joined #ocaml
srax has joined #ocaml
Madars has joined #ocaml
cantstanya has joined #ocaml
dmiller has joined #ocaml
i0sys has joined #ocaml
_andre has joined #ocaml
slash^ has joined #ocaml
seliopou_ has joined #ocaml
sivoais has quit [Ping timeout: 246 seconds]
Kakadu has joined #ocaml
ely-se has quit [Quit: leaving]
djellemah_ has joined #ocaml
hay207 has joined #ocaml
sivoais has joined #ocaml
theblatt1 has joined #ocaml
artart78_ is now known as artart78
PigDude_ has joined #ocaml
M-Illandan1 has joined #ocaml
jerith_ has joined #ocaml
mcint has quit [Quit: hibernating...]
Intensity has joined #ocaml
hay207__ has quit [*.net *.split]
iosys has quit [*.net *.split]
theblatte has quit [*.net *.split]
PigDude has quit [*.net *.split]
M-Illandan has quit [*.net *.split]
jerith has quit [*.net *.split]
DanielRichman has quit [*.net *.split]
djellemah has quit [*.net *.split]
hbar has quit [*.net *.split]
seliopou has quit [*.net *.split]
MasseR has quit [*.net *.split]
relrod has quit [*.net *.split]
i0sys is now known as iosys
sivoais has quit [Ping timeout: 240 seconds]
dsheets has joined #ocaml
MasseR has joined #ocaml
DanielRichman has joined #ocaml
nicoo has quit [Remote host closed the connection]
mcint has joined #ocaml
nicoo has joined #ocaml
orbifx has joined #ocaml
sivoais has joined #ocaml
ely-se has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kakadu has quit [Quit: Page closed]
sivoais has quit [Read error: Connection reset by peer]
sivoais has joined #ocaml
Kakadu has joined #ocaml
Madars has quit [Ping timeout: 264 seconds]
sivoais has quit [Ping timeout: 255 seconds]
sivoais has joined #ocaml
ely-se has quit [Quit: leaving]
ely-se has joined #ocaml
sbrouf has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
dsheets has quit [Ping timeout: 240 seconds]
sivoais has joined #ocaml
sivoais has quit [Read error: Connection reset by peer]
sivoais has joined #ocaml
ely-se has quit [Quit: leaving]
sivoais has quit [Ping timeout: 276 seconds]
sivoais has joined #ocaml
dsheets has joined #ocaml
keep_learning has joined #ocaml
sivoais has quit [Ping timeout: 264 seconds]
sivoais has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
sivoais has quit [Ping timeout: 264 seconds]
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
inr_ is now known as inr
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 240 seconds]
sivoais has joined #ocaml
JacobEdelman has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
govg has quit [Ping timeout: 260 seconds]
sivoais has joined #ocaml
ely-se has joined #ocaml
hbar has joined #ocaml
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
hnrgrgr_ is now known as hnrgrgr
Haudegen has quit [Ping timeout: 265 seconds]
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
sivoais has quit [Ping timeout: 265 seconds]
Sorella has joined #ocaml
Haudegen has joined #ocaml
Maelan has joined #ocaml
mcint has quit [Quit: hibernating...]
theblatt1 is now known as theblatte
keep_learning has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
jpdeplaix has joined #ocaml
keep_learning has joined #ocaml
Akshay has joined #ocaml
Maelan has quit [Quit: Reconnecting]
Maelan has joined #ocaml
d0nn1e has quit [Ping timeout: 260 seconds]
jerith_ is now known as jerith
d0nn1e has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
Akshya_ has joined #ocaml
struk|desk|away is now known as struk|desk
Akshay has quit [Ping timeout: 265 seconds]
Akshya_ has quit [Quit: Leaving]
lolisa has quit [Ping timeout: 246 seconds]
n1ftyn8_ has quit [Quit: Connection closed for inactivity]
PigDude_ has quit [Quit: leaving]
struk|desk is now known as struk|desk|away
dsheets has joined #ocaml
pierpa has joined #ocaml
RandomThrowaway has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
igoroliveira has joined #ocaml
sbrouf has quit [Ping timeout: 245 seconds]
teratorn has quit [Read error: No route to host]
kaustuv has joined #ocaml
<kaustuv> This is triggering warning 52 in 4.03.0 when it didn't in 4.02.3. How do I work around it?
<kaustuv> let second l = try Some (List.nth l 1) with Failure "nth" -> None
<companion_cube> don't use Failure "nth"
<companion_cube> Failure _ -> None
<companion_cube> this is more robust
<companion_cube> (anyway, I'd write let second = function | _::x::_ -> Some x | _ -> None)
<kaustuv> But it is also not what I want. There are multiple failures that may be raised and I just want to guard List.nth
<kaustuv> (My actual code is not this trivial, obviously.)
<flux> is it a feature though to raise a warning there, though?
<flux> I mean, you're bound to not handle some exceptions.
<kaustuv> Exactly!
<edwin> what does warning 52 say?
<flux> 52 is a new warning, though. maybe you can just disable it?
<kaustuv> > Warning 52: the argument of this constructor should not be matched against a
<kaustuv> > constant pattern; the actual value of the argument could change
<kaustuv> > in the future
<companion_cube> kaustuv: you still shouldn't rely on List.nth to raise exactly this failure
<flux> ok, so it's actually a a specific feature for Failure?-)
<flux> somehow I think it ain't gonna change.. because code does rely on it ;-)
<kaustuv> companion_cube: this is not my code. I agree with you, but I don't want do do major refactoring now just to get it to compile in 4.03.0
<companion_cube> -_-
<companion_cube> does the code raise several flavors of Failure ? :s
<flux> welll, ignore that -warning- then?
sbrouf has joined #ocaml
<flux> or are you compiling with all warnings enabled and "error on warning"?
<kaustuv> companion_cube: several is putting it mildly. It's got only failwiths for errors
<companion_cube> :(
<companion_cube> disgusting
<companion_cube> I'd say: keep the warning, don't silence it, and someday refactor the failwith away
<flux> companion_cube, you don't think it's a nice goal to catch as narrowly as possible?-(
<flux> just put catch _ there, it works just as well.
<companion_cube> I think it's a nice goal not to depend on the exact string in Failure
<companion_cube> it might change
<kaustuv> But realistically, since it's part of the public API, it won't ever change.
<ggole> let nth_exn : 'a list -> int -> 'a option = ... and then use that?
<companion_cube> ^
<companion_cube> good point, ggole
<companion_cube> kaustuv: what's your codebase, if I may ask?
<kaustuv> companion_cube: Abella. (http://abella-prover.org)
<edwin> from the Changes file it looks like you can apply this attribute to any exception, not just Failure: - GPR#254: @ocaml.warn_on_literal_pattern attribute on constructors to warn when the argument is matches against a constant pattern. This attribute is applied on predefined exception constructors which take an purely informational (with no stability guarantee) message. (Alain Frisch)
<companion_cube> hmm ok, fun, never heard of this prover
<kaustuv> I'm just wondering why warning 52 is being triggered in try ... with clauses. It makes sense for match ... with, sure, but exception handlers are not intended to be exhaustive!
<companion_cube> it's still dangerous, because if the messages of List.nth changes then you will not catch the exception
<flux> it's funny, though, how List.nth throws an exception, and then it's impossible to catch that in a future-proof fashion, _unless_ you catch it exactly after calling it.. which is sort of counters what the exceptions are there in the first place.
<flux> s/what the/why the/
<companion_cube> well it's 20 years-old design colliding with modern coding practices
<kaustuv> You can always catch all failures and then write a big if-then-else on messages
<flux> in the 20 years, how many times has the Failure message changed for List.nth.. :-)
<flux> sadly the ocaml exceptions aren't very extensible in a backward-compatible fashion
<kaustuv> The public API for List.nth says that it raises (Failure "nth") and (Invalid_argument "List.nth"). This should give you an idea of changing API norms...
<companion_cube> it would return an option, if it was written now
keep_learning has joined #ocaml
<flux> compared to a class hierarchy, where there is a way to express compatibility
<flux> in fact, objects would make fine ocaml exceptions :P
Mercuria1Alchemi has quit [Ping timeout: 260 seconds]
teratorn has joined #ocaml
sivoais has joined #ocaml
mcmillhj has joined #ocaml
zpe has joined #ocaml
sivoais has quit [Max SendQ exceeded]
Madars has joined #ocaml
<companion_cube> :D
<companion_cube> just disable the warning if you're going that way
<kaustuv> Yes, that's what I'm doing.
Sorella has quit [Quit: Connection closed for inactivity]
<companion_cube> nice
FreeBirdLjj has quit [Read error: Connection reset by peer]
sphinxo has joined #ocaml
FreeBirdLjj has joined #ocaml
kaustuv has left #ocaml ["ERC Version 5.3 (IRC client for Emacs)"]
<sphinxo> Hi i'm trying to concat strings and I'm struggling: http://lpaste.net/147582
<sphinxo> This is ocaml day 1 so I have no idea what i'm doing
sivoais has joined #ocaml
<ggole> sphinxo: ^ doesn't modify either of its arguments. It returns a new string.
<ggole> You probably want to use a Buffer here
<sphinxo> How can i make eval return body?
<ggole> For a start, you're ignoring the return value
<Drup> sphinxo: there are some syntax errors too, you don't need the ";" after the strings on line 32/36
<Drup> and you need parens against the arguments on line 40
<Drup> around*
<sphinxo> How do I make eval return body?
<Drup> sphinxo: the last expression of a function is returned
<Drup> "let f x = .... ; x"
<Drup> it returns x
<sphinxo> ahh that makes sense ofc
<sphinxo> How would I use a buffer? ggole
<companion_cube> for a start, you should just use ^ , I think
sivoais has quit [Ping timeout: 244 seconds]
<companion_cube> to understand how it works
<sphinxo> Creates a new string companion_cube
<sphinxo> eg let foobar = foo ^ bar
<sphinxo> right?
<companion_cube> yes
<companion_cube> let put_parenthesis s = "(" ^ s ^ ")" for instance
<sphinxo> Nice
<ggole> let buf = Buffer.create size in let rec loop ... = Buffer.add_char buf char; loop ... in loop ...; Buffer.contents buf
mcint has joined #ocaml
<companion_cube> ggole: if sphinxo is trying to learn functional programming then that's not helping
<companion_cube> although I agree it's better in practicve
<ggole> I don't believe in suggesting quadratic code to people.
<companion_cube> :(
<sphinxo> quadratic code? what does that mean?
sivoais has joined #ocaml
<companion_cube> sphinxo: do you know other programming languages?
Denommus has joined #ocaml
<sphinxo> functional? done some haskell and fsharp
<sphinxo> otherwise rust, python and c
<companion_cube> oh, so it should be close to f#
<ggole> Because ^ creates a new string of length equal to both of its arguments, using ^ to add a character to an accumulated string in a loop takes time quadratic in the length of the input
<Denommus> OCaml is like F#, but with a powerful module system
<Drup> ^ the doc for buffers
<sphinxo> Thanks
RandomThrowaway has left #ocaml [#ocaml]
<sphinxo> getting unbound record field add_string on buffer?
Madars has quit [Ping timeout: 245 seconds]
<ggole> I guess you're doing buf.add_string char: it should be Buffer.add_string buf char
sivoais has quit [Ping timeout: 240 seconds]
<sphinxo> Ahh :)
sivoais has joined #ocaml
JacobEdelman has quit [Quit: Connection closed for inactivity]
FreeBirdLjj has quit [Remote host closed the connection]
JacobEdelman has joined #ocaml
jonludlam has joined #ocaml
sivoais has quit [Ping timeout: 272 seconds]
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
rpg has joined #ocaml
sivoais has quit [Ping timeout: 250 seconds]
sivoais has joined #ocaml
zaquest has quit [Remote host closed the connection]
theblatte has quit [Ping timeout: 255 seconds]
groovy2shoes has quit [Quit: Leaving]
sivoais has quit [Ping timeout: 272 seconds]
theblatte has joined #ocaml
sivoais has joined #ocaml
zomgbie has joined #ocaml
zomgbie has quit [Client Quit]
sivoais has quit [Ping timeout: 246 seconds]
keep_learning has quit [Quit: This computer has gone to sleep]
mcint has quit [Quit: hibernating...]
keep_learning has joined #ocaml
ely-se has quit [Quit: leaving]
sivoais has joined #ocaml
struk|desk|away is now known as struk|desk
zpe has quit [Remote host closed the connection]
kolko has quit [Ping timeout: 255 seconds]
sivoais has quit [Read error: Connection reset by peer]
musha68k has joined #ocaml
sivoais has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
yomimono has joined #ocaml
sivoais has quit [Ping timeout: 260 seconds]
sivoais has joined #ocaml
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
musha68k has quit [Quit: leaving]
sivoais has quit [Read error: Connection reset by peer]
ygrek has joined #ocaml
musha68k has joined #ocaml
sivoais has joined #ocaml
lolisa has joined #ocaml
yomimono has quit [Ping timeout: 264 seconds]
sgnb has quit [Remote host closed the connection]
larhat1 has joined #ocaml
Khady has quit [Quit: Quit.]
Khady has joined #ocaml
relrod_ has joined #ocaml
relrod_ has quit [Changing host]
relrod_ has joined #ocaml
octachron has quit [Quit: Leaving]
relrod_ is now known as relrod
keep_learning has quit [Quit: This computer has gone to sleep]
cyraxjoe has joined #ocaml
tane has joined #ocaml
BitPuffin|osx has joined #ocaml
ril has joined #ocaml
zaquest has joined #ocaml
psy_ has quit [Remote host closed the connection]
keep_learning has joined #ocaml
ely-se has joined #ocaml
ely-se has joined #ocaml
ely-se has left #ocaml ["Leaving"]
<sphinxo> say I have let add_one i = i + 1 , can I have a list of these and look at what i was for each one?
<flux> sphinxo, list of what? functions or i-values?
<sphinxo> Partial functions?
<dmbaturin> sphinxo: let add_one i = my_sideeffectful_expression; i + 1
<sphinxo> huh dmbaturin ?
<flux> sphinxo, yes, you can have add_one functions in a list
<flux> ie. let funcs = [add_one; add_two]
<sphinxo> let funcs = [add_one 2] ?
<flux> well, yes, that's just placing a value of a function call into a list
<dmbaturin> sphinxo: I thought you want to update some list of values from the function for debug purposes.
<sphinxo> no, I guess i'm looking for some kind of enum that has params and also is a function
ollehar has joined #ocaml
<sphinxo> I'm treating it like an enum
darkf has quit [Quit: Leaving]
<ggole> Er, what?
<sphinxo> ok more like a mapping with params or something
<sphinxo> So I have several functions like move, modify which take params and return strings
<sphinxo> And I was wondering if I could just append them to a list, do some optimisations (eg move +1, move -2 = move -1)
<flux> if you want to see inside the definitions, you better just define a type, ie. type ops = Move of int | .. etc
<flux> and then provide a function let eval op env = match op with Move x -> do something with x and env
<flux> then you are able to modify the tree of operations as you wish
<sphinxo> Yeah that makes more sense
<sphinxo> thanks
lolisa has quit [Quit: meow]
Sorella has joined #ocaml
<sphinxo> When doing a type like that how would I do type ops = Loop of [ops] ?
<sphinxo> I've tried Loop of ops[]
<flux> type expr = Add of int * int | Loop of expr list
<sphinxo> Thanks
Kakadu has quit [Quit: Page closed]
<sphinxo> how can i match the first two values of a list?
<rks`> you can't.
<sphinxo> oh...
<sphinxo> How would I translate something like this? http://lpaste.net/147597
<sphinxo> into ocaml
cdidd has quit [Ping timeout: 246 seconds]
<companion_cube> match l with | a :: b :: _ -> foo | [_] | [] -> bar ?
<sphinxo> ooh, that looks like it'll work
<Korhonen> Is thre any way to make an explicit type declration or a function argument taking an object that uses row polymorphism. As in say I have a "'a listobj" type that has the hd and tl methods, is there any way to define a function that takes an object that implements hd and tl + any other number of unspecified methods.
<companion_cube> val foo : <hd: 'a ; tl: 'a ; ..> -> bar
<Korhonen> Something like "let f (x : int list ..)" or whatever
<companion_cube> let f (x : <hd:'a ; tl:'a ; ..>) = ...
<Korhonen> Yeah, I know but that requires you to type out the entire declration every time.
<Korhonen> Iwonder if you can use the 'a list name you already have and add the dots to it
<sphinxo> companion_cube: can I use _ in foo?
<companion_cube> oh, yes, just give it a name
<Korhonen> Since the actual type I have uses quite a lot more methods, this is just an example and typing it out every time maes the code unreadable.
<companion_cube> a :: b :: tail -> ...
<Korhonen> Well, I have a name right now, but the name is closed. If I give something that is opened a name then it complains.
<companion_cube> Korhonen: sadly you cannot manipulate or name the .. itself
<Korhonen> Hmm, so there's no way to declare an obect type that is another already named object type + extra methods?
tane has quit [Remote host closed the connection]
rpg has quit [Ping timeout: 246 seconds]
octachron has joined #ocaml
<companion_cube> Korhonen: you can use classes
<companion_cube> it's not exactly the same thing though
<companion_cube> class + inheritance allows to add methods to an already existing class
ygrek has quit [Ping timeout: 245 seconds]
<octachron> Korhonen, maybe "type 'a t = < hd:'b; .. > as 'a" and "f (x:'a t) = ..."
<Korhonen> Ahhh
dretnx has joined #ocaml
<Korhonen> You need to add "as 'a"
<ggole> You can "join" class types and arbitrary methods in a type, but it's a bit of a hack
<Korhonen> Got it
<ggole> It's something like type 'a t = #foo as 'a constraint 'a = <zonk : int; blap : int; ...>
<ggole> 'a t will then be the type of #foo plus the methods zonk and blap
rand_ has joined #ocaml
dretnx has quit [Client Quit]
<ggole> I don't think that works for plain object types though
<sphinxo> What does this error mean? This expression has type (directive * directive) list but an expression was expected of type directive list
<octachron> sphinxo, the type of the element list in your list is the tuple type directive * directive rather than a simple directive
<octachron> you might have a [x, y ] list when you meant [x; y]
<sphinxo> yep :) new to ocaml
mcint has joined #ocaml
palomer has joined #ocaml
struktured has quit [Ping timeout: 240 seconds]
nullcatxxx_ has joined #ocaml
Madars has joined #ocaml
struk|desk is now known as struk|desk|away
ril has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kakadu has joined #ocaml
ril has joined #ocaml
groovy2shoes has joined #ocaml
yomimono has joined #ocaml
<sphinxo> How can I map a list to a function and remove all none values in the returned list?
yomimono has quit [Client Quit]
ollehar has quit [Ping timeout: 255 seconds]
<companion_cube> look for some "filter_map" functions in alternative stdlibs
<companion_cube> or you can write one yourself, it's 3 or 4 lines
<pierpa> or you use List.fold_left
<sphinxo> How would I use List.fold_left?
<pierpa> List.fold_right even better :)
<sphinxo> fold_right?
<sphinxo> How would I use it?
<pierpa> first you read the documentation in the manual, then if something is not clear you ask
<Algebr`> sphinxo: here's an example: List.fold_left (fun accum value -> if value < 2 then value :: accum else accum) [] some_list
rpg has joined #ocaml
Haudegen has quit [Ping timeout: 255 seconds]
<sphinxo> I'm trying to use String.map to map over every char and it doesn't seem to work? http://lpaste.net/147600
larhat1 has quit [Read error: Connection reset by peer]
larhat1 has joined #ocaml
<Algebr`> because map first argument is a function that is supposed to give back char
<Algebr`> and you are giving back char option
Lasher` has quit [Ping timeout: 260 seconds]
<Algebr`> rather, you're giving back an instruction option
<sphinxo> How would I fix that?
<Algebr`> well this approache doesn't work right, so you need to think of another one?
<sphinxo> oh, ok
Lasher` has joined #ocaml
<Algebr`> think of other things that can map easily, where the return type of the map function isn't so restrained
<Algebr`> like List.map
<sphinxo> so seperate the string into a list of chars?
<Algebr`> yup, that's what i was thinking
Madars has quit [Ping timeout: 260 seconds]
<Algebr`> at least that's what i probably would have done and then List.map on them
ollehar has joined #ocaml
<sphinxo> String.explode?
<Algebr`> how you do it is up to you.
<sphinxo> What way do you think is best?
<octachron> another option would be to convert to an instruction array with Array.init
<sphinxo> how? octachron
<Algebr`> sphinxo: i think the best way is the one you come up with one your own.
<octachron> sphinxo, your initial problem stems to the fact that String is specialized to char elements
<octachron> so a way to go around this problem is to get back to the general array type by constructing a new array
Haudegen has joined #ocaml
tane has joined #ocaml
<octachron> and an array can be constructed with either Array.make and Array.init.
<octachron> Array.init allows you to construct an array from an int -> element function
<sphinxo> int?
_andre has quit [Quit: leaving]
<octachron> the type of integers?
<sphinxo> I want to go from char -> element
ygrek has joined #ocaml
<octachron> fortunately, you also have an int -> char function laying around
<sphinxo> do you mean char -> int?
<octachron> No. It might help to read Array.init description http://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html
<sphinxo> ahhh, I think I understand
sbrouf has quit [Ping timeout: 276 seconds]
rand_ has quit [Quit: leaving]
keep_learning has quit [Quit: This computer has gone to sleep]
ely-se has joined #ocaml
<sphinxo> Ok, i'm stuck
<sphinxo> So i need to work out the ints for my chars and modify the function so it matches against them?
orbifx2 has joined #ocaml
orbifx has quit [Read error: Connection reset by peer]
<octachron> sorry, I was talking about the String.get(:int->char) function
<octachron> if you have a string and you want to construct a general array , you want the k-th element of the new array to be "f (k-th element of the char)"
<sphinxo> Array.init (String.length chars) (String.get chars) ?
<companion_cube> let foo f s = Array.init (String.length s) (fun i-> f s.[i])
<companion_cube> yeah, this
orbifx2 has quit [Ping timeout: 246 seconds]
<sphinxo> Awesome thanks, I think i've got it
slash^ has quit [Read error: Connection reset by peer]
Haudegen has quit [Ping timeout: 260 seconds]
orbifx has joined #ocaml
<sphinxo> I feel this can be simplified:
<sphinxo> List.filter( Option.is_some Array.to_list((Array.map (match_instruction) (Array.init (String.length str) (String.get str)))))
<companion_cube> you should rather use pattern matching
<sphinxo> to see if some?
<companion_cube> List.fold_left (fun x l -> match f x with None -> l | Some y -> y :: l) list []
<companion_cube> yeah, String.get is evil
<companion_cube> errrrrr
groovy2shoes has quit [Quit: Leaving]
<companion_cube> wait, I read Option.get
<sphinxo> raises exception?
<companion_cube> nah, never mind
<companion_cube> but you still have options, in your case
ollehar has quit [Ping timeout: 255 seconds]
<sphinxo> Now it looks like:
<sphinxo> List.fold_left (fun x l -> match match_instruction x with None -> l | Some y -> y :: l) (Array.init (String.length str) (String.get str)) []
zozozo has quit [Quit: WeeChat 1.3]
<sphinxo> Ohh going to need to turn array into list
<sphinxo> probably should rename match_instruction
<sphinxo> any other improvements?
<companion_cube> the [] might be before the list you fold on, if you use fold_left
<sphinxo> ooh
<companion_cube> fold_left and fold_right are subtly different
Haudegen has joined #ocaml
orbifx2 has joined #ocaml
ggole has quit []
orbifx3 has joined #ocaml
orbifx has quit [Ping timeout: 265 seconds]
orbifx2 has quit [Ping timeout: 255 seconds]
<sphinxo> I don't understand this error: Error: This expression has type 'a list but an expression was expected of type char
<companion_cube> ah yes, you swapped the arguments to the fold function
<companion_cube> look at the signature of fold_left and fold_right
<sphinxo> List.fold_left f a [b1; ...; bn]
<sphinxo> I guess I got the type of a wrong?
<companion_cube> of f, I think
<companion_cube> also the typechecker gives you the location of the error
orbifx has joined #ocaml
<sphinxo> so f needs to return a list?
<sphinxo> or f takes a list?
<companion_cube> fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
<companion_cube> so, if you have a char list, the char argument to the function is the second one
orbifx3 has quit [Ping timeout: 246 seconds]
zozozo has joined #ocaml
<sphinxo> Sorry I don't understand
orbifx3 has joined #ocaml
<companion_cube> what is wrong? :)
<sphinxo> can you explain what you mean in the last thing you said
orbifx has quit [Ping timeout: 265 seconds]
<sphinxo> wait
<sphinxo> so I need to swap back the list of chars?
orbifx has joined #ocaml
<companion_cube> no, I say you probably need to change the order of the arguments to the anonymous function
<companion_cube> can I see your code ?
<sphinxo> Sure
<companion_cube> on a pastebin-like, please
<sphinxo> ofc :) http://lpaste.net/147612
<sphinxo> bunch of stuff commented out
<companion_cube> yes, so you should swap x and l
<companion_cube> also, you can use `let` :)
orbifx3 has quit [Ping timeout: 246 seconds]
<companion_cube> I edited it
<sphinxo> Nice
<sphinxo> Thanks
<companion_cube> do you see?
<sphinxo> yes
Mercuria1Alchemi has joined #ocaml
<companion_cube> cool :)
<sphinxo> is a infix function composition op?
<sphinxo> I mean does it exist in ocaml
<companion_cube> not in the stdlib
<companion_cube> it's pretty easy to defined though
<companion_cube> for instance let (%>) f g x = g (f x)
<companion_cube> then you can write f %> g
<sphinxo> nice
struk|desk|away is now known as struk|desk
<sphinxo> Is there an easy way to print datastructures in ocaml?
<sphinxo> like some kind of debug print or something
<companion_cube> outside the toplevel, no
<sphinxo> oh :|
<companion_cube> well, on 4.02, you can try https://github.com/whitequark/ppx_deriving
<companion_cube> it's a preprocessor that generates code
ollehar has joined #ocaml
<companion_cube> read the readme carefully
<sphinxo> seems to be cheating :)
groovy2shoes has joined #ocaml
<companion_cube> yep, quite convenient
<sphinxo> No easy way to print elements of my types?
<companion_cube> well, annotate them with [@deriving "show"]
<companion_cube> or [@@deriving show], something like this
<companion_cube> it's in the readme
<sphinxo> This feels like it should be in the std
<companion_cube> it's... complicated
<bitbckt> hah
<companion_cube> but external dependencies shoud not be a problem nowadays
<sphinxo> true true
<sphinxo> I also think the fact that the compiler stops after the first error is not great :(
<companion_cube> I like it, actually
<companion_cube> but you might want to use merlin
<sphinxo> I do :)
<companion_cube> oh, then, doesn't it give you errors quickly?
<sphinxo> that's true
<sphinxo> but then when I switch to my terminal I have to go back and forth
freehck has quit [Remote host closed the connection]
<ollehar> sphinxo: your editor should be integrated with make?
<sphinxo> probably yeah
<ollehar> if vim, just press enter and vim will take you to the error line/file.
<sphinxo> What's the best way to match a list of a type and append to a string as you go?
<bitbckt> sounds like a fold.
<sphinxo> Fold on a list that concat to string?
<sphinxo> fold to a list
<bitbckt> fold over a list, concatenating to a string (the accumulator), yeah.
octachron has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
lobo has joined #ocaml
<sphinxo> What does this error mean? This expression has type op list but an expression was expected of type out_channel
<ygrek> I think it means what it says?
<sphinxo> what is type out channel?
<bitbckt> you're trying to print something and got the argument order wrong?
<bitbckt> perhaps...
Sebastian has joined #ocaml
<Sebastian> Hello
Sebastian is now known as Guest73542
rpg has quit [Quit: rpg]
<sphinxo> Hello Guest73542
<Guest73542> I was wondering if someone could help me out with a problem I'm having on Window
<Guest73542> s
<sphinxo> Possibly, what's the issue you're having
<Guest73542> I'm trying to compile OPAM under mingw-w64 as per the instructions found on OPAM's Github
Mercuria1Alchemi has quit [Ping timeout: 265 seconds]
<Guest73542> I keep running into an error when trying to run "make lib-ext" to download the dependencies when trying to proceed with compilation
<sphinxo> What's the error?
<Guest73542> I'll provide a paste of the compilation log
tane has quit [Ping timeout: 250 seconds]
teknozulu has joined #ocaml
<sphinxo> Do you especially want to compile it?
<sphinxo> I think this may include opam http://www.typerex.org/ocpwin.html
ygrek has quit [Ping timeout: 256 seconds]
<Guest73542> I tried using that package earlier
<Guest73542> I'm trying to follow along with Real World OCaml
<sphinxo> ahh, ok
<sphinxo> I don't think the jane street libs work on windows
<Guest73542> Some of the necessary libraries didn't install due to compilation errors
<Guest73542> Oh
teknozulu_ has joined #ocaml
<Guest73542> Hm
<sphinxo> I would suggest that you maybe use a virtual machine?
<sphinxo> ^^ "Note that Windows is not currently supported by the examples in Real World OCaml or by OPAM, although it is being worked on. "
teknozulu has quit [Ping timeout: 240 seconds]
<sphinxo> ^^ last updated 17 Oct
tane has joined #ocaml
jonludlam has quit [Quit: Leaving]
sphinxo has quit [Quit: WeeChat 1.3]
ygrek has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 265 seconds]
ely-se has quit [Quit: Leaving...]
ril has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
damason has joined #ocaml
teknozulu_ has quit [Ping timeout: 240 seconds]
zpe has quit [Ping timeout: 272 seconds]
Accidus has joined #ocaml
<Accidus> 'opam install ocp-build' fails on 4.03.0+trunk with "undefined reference to `caml_is_printable'" --- any advice as to how to proceed?
Kakadu has quit [Remote host closed the connection]
Kakadu has joined #ocaml
Kakadu has quit [Remote host closed the connection]
Kakadu has joined #ocaml
tane has quit [Quit: Verlassend]
teknozulu has joined #ocaml
Guest73542 has quit [Quit: Page closed]
Haudegen has quit [Ping timeout: 244 seconds]
struk|desk is now known as struk|desk|away
Haudegen has joined #ocaml
Kakadu has quit [Remote host closed the connection]