adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.2 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
ygrek has quit [Ping timeout: 252 seconds]
rgrinberg1 has joined #ocaml
rgrinberg has quit [Ping timeout: 246 seconds]
jonludlam has quit [Ping timeout: 268 seconds]
ygrek has joined #ocaml
obadz has quit [Ping timeout: 240 seconds]
obadz has joined #ocaml
damason has joined #ocaml
AltGr has joined #ocaml
browncodes has quit [Remote host closed the connection]
nullcatx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
enamex has quit [Ping timeout: 255 seconds]
mea-culpa has quit []
nullcatxxx_ has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
igoroliveira has joined #ocaml
browncodes has joined #ocaml
nullcatxxx_ has quit [Max SendQ exceeded]
nullcatxxx_ has joined #ocaml
enamex has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg1 has quit [Ping timeout: 264 seconds]
toomuchtvrotsurb has quit [Remote host closed the connection]
toomuchtvrotsurb has joined #ocaml
toomuchtvrotsurb has quit [Remote host closed the connection]
ygrek_ has joined #ocaml
tmtwd has joined #ocaml
ygrek has quit [Ping timeout: 260 seconds]
nullcatxxx_ has joined #ocaml
nullcatxxx_ has quit [Client Quit]
nullcatxxx_ has joined #ocaml
ygrek_ has quit [Ping timeout: 246 seconds]
Algebr has joined #ocaml
<Algebr> Anyone on OS X, el captain? I'm trying to verify that the newest OS X update broke the standard ocaml tools
moei has quit [Quit: Leaving...]
dalastboss has joined #ocaml
<dalastboss> Is there a way to tell ocamlbuild to compile with a larger stack size then the default?
gdd229 has joined #ocaml
dsturb has quit [Ping timeout: 240 seconds]
palomer has quit [Quit: palomer]
psy_ has joined #ocaml
empyrean has quit [Ping timeout: 252 seconds]
palomer has joined #ocaml
pilne has quit [Remote host closed the connection]
<yminsky> Algebr: I'm on el capitan, and things are working fine for me.
<enjolras_> dalastboss: for threads, i don't know but for process i think the stack is allocated by the os, and you need to change it at runtime with ulimit -s
<enjolras_> at least on linux
AltGr has left #ocaml [#ocaml]
Algebr has quit [Ping timeout: 250 seconds]
gdd229 has quit [Quit: WeeChat 0.4.2]
dsturb has joined #ocaml
dsturb has quit [Remote host closed the connection]
AltGr has joined #ocaml
<dalastboss> @Enjolras_: would that require me to do whatever work I want in a new process?
<dalastboss> I dont see how I can execute a ulimit -s at runtime without opening a new process
<enjolras_> i mean ulimit -s is an environment setting, per user
<enjolras_> maybe you can launch a process specifically with a larger stack, not sure how though
<dalastboss> ah
<dalastboss> my issue is that if i do ulimit -s and increase the stack size, everything works fine on my machine
enamex has quit [Ping timeout: 244 seconds]
<dalastboss> but I need to submit the source for this compiler to be graded on a different machine
<dalastboss> so my only other thought is to to put "ulimit -s ..." in my makefile
<dalastboss> otherwise the stack size will be too small when run on the other machine
<enjolras_> on linux you can allocate the stack yourself, but i've no idea how to do that in ocaml. You probably need to start from C and then run the ocaml binary
dalastboss has quit [Quit: Page closed]
xaimus has quit [Ping timeout: 272 seconds]
nullcatx_ has joined #ocaml
nullcatxxx_ has quit [Ping timeout: 246 seconds]
AltGr has left #ocaml [#ocaml]
xaimus has joined #ocaml
darkf has joined #ocaml
palomer has quit [Quit: palomer]
rgrinberg1 has joined #ocaml
AltGr has joined #ocaml
palomer has joined #ocaml
rgrinberg1 has quit [Ping timeout: 252 seconds]
mac10688 has quit [Ping timeout: 250 seconds]
echo-area has joined #ocaml
psy_ has quit [Ping timeout: 264 seconds]
palomer_ has joined #ocaml
palomer has quit [Ping timeout: 240 seconds]
palomer_ is now known as palomer
rgrinberg1 has joined #ocaml
nullcatxxx_ has joined #ocaml
nullcatx_ has quit [Read error: Connection reset by peer]
nullcatxxx_ has quit [Read error: Connection reset by peer]
nullcatxxx_ has joined #ocaml
palomer has quit [Quit: palomer]
AltGr has left #ocaml [#ocaml]
swgillespie has joined #ocaml
MercurialAlchemi has joined #ocaml
keen___________5 has joined #ocaml
keen___________4 has quit [Ping timeout: 268 seconds]
palomer has joined #ocaml
browncodes has quit [Remote host closed the connection]
AltGr has joined #ocaml
<palomer> does ocaml know how to correctly hash a set?
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tibor_ has quit [Quit: Page closed]
nullcatxxx_ has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
<flux> if you by 'correctly' you mean that hashes built differently but have the same contents then I expect 'no'
<flux> oops I meant 'sets built differently'
<flux> so you cannot use the polymorphic hashing on sets in that manner
palomer has quit [Quit: palomer]
zpe has joined #ocaml
zpe_ has joined #ocaml
nullcatxxx_ has quit [Read error: Connection reset by peer]
tmtwd has quit [Ping timeout: 240 seconds]
zpe has quit [Ping timeout: 246 seconds]
nullcatxxx_ has joined #ocaml
tmtwd has joined #ocaml
psy_ has joined #ocaml
zpe has joined #ocaml
luzie has quit [Quit: WeeChat 1.4-dev]
luzie has joined #ocaml
zpe_ has quit [Ping timeout: 240 seconds]
igoroliveira has quit [Quit: Connection closed for inactivity]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
palomer has joined #ocaml
thizanne has joined #ocaml
__uu__ has joined #ocaml
moei has joined #ocaml
<enjolras_> hi, i have an exception which is raised from toplevel code of a linked module, and i don't know which ones. It happens before the entry point of my main module
<enjolras_> any hint on how to debug this ?
tmtwd has quit [Ping timeout: 246 seconds]
<adrien> Enjolras_: gdb and backtrace?
enamex has joined #ocaml
<dmbaturin> Enjolras_: Compiling with -g and running with OCAMLRUNPARAM=b env variable gives some exception trace.
<adrien> Enjolras_: but in practice Ive found that there are few enough of such expressions that I could check by reading the code
nullcatxxx_ has quit [Quit: gone...]
<adrien> and actually, strace might help
<enjolras_> dmbaturin: yes, well, it tells me it failed in pervasive
<enjolras_> not much help
<adrien> Enjolras_: backtrace isn't deeper?
<enjolras_> adrien: right, strace gave me the root of the problem, but not where it happens in codebase
<enjolras_> no
<dmbaturin> In pervasives? Is it a stable ocaml release?
<adrien> could be trying to open a file
<enjolras_> yes, it fails with ENOENT, and raises Not_found
<dmbaturin> Could you paste the backtrace?
<def`> Inlined call from your code :p
ygrek_ has joined #ocaml
<enjolras_> but, what i would like to know is where it comes from
<def`> try in bytecode
<flux> enjolras_, ocamlopt or ocamlc?
antkong_ has joined #ocaml
<enjolras_> def`: i can't :/ Not without an hour of work
palomer has quit [Quit: palomer]
<enjolras_> flux: native
<flux> well, try in bytecode :)
<flux> hour of work or hour of compilation?
<def`> Try with my patches :)
<enjolras_> flux: i need to port it to bytecode, link custom stubs, etc
<flux> enjolras_, you should've done it from the get-go.. :-)
<enjolras_> def`: what are your patches ?
<flux> but, I need to go ->
<enjolras_> dmbaturin: the backtrace says nothing besides "it raises Not_found from pervasives open"
<enjolras_> this is probably because it's a toplevel code block somewhere
<enjolras_> which is executed at launch time and then, there is no more backtrace
<enjolras_> def`: thanks
<enjolras_> actually, i just need a way to find the module name
<def`> Enjolras_: it's a bit early, but soon it will become less of a problem :(
<def`> run in gdb?
<def`> or print the name of each modulenat the beginning
<enjolras_> too many. like 50 modules which get linked
<def`> hmm let me think...
<enjolras_> is there a common excption handler symbol i can break point at ?
<enjolras_> hmm, it won't help actually, it will just be in persvasives
<enjolras_> but maybe, you're right, gdb and hit "next" until it fails, it'll try that first, thanks
<def`> Printexc.set_uncaught_exception_handler
<def`> as soon as Printexc module is loaded, all top exn go through it
Haudegen has quit [Ping timeout: 265 seconds]
antkong_ has quit [Quit: antkong_]
<enjolras_> grmpf. It does nothing. Probably again because it happens before the entry point of my main module
<def`> You should link this module first
<def`> The order of linking determines when top effects occur
<enjolras_> i'll try to build manually then
<adrien> Enjolras_: if you only want the module name, I'm fairly sure gdb has what you want
<adrien> you'll get a symbole like caml__thatmodule__init or some something in that spirit
<def`> camlModule__entry
<enjolras_> ok, thanks for the hints
Haudegen has joined #ocaml
damason has quit [Ping timeout: 240 seconds]
zpe has quit [Remote host closed the connection]
<def`> Enjolras_: and afer that, there is a way to know how far ocaml went into initialization when it failed
<def`> it's just not practical :)
<def`> (although it could be made usable from your print exception handler)
xificurC has quit [Read error: Connection reset by peer]
xificurC has joined #ocaml
rgrinberg1 has quit [Ping timeout: 252 seconds]
xificurC_ has joined #ocaml
xificurC has quit [Ping timeout: 260 seconds]
zpe has joined #ocaml
malc_ has quit [Quit: leaving]
ely-se has joined #ocaml
t4nk290 has joined #ocaml
<t4nk290> Hi, I am new to Ocaml
<t4nk290> so I recently installed opam with ocaml on my mac
<t4nk290> went on terminal and typed in "ocaml" to launch it
<t4nk290> now I'm on "top level"
<t4nk290> but how do I create a file for my program?
<def`> with any text editor (emacs, vim, sublime if you prefer)
<t4nk290> so I'd create a file.ml using emacs/vim/etc
<def`> yes
<t4nk290> then open it in ocaml using #use "file.ml"
<def`> if you want to run from the toplevel/repl, yes
<def`> otherwise you can produce an executable file
<t4nk290> ok
<t4nk290> alright, thanks
<def`> you are welcome
<t4nk290> and say my program has multiple functions in it
<t4nk290> and the very first function takes in an argument
<t4nk290> actually
<t4nk290> nvm
<def`> :)
psy_ has quit [Quit: Leaving]
zpe has quit [Remote host closed the connection]
enamex has quit [Ping timeout: 244 seconds]
<enjolras_> interesting. I'm finishing lunch, and will try, thanks a lot
AltGr has left #ocaml [#ocaml]
xificurC has joined #ocaml
oscar_toro has joined #ocaml
xificurC_ has quit [Ping timeout: 252 seconds]
__uu__ has quit [Read error: Connection timed out]
__uu__ has joined #ocaml
xificurC_ has joined #ocaml
xificurC has quit [Ping timeout: 240 seconds]
darkf_ has joined #ocaml
AltGr has joined #ocaml
darkf has quit [Ping timeout: 240 seconds]
sh0t has joined #ocaml
mort___ has quit [Quit: Leaving.]
zpe has joined #ocaml
zpe has quit [Read error: Connection reset by peer]
zpe_ has joined #ocaml
zpe_ has quit [Read error: Connection reset by peer]
zpe has joined #ocaml
rgrinberg1 has joined #ocaml
orbifx has joined #ocaml
rgrinberg1 has quit [Ping timeout: 244 seconds]
mort___ has joined #ocaml
darkf_ is now known as darkf
zpe has quit [Ping timeout: 260 seconds]
zpe has joined #ocaml
sh0t has quit [Ping timeout: 256 seconds]
toolslive has joined #ocaml
<toolslive> I'm trying to generate a generic show for sets. but I'm failing. my current attempt is this: https://gist.github.com/toolslive/73cf506cdea22d2630a3 the downside is that I have to shadow all input modules (String,Int32,...) Is there a better way?
larhat1 has quit [Quit: Leaving.]
ygrek_ has quit [Ping timeout: 272 seconds]
zpe_ has joined #ocaml
zpe has quit [Read error: Connection reset by peer]
yomimono has joined #ocaml
lionel_ has joined #ocaml
lionel_ has left #ocaml [#ocaml]
sepp2k has joined #ocaml
rgrinberg1 has joined #ocaml
rgrinberg1 has quit [Ping timeout: 250 seconds]
jonludlam has joined #ocaml
t4nk290 has quit [Quit: Page closed]
Kakadu has joined #ocaml
dsheets has joined #ocaml
<lyxia> toolslive: Why is it necessary to shadow the input modules? Can't you call the first one "StringShow" instead of "String" for example?
<toolslive> yes, but I would like to avoid creating extra module(name)s. ideally, it would work with the std String module
beginner has joined #ocaml
<beginner> are unit tests a proper approach to test a compiler written in ocaml?
dsheets has quit [Ping timeout: 240 seconds]
octachron has joined #ocaml
<toolslive> what is the input of these unit tests, and what is asserted?
<flux> is compiler a unit? I would say no. but it certainly is built of units that are suitable for unit testing.
<flux> but you can some form of 'integration tests': run compiled programs and check if they do what you expect
zpe_ has quit [Remote host closed the connection]
<toolslive> you can have a unit test for a certain optimization: have a program which should get the certain transformation, and check the intermediate/asm output to assert it has been done.... compilers typically have a zillion test programs like that.
<flux> sounds like that's mostly useful for regression testing, if the input and output are defined literally
<flux> and if you should make an optimization rename the registers somehow, such a test would fail, even though nothing has been broken but the tests
<flux> of course if you can make your tests better, then great :)
<flux> in particular that can be annoying if you're just starting to write the compiler and big - or small - changes are bound to happen
<flux> whereas with test programs that's much, much less likely
<toolslive> you can assert the transformation before the register assignment....
<flux> just an example. could be another thing than register assignment, for example moving code around might just cause the instructions to be written in different order, because it wouldn't matter
<toolslive> you can do 'system tests' but if you can validate something with a 'unit test' it's going to be cheaper in general.
<toolslive> I'm not saying 'yes' or 'no', I'm just saying it 'it could be' ;)
<flux> maybe something like counting the number of different operations would be a decent check, but not actually a test
<beginner> how is it done with the ocaml compiler itself?
<flux> well, if it's well-typed then it works.. :)
<flux> apparently they take a bunch of ocaml apps/libs and try to compiel them..
<flux> actually ocaml/testsuite/tests is the place to look at
<flux> so it seems they run test programs and have a golden output
<flux> some of them seem to be as if they were entered to the toplevel
<flux> and the golden output then includes the responses from the toplevel
<flux> the golden output can be short. for example, ocaml/testsuite/tests/misc/weaktest.ml is 83 lines long and its output is: if !mistakes < 5 then printf "pass\n" else printf "fail\n";;
<octachron> from my understanding, toplevel tests are used for catching expected compilers warnings/errors
<ely-se> is toplevel the most high-level? :P
ely-se has quit [Quit: leaving]
dsheets has joined #ocaml
ely-se has joined #ocaml
Haudegen has quit [Ping timeout: 246 seconds]
rgrinberg1 has joined #ocaml
toolslive has quit [Ping timeout: 256 seconds]
rgrinberg1 has quit [Ping timeout: 256 seconds]
ely-se has quit [Quit: leaving]
empyrean has joined #ocaml
Haudegen has joined #ocaml
zpe has joined #ocaml
toolslive has joined #ocaml
AltGr has left #ocaml [#ocaml]
darkf_ has joined #ocaml
ggole has joined #ocaml
darkf has quit [Ping timeout: 246 seconds]
jonludlam has quit [Ping timeout: 264 seconds]
darkf_ is now known as darkf
ely-se has joined #ocaml
Soni has quit [Quit: Leaving]
_andre has joined #ocaml
jonludlam has joined #ocaml
__uu___ has joined #ocaml
__uu__ has quit [Ping timeout: 260 seconds]
dsheets has quit [Ping timeout: 244 seconds]
BitPuffin has joined #ocaml
rgrinberg1 has joined #ocaml
rgrinberg1 has quit [Ping timeout: 265 seconds]
antkong_ has joined #ocaml
antkong_ has quit [Client Quit]
freehck has joined #ocaml
<freehck> Hello everybody! :)
zpe has quit [Remote host closed the connection]
<freehck> I've configured a second monitor, so I can be in chat all the time. Hooray! :)
zpe has joined #ocaml
zpe has quit [Ping timeout: 260 seconds]
<dmbaturin> freehck: Have you heard of IRC clients? ;)
<freehck> I've heared, but our company has a strict restriction for output connections, so I can use only webchat. :)
<flux> "hi boss, can I get a new monitor?" "sure, whatcha gonna use it for?" "stuff.."
<freehck> Hey, chatting is a very important part of the work. It helps to quickly solve problems.
oscar_toro has left #ocaml [#ocaml]
<dmbaturin> freehck: Have you heard of SSL proxies? ;)
huza has joined #ocaml
<freehck> dmbaturin: yep, and I'm going to deploy an openvpn server with proxy to it for my own needs. But it'll take time, so now it's the easiest solution for me. :)
ely-se has quit [Quit: leaving]
zpe has joined #ocaml
rgrinberg1 has joined #ocaml
zpe has quit [Remote host closed the connection]
dsheets has joined #ocaml
rgrinberg1 has quit [Ping timeout: 268 seconds]
empyrean has quit [Ping timeout: 250 seconds]
tane has joined #ocaml
luzie has quit [Read error: Connection reset by peer]
luzie has joined #ocaml
huza has quit [Quit: WeeChat 0.3.8]
pyon has joined #ocaml
ely-se has joined #ocaml
dsheets has quit [Ping timeout: 250 seconds]
pyon is now known as nyon
rgrinberg1 has joined #ocaml
rgrinberg1 has quit [Ping timeout: 240 seconds]
dsheets has joined #ocaml
shinnya has joined #ocaml
mort___ has left #ocaml [#ocaml]
rgrinberg1 has joined #ocaml
kushal has joined #ocaml
hcarty has quit [Quit: leaving]
hcarty has joined #ocaml
Simn has joined #ocaml
AltGr has joined #ocaml
ely-se has quit [Quit: leaving]
AltGr has left #ocaml [#ocaml]
hcarty has quit [Quit: WeeChat 1.3]
AltGr has joined #ocaml
aziem has joined #ocaml
antkong_ has joined #ocaml
marsam has joined #ocaml
ncthom91 has joined #ocaml
ncthom91 has quit [Max SendQ exceeded]
ncthom91 has joined #ocaml
ncthom91 has quit [Read error: Connection reset by peer]
madroach has quit [Ping timeout: 264 seconds]
ncthom91 has joined #ocaml
ncthom91 has quit [Read error: Connection reset by peer]
madroach has joined #ocaml
hannes` has joined #ocaml
hannes has quit [Read error: Connection reset by peer]
empyrean has joined #ocaml
thomasga has joined #ocaml
nyon has quit [Quit: nyan]
marsam has quit [Remote host closed the connection]
marsam has joined #ocaml
jeffmo has joined #ocaml
thomasga has quit [Quit: Leaving.]
<orbifx> freehck: have you not got a phone?
<orbifx> a mobile one
<orbifx> and if so, do you have a data plan?
<orbifx> or do they have a free wifi
<freehck> oh... :)
<freehck> orbifx: I've specifically not got a phone with a wifi module, we don't have a free wifi in the office.
<freehck> And I didn't understand the question about data plan.
thomasga has joined #ocaml
<orbifx> if your mobile can access to the internet
<orbifx> via the cell network
dsheets has quit [Ping timeout: 256 seconds]
<freehck> it can't
dexterph has quit [Quit: WeeChat 1.3]
dexterph has joined #ocaml
IbnFirnas is now known as rjp
rjp is now known as IbnFirnas
<orbifx> ok
<orbifx> you need some kind of tunnel then
MercurialAlchemi has joined #ocaml
<freehck> orbifx: I've prepared today a simple variant to connect my server via ssh. ssh-client -> cntlm -> sslh -> sshd
<freehck> I heared sslh could be used for proxying to openvpn so it's just a question of time to prepare a working variant.
AltGr has left #ocaml [#ocaml]
<orbifx> ok
<orbifx> not heard of those, but ssh can tunnel anything if recall
<freehck> orbifx: it's not a question of just tunelling. Packets must go to the port 443 in order to make Squid let them pass. For these purposes I need an SSL proxy (cntlm) to bind my local port to a remote 443, and will use an upper proxy for delivering packages.
<freehck> Then, I have an https in my website, so I should split https and ssh streams, that are going through 443 port on my remote server.
<freehck> For these purposes there's sslh multiplexor.
<freehck> Any questions? :)
<orbifx> if you have admin access to that server, or even just ssh access, you can just ssh tunnel
dsheets has joined #ocaml
<orbifx> let sophisticated and automated but less configuration too.
ygrek_ has joined #ocaml
<orbifx> heck you can run your favourite terminal irc client in a tmux session. You can be online forever!
zpe has joined #ocaml
enamex has joined #ocaml
<freehck> orbifx: okay, it could be said easier: I have no problems, I can solve anything myself. Let's fin the flood.
dsheets has quit [Ping timeout: 250 seconds]
zpe has quit [Ping timeout: 264 seconds]
stormogulen has joined #ocaml
slash^ has joined #ocaml
hcarty has joined #ocaml
toomuchtvrotsurb has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
Guest38 has joined #ocaml
stormogulen has quit [Remote host closed the connection]
stormogulen has joined #ocaml
orbifx has quit [Ping timeout: 256 seconds]
<toolslive> how do I debug an external (ppx based) preprocessor? (I get "external preprocessor does not produce a valid file")
palomer has joined #ocaml
oscar_toro has joined #ocaml
<dinosaure> toolslive: use -dsource option with ocamlc
<toolslive> that's exactly what I'm doing to get the error
<Drup> -dparsetree ?
toomuchtvrotsurb has quit [Remote host closed the connection]
johnf has joined #ocaml
<Drup> But, hum, who is the faulty ppx ? :]
<toolslive> it's one I'm developing
<Drup> I see
rgrinberg1 has quit [Ping timeout: 244 seconds]
<def`> Then just dump contents from your ppx
<Drup> then yes, -dparsetree is the way to go for debuging
<toolslive> so yes, I probably am doing something wrong ...
Stealth has left #ocaml ["Dont wait to die to find paradise..."]
<toolslive> something like this? ocamlc -dparsetree -ppx ./ppx_deser.native test.ml
rgrinberg1 has joined #ocaml
stormogulen has quit [Ping timeout: 256 seconds]
enamex has quit [Ping timeout: 265 seconds]
enamex has joined #ocaml
beginner has quit [Quit: Page closed]
toomuchtvrotsurb has joined #ocaml
^elyse^ has joined #ocaml
browncodes has joined #ocaml
enamex has quit [Ping timeout: 244 seconds]
rgrinberg1 has quit [Ping timeout: 250 seconds]
toomuchtvrotsurb has quit [Remote host closed the connection]
jwatzman|work has joined #ocaml
toomuchtvrotsurb has joined #ocaml
Haudegen has quit [Ping timeout: 268 seconds]
rgrinberg1 has joined #ocaml
<rgrinberg1> 1
^elyse^ has quit [Quit: food]
larhat1 has joined #ocaml
jonludlam has quit [Ping timeout: 264 seconds]
Haudegen has joined #ocaml
enamex has joined #ocaml
NoNNaN has left #ocaml ["PART ##fsharp :PING 1444237766"]
zpe has joined #ocaml
<companion_cube> 2
<companion_cube> I'm so in love with Format right now
<Drup> companion_cube: you finally converted yourself :D
<companion_cube> nah, I've been using it for years
<companion_cube> but I've just written a lot of pretty-printers, and they look nice without efforts
Tekilla has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
kushal has quit [Ping timeout: 268 seconds]
gobbledigook has joined #ocaml
octachron has quit [Quit: Leaving]
<gobbledigook> hi
<gobbledigook> I am new to Ocaml
<gobbledigook> I recently saw an example on pattern matching
<companion_cube> welcome then!
<gobbledigook> it was a basic "sum" function of all elements in a list
<gobbledigook> let rec sum l = match l with
<gobbledigook> [] -> 0
<gobbledigook> hd :: tl -> hd + sum tl;;
<gobbledigook> now what I'm curious is
<gobbledigook> what does the "::" do in "hd::tl"?
<companion_cube> it's the list constructor
<companion_cube> 1 :: l is 1 added to the front of l
<Denommus> gobbledigook: :: is the cons operator. The first parameter is an element. The second is a list of elements of the same type as the first parameter
<gobbledigook> ok
<gobbledigook> so help me understand what this function is doing
<gobbledigook> so the user inputs a list "l" in this function
<gobbledigook> if this list l is empty "[]" it returns 0
<companion_cube> yes
<companion_cube> otherwise, the list must be some hd :: tl
<gobbledigook> if not, then it appends the head of list "l" to what tail?
<companion_cube> no, hd :: tl -> ... is a pattern
<companion_cube> it deconstructs lists, rather than building them
<gobbledigook> so it takes list "l"
<gobbledigook> and separates its head
<Denommus> gobbledigook: if it's not empty, it takes the head of the list and adds it to sum tl
<gobbledigook> from the tail
<gobbledigook> ?
<Denommus> gobbledigook: for instance, if the list is [1, 2]
<companion_cube> and if l is hd :: tl then it follows the branch hd + sum tl
<gobbledigook> so say l = [1,2,3]
<Denommus> gobbledigook: it will match l. hd will be 1, tl will be 2
<gobbledigook> hd would be 1, tl would be 2, 3 right?
<Denommus> gobbledigook: so the second case returns 1 + sum [2]
<gobbledigook> ah ok
<gobbledigook> oh
<gobbledigook> so hd::tl just checks if argument "l" is of that pattern
<Denommus> gobbledigook: [2] would then be matched. hd would be 2 and tl [], so sum [2] is 2 + sum []
<companion_cube> gobbledigook: exactly
<Denommus> gobbledigook: sum [] is 0 (because of the first case)
<gobbledigook> now I have another question
<gobbledigook> why not use if else?
<companion_cube> and it bings "hd" and "tl" if l is indeed a cons
<companion_cube> gobbledigook: pattern matching is strictly better
<Denommus> gobbledigook: because this way the code is cleaner
<companion_cube> you can only speak about hd or tl if the list is in the case ::
<Denommus> gobbledigook: and also easier to read, once you're used to it
<gobbledigook> kk
<gobbledigook> thank you all
<companion_cube> in C you could write if (list == null) { .... list -> next }
<companion_cube> and fail miserably
<companion_cube> here, you can only access hd and tl if l is not empty
ggole has quit []
<gobbledigook> kk
<Denommus> gobbledigook: sorry, I said "tl will be 2" up there, but I meant "tl will be [2]"
<gobbledigook> btw, can you use match statement on 2 arguments?
<gobbledigook> say sum takes in 2 lists
<Denommus> gobbledigook: you can use a tuple for that
<Denommus> gobbledigook: like match (foo, bar) with ([], []) -> ...
^elyse^ has joined #ocaml
<gobbledigook> I see
<companion_cube> yes, it's very useful
<Denommus> gobbledigook: it's technically a single tuple argument that you're matching out. Nevertheless, it's a common idiom
<gobbledigook> would that be the only way to get around pattern matching more than 1 argument?
<companion_cube> you can also pattern match deep in a structure
kushal has joined #ocaml
antkong_ has quit [Quit: antkong_]
<Denommus> gobbledigook: well, you can make a match inside the other, but the tuple solution is often what you need
<gobbledigook> match inside the other?
<Denommus> gobbledigook: yes, just like you could have an if inside the other
<gobbledigook> so would that look something like (say we're trying to add elements of 2 lists)
<gobbledigook> let rec sum a b = match a with
<gobbledigook> [] -> 0
<gobbledigook> hd::tl -> match b with
<gobbledigook> [] -> 0
<gobbledigook> etc?
darkf has quit [Quit: Leaving]
<Denommus> gobbledigook: you could do that, but it would be far more verbose, complex, and harder to read
<companion_cube> this kind of thing is nice
<gobbledigook> companion_cube what exactly is going on in [], _::_ | _::_,[] -> "Not same length"
<companion_cube> so I wrote a small function that sums lists pairwise
<companion_cube> this is the case where the lists do not have the same length
<companion_cube> _::_ is like matching hd::tl but doesn't give names to head and tail
<gobbledigook> so you are checking cases if a or b is the empty set
<gobbledigook> and the other isn't?
<Denommus> gobbledigook: _::_ is just matching the head and tail of a list, but not holding the values in a variable
<companion_cube> gobbledigook: empty list, not empty set
<companion_cube> lists are not sets
<gobbledigook> empty list sorry
<gobbledigook> and at the end
<Denommus> gobbledigook: _ is like a "hole" in the matching. You're telling the match engine that it's important for the list to have that "format", but you don't care about whatever's inside
<gobbledigook> so does that mean in my original "sum" function
<gobbledigook> I could've replaced hd::tl -> hd + sum tl
<gobbledigook> with any other name for hd and tl?
<Denommus> gobbledigook: yes. Those are variables
<gobbledigook> like hi::bob -> hi + sum bob
<gobbledigook> ah
<gobbledigook> also the last line of that program
<gobbledigook> x :: a', y :: b'
<gobbledigook> sorry for all these questions
<companion_cube> no problem
<gobbledigook> what is the ' used for?
<companion_cube> it's just a name
<companion_cube> in OCaml, a' is a valid name for a variable
jonludlam has joined #ocaml
<Denommus> gobbledigook: nothing
<Denommus> gobbledigook: ' can be used in identifiers as long as it's not the first character
<gobbledigook> so in x :: a' we are appending an uninitialized variable x to uninitialized variable a'
<gobbledigook> same with y and b'?
enamex has quit [Ping timeout: 244 seconds]
<companion_cube> it's not uninitialized variables
<companion_cube> x is the head of the first list, a' its tail
<Denommus> gobbledigook: there are no unitialized variables in OCaml
<companion_cube> and same for y and b'
<gobbledigook> oh wait
<gobbledigook> I am stupid
<thizanne> you're not « appending something to an uninitialised variable », you're saying « then if it's not empty, my list is built by appending an head to a tail, let's name the head x and the tail a' »
<companion_cube> no you're not
<Denommus> gobbledigook: don't worry, getting your head around pattern matching takes some time for most people
<gobbledigook> and x + y :: sum a' b' ?
<companion_cube> it builds a new list
<gobbledigook> you add the heads of list a and b
<companion_cube> with head x+y, and tail sum a' b'
<companion_cube> yes
<gobbledigook> ah
<companion_cube> sum [1;2] [3;4] will return [4;6]
mort___ has joined #ocaml
<gobbledigook> alright
<gobbledigook> so the cons operator is used only with lists then?
mort___ has quit [Client Quit]
<companion_cube> yes, :: is for lists only
<companion_cube> but pattern matching works with many many types
<gobbledigook> is _::_::_ valid?
<companion_cube> yes
<gobbledigook> for head, head-1, and tail?
<Denommus> gobbledigook: sure
<companion_cube> it is the same as _ :: (_ :: _)
<companion_cube> that's one example of deep pattern matching
<Denommus> you could do something like _::snd::_ to take the second element of a list, for instance
<gobbledigook> I see
<gobbledigook> well that's all the questions I have for now
<gobbledigook> I am currently trying to write a ocaml program for testing if a list a is a subset of list b
<gobbledigook> if I have any more questions I'll be sure to come back here
<gobbledigook> thanks guys
<Denommus> good luck
<companion_cube> gobbledigook: also, ocaml.org has many useful stuff for beginners
kushal has quit [Remote host closed the connection]
Kakadu has quit [Quit: Page closed]
Bluddy has joined #ocaml
<gobbledigook> so here was my first go at it
<gobbledigook> let rec subset a b = match a, b with
<gobbledigook> | [], _::_ -> true
<gobbledigook> | _::_, [] -> false
<gobbledigook> | ah::at, bh::bt -> if ah (==) bh
<gobbledigook> then subset at, b
<gobbledigook> else subset a, bt;;
<gobbledigook> but I have an error at line 5
<gobbledigook> "This expression has type 'a * 'b but an expression was expected of type bool
<Denommus> gobbledigook: please, start using a paste site
<gobbledigook> sorry
<Denommus> gobbledigook: anyway, the problem is that you want if ah = bh
<gobbledigook> yes
<gobbledigook> this is to check of list "a" is a subset of list "b"
<Denommus> gobbledigook: OCaml uses = for both comparison and assignment
<Denommus> gobbledigook: ah, no, sorry, that's not the problem
<Denommus> gobbledigook: the problem is that you want subset at b
<Denommus> gobbledigook: not subset at, b
<gobbledigook> oh woops
<Denommus> gobbledigook: the same in else
octachron has joined #ocaml
<Denommus> gobbledigook: you also forgot to match ([],[])
<gobbledigook> oh that is right
<Denommus> gobbledigook: the first case can be replaced by ([], _) -> true
<Denommus> gobbledigook: because it doesn't matter whether the second list is empty or not. If the first list is empty, it's a subset of the second
<gobbledigook> yeah
<gobbledigook> and that would also cover ([], []) case
<Denommus> yup
<gobbledigook> argh
<gobbledigook> I'm not getting any errors on compiling but when I try to run the program
<gobbledigook> subset [1;2] [1;2;3]
<gobbledigook> ;;
<gobbledigook> Error: This expression has type int but an expression was expected of type
<gobbledigook> ('a -> 'a -> bool) -> 'b -> bool
<Denommus> gobbledigook: check the type for subset
<gobbledigook> check the type?
johnf has quit [Read error: Connection reset by peer]
<Denommus> gobbledigook: subset;;
<gobbledigook> (('a -> 'a -> bool) -> 'b -> bool) list -> 'b list -> bool = <fun>
<Denommus> there's something wrong, then XD
<Denommus> gobbledigook: it should be 'a list -> 'a list -> bool
<gobbledigook> I don't understand how this got so convoluted
<gobbledigook> yes
<Denommus> gobbledigook: the problem is probably on your if
<gobbledigook> should I bracket it?
<gobbledigook> [ah] (==) [bh]?
<Denommus> gobbledigook: no
<Denommus> gobbledigook: as I said, it should be ah = bh
<Denommus> gobbledigook: OCaml uses = for both assignment and comparison
<Denommus> gobbledigook: (it's confusing, I know)
<gobbledigook> so in an if statement it would infer that = is comparison
<gobbledigook> whereas in another setting it would infer that = is assignment?
<Denommus> gobbledigook: == also works, it seems
<Denommus> I didn't
<Denommus> know
f[x] has joined #ocaml
<octachron> (==) is physical equality, the fact that it works the same as (=) for int is "accidental"
<gobbledigook> changing the comparison operator is giving me compilation errors now
<gobbledigook> hm
<dmbaturin> Denommus: It doesn't use = for _assignment_. Binding is not assignment. ;)
sepp2k has quit [Quit: Leaving.]
ygrek_ has quit [Ping timeout: 244 seconds]
<dmbaturin> gobbledigook: In the "let <pattern> = <expr> [in <expr>]" form, = is interpreted as part of the binding syntax. Anywhere else it's interpreted as an operator.
enamex has joined #ocaml
<dmbaturin> let foo = 4 = 5 (* binds foo to false *)
<enjolras_> ocaml doesn't use = for asignment
<gobbledigook> thanks dmbaturin
<enjolras_> it uses either := or <- depending on the kind of assignment
<palomer> hey guys
<palomer> is Marshal cross platform?
<enjolras_> forget about marshal and you will be ok
<palomer> :D
<palomer> I should switch to binio?
<gobbledigook> oh my goodness all I want to do in life is just check if these two values are equal
<enjolras_> it depends on the compiler version, so even if it is cross platorm it's not really robust
t4nk972 has joined #ocaml
<t4nk972> guys I need some help
<dmbaturin> gobbledigook: Then use "<val1> = <val2>". :)
<enjolras_> palomer: whatever serialization format you want, anything is fine, json, binio, whatever
thomasga has quit [Quit: Leaving.]
<gobbledigook> dmbaturin within the <> brackets?
f[x] has quit [Ping timeout: 252 seconds]
t4nk972 has quit [Client Quit]
schoppenhauer has quit [Ping timeout: 264 seconds]
<dmbaturin> gobbledigook: No, the brackets are just a BNF-like notation. "if ah = bh then ...".
taigi100 has joined #ocaml
<taigi100> guys
<enjolras_> t4nk972: on irc, it's usually better to ask a question instead of asking whether you can ask
<gobbledigook> I've tried ah = bh and I'm getting compilations errors
<gobbledigook> same with ah == bh
<enjolras_> gobbledigook: show the code, it's probably unrelated
<taigi100> I've put the SO link so I don't fill up the chat in here :) if anyone could help it would be amazing
<gobbledigook> Enjolras_ http://paste.isomorphis.me/WkX
<taigi100> This is the latest version I got to : http://paste.isomorphis.me/qHG
<taigi100> Basically I'm trying to compute fib n, using a recursive function that takes the last 2 fib's terms ( bottom-up recursion )
<enjolras_> gobbledigook: it looks ok
mort___ has joined #ocaml
<enjolras_> it choud compile and typecheck
<gobbledigook> but it's not compiling
<enjolras_> uh ?
<dmbaturin> gobbledigook: That code looks fine. What is the error?
<enjolras_> you should get a function of type 'a list -> 'a list -> bool
<gobbledigook> oh wait
<dmbaturin> taigi100: Ok, now describe the problem. :)
<gobbledigook> are you kidding me
<gobbledigook> nevermind
<enjolras_> taigi100: your fib function takes "two" argyuments, a and b and you only apply it to n
<enjolras_> taigi100: so the application is partial and you get a function
<palomer> anyone here tried ppx_deriving with yojson?
<enjolras_> of course. There is also atdgen you might be interested on
schoppenhauer has joined #ocaml
<dmbaturin> taigi100: But yeah, careful with shadowing. The fib in the result = fib n expression is the inner fib.
<dmbaturin> palomer: I did.
<taigi100> I'm a little bit lost, first time doing OCaml programming
<taigi100> How should I go about doing what I'm trying to?
* enjolras_ doesn't remember how to compute fibonacci
<taigi100> I wanna call a function fib(n) yet inside I wanna use a different function with 2 arguments that actually calculates it
antkong_ has joined #ocaml
<dmbaturin> taigi100: To avoid confusion it's better to name the inner auxillary function something else, e.g. fib'
<palomer> dmbaturin: I’m getting the error Cannot locate deriver yojson even though I’m compiling with -pkg ppx_deriving.std
<palomer> dmbaturin: did you ever run into this problem?
<enjolras_> i think what you want is remove the a = 0 and b = 1
<enjolras_> and just call fib 0 1
<enjolras_> instead of fib n
<enjolras_> and you can remove the "let result =" you want to return the value, not bind the value to a name
<palomer> I usually call my simple inner functions ‘doit'
<Denommus> dmbaturin: sorry, messed up XD
<enjolras_> or "aux" or "loop"
<taigi100> tried this, tells me unbound value result at the result line
<dmbaturin> palomer: Do you also compile with '-package ppx_deriving_yojson'?
<palomer> ahh, that’s what’s missing :D
<Johann> taigi100: in let result =
<octachron> taigi100, what is the last line trying to do? (hint, = is not for assignment )
enamex has quit [Ping timeout: 246 seconds]
<dmbaturin> palomer: You also need to link programs with ppx_deriving_yojson.runtime
<taigi100> oh yeah, missed the let, but if I do put the let then it gives me a syntax error
gobbledigook has quit [K-Lined]
<enjolras_> this is a working version of you code. Not sure it actuaklly computes fibonacci, but it does what youwant
<dmbaturin> I never thought you can get K-lined for confusing (==) with (=).
mort___ has left #ocaml [#ocaml]
<palomer> dmbaturin: ocamlbuild doesn’t just handle that?
<dmbaturin> palomer: Probably not, I had to add it to BuildDepends: in my _oasis. You can try though.
<taigi100> <Enjolras_> If I call fib (ref 1) why does it give me 0 instead of 1 ?
<taigi100> and why does it take a reference ? isn't n a constant?
<enjolras_> well, that's an algorithmic error.Again, i do'nt remember fibonacci sequence, i've just fixed the code to be actual ocaml
<enjolras_> the code i paste has type int -> int
<enjolras_> it doesn't take a reference. You are probably missing the ! before counter
Haudegen has quit [Ping timeout: 246 seconds]
<enjolras_> if you don't put !, it will infer that n is an int ref from the comparaison in the if condition
hcarty1 has joined #ocaml
<taigi100> got it :)
hcarty has quit [Ping timeout: 246 seconds]
<taigi100> now if you don't mind explaining, my fib (n) function takes the value of the last expresion right?
Kakadu has joined #ocaml
<palomer> if I try to run an ocaml program from GNU screen I get a core dump :(
Haudegen has joined #ocaml
orbifx has joined #ocaml
<taigi100> I've implemented the same algorithm in C++ also, for some reason the results aren't the same. When I call fib 1 in C++ I get 1 ( the right result ) but in OCaml I get 2 for some reason...
bjorkintosh has quit [Quit: Leaving]
<palomer> fib a a+b -> fib a (a+b)
<companion_cube> maybe you start at -1 instead of 0
<flux> int cnt = -1,n; wot :)
<taigi100> yep , the brakets saved it :)
<palomer> anyone here ever try running an ocaml program in gnu screen or tmux?
<taigi100> Thnx a lot guys!
<adrien> palomer: all of the time
<palomer> adrien: do you ever get a core dump?
<adrien> never
<adrien> or I wouldn't be doing it all of the time
<flux> I sometimes run ocaml programs under screen, but I have never seen a coredump from that
<palomer> hrmph, I’ll keep investigating
gobbledigook has joined #ocaml
ousado_ has quit [Quit: --]
ousado_ has joined #ocaml
<palomer> https://www.google.ca/trends/explore#q=tmux%2C%20gnu%20screen <—looks like tmux is crushing gnu screen
<gobbledigook> in a list of just one element, can there be a head and a tail?
<adrien> yes, the tail will be the empty list
<gobbledigook> so [3] would be head = 3, tail = []?
<flux> palomer, screen just works, why would anyone google for it.. :)
<palomer> :D
<adrien> (and people don't search for "gnu screen" but only "screen")
BitPuffin has quit [Ping timeout: 250 seconds]
<adrien> gobbledigook: yes
<dmbaturin> gobbledigook: You should better avoid List.hd and List.tl and use pattern matching exclusively. However, yes, [_] is equivalent to _ :: []
<gobbledigook> kk
<dmbaturin> palomer: I've seen a number of people to migrate to or choose tmux over screen. Arguments against screen are often subjective though.
<palomer> does anyone here put expressions directly in a module instead of wrapping it in a let _ ?
rgrinberg1 has quit [Ping timeout: 250 seconds]
jonludlam has quit [Ping timeout: 246 seconds]
f[x] has joined #ocaml
Denommus has quit [Read error: Connection reset by peer]
xificurC has joined #ocaml
thomasga has joined #ocaml
jwatzman2 has joined #ocaml
Denommus has joined #ocaml
flx has quit [Read error: Connection reset by peer]
flxx has joined #ocaml
Muzer has quit [Ping timeout: 240 seconds]
xificurC_ has quit [Ping timeout: 240 seconds]
jwatzman|work has quit [Ping timeout: 240 seconds]
lobo has joined #ocaml
octachron has quit [Quit: Leaving]
toolslive has quit [Ping timeout: 252 seconds]
taigi100 has quit [Quit: Page closed]
bjorkintosh has joined #ocaml
Tekilla has quit [Quit: Quitte]
Muzer has joined #ocaml
<palomer> omg, I figured it out
<palomer> when I start tmux or screen I get a different CAML_LD_LIBRARY_PATH
<palomer> in my environment
sh0t has joined #ocaml
<gobbledigook> how do you have a default return statement?
<gobbledigook> just the value?
<gobbledigook> I have a function that checks elements of list a and sees if the element exists in list b
toolslive has joined #ocaml
<gobbledigook> if it goes through the entire loop I want it to return false
<gobbledigook> can I just do done -> false?
jwatzman2 is now known as jwatzman|work
jwatzman|work has quit [Changing host]
jwatzman|work has joined #ocaml
Algebr has joined #ocaml
jlouis has quit [Ping timeout: 240 seconds]
rgrinberg1 has joined #ocaml
jlouis has joined #ocaml
Denommus has quit [Remote host closed the connection]
<gobbledigook> anyone know how to make a default return statement?
<Kakadu> List.fold, gobbledigook
<gobbledigook> what does that do?
<Kakadu> folds list to single value
<gobbledigook> that's not what I want though
<gobbledigook> this is what I have so far
<gobbledigook> get_element_at is a self explanatory helper function that returns an element at index i in the supplied list
<gobbledigook> this doesn't work because I can't just have "false" out there
<Kakadu> why not List.nth?
<gobbledigook> sure I could use that, but that's not my question
<Algebr> what's the question, a default return?
<gobbledigook> yes
<gobbledigook> if it goes through the loop and cannot find a match
<gobbledigook> I want it to just return false
<Kakadu> I understand but in FP we write things like that not like in the imperative world. So you code is weird from the beginning
<gobbledigook> kakadu so I can't make a default return statement with Ocaml?
<Kakadu> I don't indestand the question. In OCaml last statement is return statement
<Algebr> This is odd code, probably just easier to do let value = ref false and then a while loop that upon a certain condition changes value := true
<Algebr> at the end just blind give back !value
thomasga has quit [Quit: Leaving.]
<Algebr> no statements, expressions
<Kakadu> gobbledigook: Also, List.mem can be useful
<gobbledigook> Algebr what is ref false?
<Algebr> holding a reference value, real mutation.
Haudegen has quit [Ping timeout: 240 seconds]
<gobbledigook> so you use ref _ if you want it to be mutable?
<Algebr> yes.
<Algebr> But its probably better to get into the "functional" way of doing things.
<gobbledigook> so then how would I go about this program the "functional" way?
<Algebr> the fold
<gobbledigook> how does fold help though?
<Algebr> starting value of false
<gobbledigook> but
<gobbledigook> okay
<orbifx> gobbledigook: considered using None and Some?
<gobbledigook> I'm making a function to test if list "a" is a subset of list "b"
<gobbledigook> I originally had something working, but realized it wouldn't work for cases like [3;1] to [1;3]
<gobbledigook> so I am rewriting it
<gobbledigook> I want to know how "fold" helps here
<gobbledigook> orbifx what is none and some?
<orbifx> Not looked at your code, but that's first thing that came to mind
<gobbledigook> orbifx http://paste.isomorphis.me/75c
<gobbledigook> woops
<gobbledigook> i = 0 to List.length b do*
<orbifx> gobbledigook: wait need to relog
orbifx has quit [Quit: AtomicIRC: The nuclear option.]
orbifx has joined #ocaml
<gobbledigook> should I resend?
<orbifx> gobbledigook: link again please
<orbifx> yeah
<orbifx> this is the functional way to "wrap" values that can basically not exist
<orbifx> ideally you should write a function that has a value for every possible input
<gobbledigook> so uh
<gobbledigook> I'm still at a loss as to how to include that
thomasga has joined #ocaml
<orbifx> if you really must have arguments for which values don't exist, this is one "option" ;)
<orbifx> wait you only need to return a bool, not the found number?
Haudegen has joined #ocaml
<gobbledigook> yes
<gobbledigook> only the bool
<gobbledigook> if it goes through the loop and it cannot find a match
<orbifx> ok ignore the option
<gobbledigook> it is done
<gobbledigook> and return false
<orbifx> the suggested way of using a fold is valid
<orbifx> what you do with that is fold all the bools returned from inspecting the elements
<orbifx> so fold is like an accumulator
<orbifx> and you have a list of bools by mapping a boolean check over the list values.
<orbifx> so if your default is false
<orbifx> you can do something like: fold_left (ah =) false List
<orbifx> this is pseudo code basically to give you an idea
<gobbledigook> is there any way to do this recursively?
<gobbledigook> actually?
<Algebr> A fold is an abstraction over recursion
<orbifx> yes gobbledigook
<orbifx> you should fold_left on the rest of the elements
palomer_ has joined #ocaml
<gobbledigook> okay
<gobbledigook> say I were to use fold
<gobbledigook> erm
palomer has quit [Ping timeout: 265 seconds]
palomer_ is now known as palomer
<orbifx> gobbledigook: try it in the interactive interpreter
<orbifx> you will get it
<gobbledigook> something like this...?
thomasga has quit [Quit: Leaving.]
freehck has quit [Ping timeout: 246 seconds]
johnelse has quit [Ping timeout: 240 seconds]
<orbifx> no need for `for` or then
<gobbledigook> so I remove the for loop
<gobbledigook> and I'm fine?
<orbifx> almost
<orbifx> you aren't trying it :P
johnelse has joined #ocaml
<gobbledigook> well, because my problem seems so simple to solve
<gobbledigook> and I don't see why we have to use fold_left for this
johnelse is now known as Guest41780
<orbifx> you should really read about fold, it is used for a lot of cases you would use loops in imperative functions
<orbifx> gobbledigook: I will show you one example i have recently written, sec
<orbifx> this is an older version of that file
<gobbledigook> okay wait
<gobbledigook> hold on
<gobbledigook> when exactly would you use fold left?
<toolslive> whenever you need to go over a list (or a monoid in general) producing a result
<orbifx> when you want to create an aggregate of a left associated function (others correct me if I am wrong here)
<orbifx> its `left` because of the way it will apply the recursion, it can otherwise be `right` where it applies the function from the right to left.
<gobbledigook> okay so I have this
<gobbledigook> compilation error
<orbifx> but the awesome thing with fold is that is means you don't have to write a loop or a recursion your self
Algebr has left #ocaml ["ERC (IRC client for Emacs 25.0.50.1)"]
<orbifx> you don't need then
Algebr has joined #ocaml
<gobbledigook> so then
<gobbledigook> how would I check if the other elements in list "a" are in list "b"?
<gobbledigook> also I keep getting unbound value fold_left
<orbifx> fold_left (||) (map (ah =) b)
<orbifx> you need to either `open` the module, or prepend the module's name to the function.
<orbifx> oops missed the default value
<orbifx> fold_left (||) false (map (ah =) b)
<orbifx> i thin that should work
<gobbledigook> what is (||)?
<orbifx> its the logical or
<gobbledigook> so I have this
<orbifx> i reckon you ned a space after fold_left
<gobbledigook> I have no errors there, so I think it's fine
<gobbledigook> however
<gobbledigook> (ah =) operator expected
gobbledigook has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<orbifx> ow I think in Ocaml you have to use ==
gobbledigook has joined #ocaml
<companion_cube> == is only for physical equality
<gobbledigook> woops
<gobbledigook> anyway who was I talking to?
<gobbledigook> (ah =) operator expected
<companion_cube> orbifx> ow I think in Ocaml you have to use ==
<orbifx> whats physical vs structural equality?
<companion_cube> well, physical equality is pointer equality
<companion_cube> (=) traverses structures to compare them
<orbifx> companion_cube: does he have to do ((=) ah) to partially apply it, or is (ah =) good enough?
<companion_cube> the first one
<orbifx> gobbledigook: you got that?
<gobbledigook> get what?
oscar_toro has left #ocaml [#ocaml]
<orbifx> inteast of (ah =) do ((=) ah)
rand__ has joined #ocaml
<gobbledigook> okay
<gobbledigook> now it's saying unbound value map
palomer has quit [Quit: palomer]
<companion_cube> List/map, maybe
<companion_cube> List.map sorry
<gobbledigook> okay
<gobbledigook> so it compiles
<gobbledigook> and it's not working as intended
<gobbledigook> this is what I have at the moment
<companion_cube> oh btw, List.exists might be what you want
<companion_cube> also, you forgot the recursive case
<gobbledigook> before all this advice I just want to let you know
<gobbledigook> I am trying to make a function that checks if a list "a" is a subset of list "b"
<gobbledigook> I had something working before, but realized it failed on certain cases
<gobbledigook> eg [1;3] and [3;1]
<orbifx> gobbledigook: use standard (or popular) libraries for this, unless it's some kind of homework
<zozozo> gobbledigook: subset including multiplicty ? i.e should [1;1;2] be a subset of [1;2] or not ?
<gobbledigook> this is actually a homework
<gobbledigook> I originally came here to see if there's any way I could do a default return value
<gobbledigook> but then people told me to use fold_left and all that jazz
<orbifx> gobbledigook: Yea, saw that, it's a valid comment
<gobbledigook> [1;1;2] would be a subset of [1;2]
<gobbledigook> zozozo
<orbifx> and you are going the wrong way about this.
<zozozo> ok
<companion_cube> gobbledigook: here you should use List.exists
<orbifx> you should really study the recommended approaches.
<zozozo> gobbledigook: i think the easiest way is to sort, eliminate duplicates, then the subset relation is a lot easier to check
jonludlam has joined #ocaml
<gobbledigook> what I had originally was take in two lists (a, b)
<gobbledigook> then for i=0 to list.length b do
<gobbledigook> if ah matches any element in list b
<gobbledigook> it recursively calls the subset function using the tail of "a" and all of list "b"
<gobbledigook> ah = list a's head
<zozozo> should work
<gobbledigook> it should
<gobbledigook> but I do not know how to return false
<gobbledigook> if it exits the loop
<gobbledigook> and does not find a match for ah
<zozozo> gobbledigook: could you paste the code ?
<zozozo> gobbledigook: ok, i'd say, do "if List.exists ((=) ah) b then subset at b else false"
<orbifx> the fold approach you had didn't work cause it only checks for the existense of the first element. Just so you know.
hcarty1 has quit [Ping timeout: 264 seconds]
<gobbledigook> zozozo I got an error saying "This expression "List.exists ((=) ah) b" has type 'a * 'b but an expression was expected of type bool"
gobbledigook has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
gobbledigook has joined #ocaml
gobbledigook has quit [Client Quit]
gobbledigook has joined #ocaml
<gobbledigook> zozozo lost connection
<zozozo> gobbledigook: that's a weird error
<zozozo> do you open an external library which could shadow the List module ?
<gobbledigook> huh?
<gobbledigook> I didn't open any external library
<zozozo> ok, that's strange
<zozozo> can you paste the whole code which throws the error ?
shinnya has quit [Ping timeout: 268 seconds]
enamex has joined #ocaml
<gobbledigook> oh my god
<gobbledigook> I am a moron
<gobbledigook> that comma though
<zozozo> ^^
<gobbledigook> yes!
<gobbledigook> it works
<gobbledigook> thank you everyone for your help
<gobbledigook> especially you zozozo
_andre has quit [Quit: leaving]
<zozozo> gobbledigook: anytime
gobbledigook has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
antkong_ has quit [Quit: antkong_]
thomasga has joined #ocaml
<orbifx> zozozo: you realise that was his homework? :P
<zozozo> yeah i feel a bit bad about giving him the solution rather than helping him find it, :p
<zozozo> well, i still think sorting before would have been a better solution (better complexity in theory)
mv has joined #ocaml
<orbifx> probably
<orbifx> but when i figured out it was his homework and he wasn't investigating I gave up
<zozozo> ah, didn't have enough time to backlog
<zozozo> saw that it was some kind of homework, but thought that was a subgoal, or intermediate question rather then the goal of the exercise
MercurialAlchemi has quit [Ping timeout: 244 seconds]
<orbifx> it's alright
<orbifx> you didn't do much wrong
<orbifx> his fault
<orbifx> who knows, maybe he will like ocaml in the end
mv has quit [Remote host closed the connection]
<zozozo> would be nice
<orbifx> :P
tane has quit [Quit: Verlassend]
<zozozo> I realize that now that I know how to code in caml, I have trouble understanding people who have simple problems (such as code that does not typecheck), :(
<zozozo> i should work on that
<companion_cube> :)
<orbifx> functions programming requires a grasp of it's fundamentals, it's a paradigm shift.
<orbifx> it's subtle there is actually a leap in the thinking in there.
<orbifx> When i first started with Haskell, I though i got it till I reached some problems.
<orbifx> Which revealed the leap.
<orbifx> Now I still think I got it, till I reach the next problem :P
<orbifx> hahaha
<zozozo> ^^
<orbifx> but I would say Ocaml is more straight forward than Haskell.
<zozozo> I should take a look at haskell some day
gobbledigook has joined #ocaml
yomimono has quit [Ping timeout: 265 seconds]
<Drup> zozozo: it's not difficult if you have a good grasp of OCaml
<Drup> you get annoyed by things, though
<orbifx> zozozo: I would agree with Drup
<Drup> What you really have to learn is, as usual, the ecosystem
<orbifx> I really like the idea of Haskell and what they are after. But seems GHC needs to get to version 10 before the calm down a bit :P
<zozozo> is there a haskell for ocaml programmer tuto somewhere ?
<Drup> yeah
<zozozo> :o
<Drup> ah, non, wrong one
hannes` is now known as hannes
<orbifx> zozozo: GHC is 700 MiB last I checked
<orbifx> that on its own was annoying
<orbifx> and also the tools for working with ARM are not there yet.
<orbifx> which was bad in my case.
<zozozo> orbifx: yeah I remember that ghc is a monster from my time using xmonad
<Drup> I google "Haskell for the OCaml programmer"
<Drup> I open the first pdf
browncodes has quit [Remote host closed the connection]
<Drup> "There are two set of important features found in Haskell and not in OCaml: killer features and
<Drup> acquired tastes."
<Drup> First item in killer features: "indentation based language"
<companion_cube> olol
<Drup> Well, we can close that now.
<companion_cube> next incoming killer feature: strict types
<Drup> zozozo: I think I would just advise http://dev.stephendiehl.com/hask/
<Drup> instead of anything "for OCaml programmers"
browncodes has joined #ocaml
<zozozo> Drup: thx, I will try and read that soon
jwatzman|work has quit [Read error: Connection reset by peer]
jwatzman|work has joined #ocaml
Simn has quit [Quit: Leaving]
sh0t has quit [Ping timeout: 244 seconds]
<orbifx> i still use xmonad, but.... but..
<orbifx> it's like it's a lab language
<orbifx> anyway, time for Matrix
<orbifx> catch you later
orbifx has quit [Quit: WeeChat 1.3]
Algebr has quit [Remote host closed the connection]
^elyse^ has quit [Quit: Leaving]
f[x] has quit [Ping timeout: 265 seconds]
palomer has joined #ocaml
palomer has quit [Client Quit]
Haudegen has quit [Ping timeout: 256 seconds]
jonludlam has quit [Ping timeout: 250 seconds]
__uu___ has quit [Remote host closed the connection]
lobo has quit [Quit: leaving]
c74d3a has quit [Ping timeout: 252 seconds]
antkong has joined #ocaml
sgnb` has quit [Read error: Connection reset by peer]
sgnb` has joined #ocaml
jonludlam has joined #ocaml
marsam has quit [Ping timeout: 240 seconds]
mac10688 has joined #ocaml
gobbledigook has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
Haudegen has joined #ocaml
contempt has quit [Ping timeout: 264 seconds]
thomasga has quit [Quit: Leaving.]
jwatzman|work has quit [Ping timeout: 264 seconds]
enamex has quit [Ping timeout: 255 seconds]
thomasga has joined #ocaml
thomasga has quit [Client Quit]
mort___ has joined #ocaml
jonludlam has quit [Ping timeout: 255 seconds]
mort___ has quit [Client Quit]
rand__ has quit [Quit: leaving]
f[x] has joined #ocaml
obadz has quit [Ping timeout: 244 seconds]
empyrean has quit [Remote host closed the connection]
obadz has joined #ocaml
jwatzman|work has joined #ocaml
Guest38 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jwatzman|work has quit [Read error: Connection reset by peer]
palomer has joined #ocaml
palomer has quit [Quit: palomer]
jeffmo has quit [Ping timeout: 246 seconds]
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
echo-area has quit [Remote host closed the connection]
Kakadu has quit [Remote host closed the connection]
shinnya has joined #ocaml
jeffmo has joined #ocaml