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_>
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
<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
<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
<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 ?