Kevin_ has quit [Remote host closed the connection]
lopex has quit []
wtetzner has quit [Remote host closed the connection]
dnolen has joined #ocaml
everyonemines has joined #ocaml
mjonsson has quit [Remote host closed the connection]
dnolen has quit [Quit: dnolen]
Skolem has joined #ocaml
<Skolem>
I expect this (let p = 8 in match 8 with p -> 0 | _ -> 1) to evaluate to 1, but instead I get two warnings: "unused variable p", and "this match case is unused". I don't understand why p is unused. What am I missing?
thelema_ has joined #ocaml
thelema has quit [Read error: Connection reset by peer]
Skolem has quit [Quit: Connection reset by pear]
Tobu has quit [Read error: Operation timed out]
Tobu has joined #ocaml
<everyonemines>
you're not using p
<everyonemines>
let p = 8 in match p with p -> 0 | _ -> 1
<everyonemines>
now you get an unused match case warning because everything matches to 0
<everyonemines>
oh i see what you're going for
<everyonemines>
i don't think you should use a constant in matching like that
<everyonemines>
you're supposed to go 8 -> 0
<everyonemines>
i'm probably not the person to ask actually
<everyonemines>
ok you have a variable scope problem but I forget the correct way to do that
wtetzner has joined #ocaml
<everyonemines>
You're binding p as a variable to be used in the match result. That overwrites the existing p.
<everyonemines>
Personally I've always just used if statements for things like that.
<everyonemines>
I think the solution might involve X as Y.
surikator has quit [Quit: Computer is sleeping. I'm probably not.]
Skolem has joined #ocaml
<everyonemines>
Skolem: You're binding p as a variable to be used in the match result. That overwrites the existing p.
<everyonemines>
Use an if statement, I think.
<Skolem>
Hmm, what I actually want to do is check an integer k against some predefined values. Like, if k = a * b, then return 0, if k = a + b, then return 1, if k = something else, return 2, etc. It seems like pattern matching is ideal here,though I suppose I could use nested if/then/elses.
<Skolem>
so, suppose a and b are in scope. How should I write that? I was trying to do: let p = a * b in match k with p -> 0 | _ -> 1;;
<everyonemines>
That's not what match is for. It's more for variant types.
<everyonemines>
imo
<Skolem>
I see what you mean -it's not for comparing one value against a bunch of different constants. It's for seeing what type a value is.
<everyonemines>
Documentation uses it like a switch statement, because that's simpler. Would that really be better than if then else if, though?
<Skolem>
He follows it up with an example that uses a "case" statement, which may be what I want here.
<everyonemines>
ah, well I don't see the point of that, but that's different
<everyonemines>
let x = 5 in let p=8 in match (p=x) with true -> 0 | false -> 1;;
<everyonemines>
see?
<everyonemines>
"It encourages students to think in terms of pattern matching, and prepares the ground for later developments"
<everyonemines>
what a BS reason
<Skolem>
Heh, OK, I'm very new to this, so I'm probably more liable to go in the wrong direction.
<everyonemines>
Matching can also be used to break stuff like pairs up into variables.
<everyonemines>
What are you trying to do with ocaml? just learn it in general?
<Skolem>
He follows up his diatribe with example code that doesn't even seem to be legal OCaml: "case Int.compare(x,y) of LESS => ... | GREATER => ... | EQUAL => ..."
<Skolem>
Even if I replace the ... with integers, it doesn't compile.
<Skolem>
Yeah, just learn it in general. I know Perl and C pretty well, but I want ocaml to be my main programming language.
<everyonemines>
compare outputs an integer
<Skolem>
OK, but I can't find any exampes where case foo of bar compiles.
<everyonemines>
let f x y = match (compare x y) with -1 -> 5 | 1 -> 4 | 0 -> 3;;
<everyonemines>
I don't feel like reading that.
<Skolem>
Oh, I see. He meant to use a match. FWIW, when I type Int.compare(2,3);; from the top-leve, I get "Error: Unbound module Int". I can't seem to fix this, and googling for the error isn't helpful.
<everyonemines>
if you want to learn ocaml
<everyonemines>
stop reading that stuff, open up the libref, and code something
<everyonemines>
What attracted you to ocaml, btw?
<Skolem>
Well, I've actually reached the point where I'm trying to code everything in Ocaml, and not letting myself use another language that I already know.
<Skolem>
But I get hung up on the stupidest things.
<everyonemines>
I think 'case' is from SML not ocaml.
<Skolem>
I liked that Ocaml did well on the programming language shootout, and it seemed to be pretty straightforward, and i've heard it has a solid mathematical foundation (which I don't yet understand). I've also heard that if you use it right it can be unusually good at helping you catch errors in the compilation phase.
<everyonemines>
"heard" where?
<everyonemines>
I was attracted by it being compiled and interpreted, and as fast as C++, and having some libraries.
<Skolem>
"heard" = read on some crazy blog, the url of which escapes me. :)
<Skolem>
Those sound like solid reasons.
<everyonemines>
The type system can be a real pain though.
<everyonemines>
eg different functions for arrays vs bigarrays
<Skolem>
Do you know if there's a ready-made way to run Ocaml "scripts" by putting "#!/usr/bin/ocamlscript" (or whatever) at the top of the file, similarly to how executable Perl scripts are formatted?
<everyonemines>
well there's ocamlscript :-)
<everyonemines>
haven't used it myself tho
<everyonemines>
because you can just compile them, it's not really a problem
<Skolem>
Ha, I didn't know that existed. Awesome!
<Skolem>
Well, one problem I have with ocamlopt is it leaves all these intermediate files laying around.
<Skolem>
gcc -o foo foo.c just creates 'foo' and nothing else.
<Skolem>
ocamlopt pollutes my directory with something approximately like foo.mli, foo.mlx, foo.o, etc.
<everyonemines>
Just put stuff in a folder.
<everyonemines>
...or use ocamlscript I guess
<Skolem>
Good point. It's annoying, though. gcc also has to create intermediate files, it just cleans up after itself unless you specifically tell them to leave them around.
<everyonemines>
have you checked ocamlopt docs?
<Skolem>
I checked ocamlopt -h, and didn't see anything relevant, but I haven't read the manual yet.
<everyonemines>
What kind of programming do you tend to do?
ulfdoz has joined #ocaml
<Skolem>
Scheduling stuff, for one thing. And I wrote a program that won the 2010 World Game of Sprouts Association Tournament. How about you?
<everyonemines>
system and numerical
<Skolem>
Do you use F# at all?
<everyonemines>
I use OS X so no.
<Skolem>
OK, me too. Man, I've found the macport ocaml packages to be consistently broken.
<Skolem>
So I installed GODI and haven't looked back.
struktured has joined #ocaml
dgbaley27 has joined #ocaml
<dgbaley27>
I'm having trouble with something simple: let x = 1; while x < 10 do let x = x + 1 done. I'm getting an error on the "done"
<everyonemines>
you can't do that.
<everyonemines>
let x = ref 1 in while (!x < 10) do x := !x + 1; done
<dgbaley27>
I can't use references. Do I need to do a anonymous recursive function?
<everyonemines>
Why can't you use refs?
<dgbaley27>
This is schoolwork. The class is not about ocaml but it's the implementation language for the assignment. We were told not to use references.
<flux>
dgbaley27, in that case I'm pretty sure you've been told about recursion :)
<flux>
I guess you would need an unfold function, but ocaml doesn't come with one
<flux>
skolem, ocamlbuild solves the intermediate file problem by putting them into _build
<Skolem>
flux, cool! installing w/godi now.
<Skolem>
flux, do you have any insight into what is the right way to do this: let foo a b c = match c with a * b -> 1 | a + b -> 2 | a - b -> 3 | _ -> 4;; ?
<Skolem>
I'm trying to see if c is the product, sum, or difference of a & b
<everyonemines>
Use if else.
<Skolem>
for one thing, it's not very DRY in that you have to repeat c in each expression
<Skolem>
if c = a * b then ... else if c == a + b then ... etc
<everyonemines>
I don't think that's what DRY is about.
<Skolem>
It's about not repeating yourself.
<everyonemines>
You can compare it against a list if you want.
<everyonemines>
If you have like a million things.
bobry has quit [Quit: Leaving.]
<flux>
skolem, well, you can do this: let eval a b c binop = binop a b = c in List.filter (binop a b c) [( * ); ( + ); ( - )] or something similar
<Skolem>
I'm actually a fairly fast reader, but, uh, damn, yeah that text goes by quick.
<Skolem>
oops
<flux>
batteries' filter_map or findi might be more suitable
<Skolem>
flux, whoa, that's awesome.
<Skolem>
Now that's what I call dry.
<flux>
(actually most of that was superfluous, because you already had a b c in the scope, so you don't need to pass them as parameters)
<flux>
also the code was wrong :) it was suppsoed to call eval, not binop
<flux>
(which didn't exist at that point)
<everyonemines>
filtermap is different though, it returns stuff your condition is true for
<flux>
everyonemines, yes, I was thinking the list would be something like [( * ), 1; ( + ), 2; .. ] to have the original meaning
<Skolem>
Yeah, I get the overall picture though, using List.filter and the form of ( * ), ( + ) that lets them be passed as functions.
<flux>
so you would return Some n when it maches. but findi perhaps is better.
<flux>
I think it's unlikely the real code would return list indices, though, because in my opinion that's quite a rare operation in ocaml
<everyonemines>
well, I like to write fortran style ocaml
<Skolem>
Yes, 1,2,3 were placeholders.
<everyonemines>
and it works fine
<flux>
but, time to make some breakfast
Skolem has quit [Quit: Connection reset by pear]
Skolem has joined #ocaml
junsuijin has quit [Quit: Leaving.]
dnolen has joined #ocaml
dnolen has quit [Client Quit]
ulfdoz has quit [Ping timeout: 260 seconds]
dgbaley27 has left #ocaml []
Skolem has quit [Ping timeout: 260 seconds]
Skolem has joined #ocaml
ttamttam has joined #ocaml
ttamttam has left #ocaml []
everyonemines has left #ocaml []
edwin has joined #ocaml
clog has joined #ocaml
<adrien>
couldn't find anything that suited my needs; "dump" modules don't support reading back and most of the (de)serializers use camlp4
<adrien>
although biniou/atd-gen/json* from Martin Jambon could do what I need
jaar has joined #ocaml
larhat has quit [Quit: Leaving.]
larhat has joined #ocaml
edwin has joined #ocaml
bacam has joined #ocaml
wishi has joined #ocaml
<adrien>
hmmm, atd depends on menhir
ikaros has joined #ocaml
<flux>
adrien, howabout piqi.org?
<adrien>
it's using camlp4 somewhere in the source
<flux>
so, camlp4&windows is a no-go?
<adrien>
last-time I tried it, it was and since I'm very time-constrained this time, I'm avoiding it
<adrien>
actually, right now, I only have ints to store, and only a few, so I could even do it by hand myself and that's what I'd do rather than trying with camlp4 this time
<adrien>
actually, I think that even for yypkg (so ocaml 3.11), I had issues for camlp4 (sexplib)
<adrien>
and if I can use atd and yojson and they don't use camlp4, I'll use that in yypkg
<adrien>
(currently I preprocess everything on linux, commit that to a branch, and download a tarball of that branch from gitweb)
<adrien>
hmmm, make yields lots of unix erros trying to open /tmp/ocamldep.wrapper.lock; I'll probably blame it on msys
<adrien>
(make for menhir)
larhat has left #ocaml []
larhat has joined #ocaml
<raphael-p>
adrien: isn't it possible to devellop in a linux vm and execute outside in your windows box?
<raphael-p>
of course, if you have tight time constraints it might not be possible…
<adrien>
now, it's completely impossible; I have a few hours left
<adrien>
the next approach I'll use is probably going to be linux+wine
<adrien>
and I think that currently, menhir won't build because of msys
Obfuscate has joined #ocaml
<adrien>
writing a bunch of ints by myself is actually almost as bad as using Marshal and I'll have to use a separate filename anyway to avoid future issues so I'll probably go with Marshal for today
HoraseLunums has joined #ocaml
<f[x]>
mfp, regarding extprot, is it possible to specify default values for new record fields so that extending messages is backward-compatible?
<f[x]>
looks like not possible currently, but could be added, at least for primitive types.. what do you think?
as has quit [Quit: leaving]
as has joined #ocaml
HoraseLunums has quit [Remote host closed the connection]
lopex has joined #ocaml
surikator has joined #ocaml
surikator has quit [Client Quit]
surikator has joined #ocaml
<mfp>
f[x]: yes, that'd be possible, but I try to avoid modifying the code generator, so I tend to use option types ;-)
avsm has joined #ocaml
avsm has quit [Quit: Leaving.]
Kakadu has quit [Ping timeout: 252 seconds]
_andre has joined #ocaml
<f[x]>
will you accept the patch if I ever endeavour to do it?
<f[x]>
mfp, ^^
<mfp>
sure, as long as the MIT license is OK for you :)
<ttamttam>
adrien: I'm leaving, but just saw you have problem building menhir on msys ?
<ttamttam>
If it can help, here is what I have to do for it to work on cywin+mingw:
<ttamttam>
cd ${extractdir}/${menhir} && \
<ttamttam>
sed -i "s/chmod -w/chmod u-w/" src/Makefile && \
<ttamttam>
sed -i "s|openfile \"/tmp|openfile \"c:/cygwin/tmp|" demos/ocamldep.wrapper && \
<ttamttam>
make PREFIX=${menhirprefix} install
<ttamttam>
Good afternoon
ttamttam has left #ocaml []
<adrien>
ah, he really left quickly
<adrien>
for the record, I have other issues (early ones, very early ones: it's not even building .cmi files)
<f[x]>
btw, mfp, is i64_buf really thread-safe? because of no allocations??
Reaganomicon has quit [Read error: No route to host]
george_z0rwell has joined #ocaml
george_z0rwell has quit [Ping timeout: 260 seconds]
wtetzner has quit [Read error: Connection reset by peer]
milosn has quit [Ping timeout: 258 seconds]
surikator has quit [Quit: Scientific discovery is just maximal compression of strings. Nothing more, nothing less.]
Reaganomicon has joined #ocaml
oriba has joined #ocaml
ttamttam has joined #ocaml
<mfp>
f[x]: it certainly seems I thought so when I wrote it...
<mfp>
now, the computations performed in read_i64_bits are fine, but there could indeed be a problem in IO_reader.read_i64_bits if there's a context switch in the middle of read_bytes
<mfp>
hmm I guess there was no List.mapi at the time
<mfp>
or maybe it comes from extlib and I missed it
<f[x]>
it is in extlib, yes
<f[x]>
since long ago, so no BC problem
<hcarty>
adrien: Do the mmap functions in the Bigarray modules work in Windows? That may provide a simple way to serialize groups of integers.
<hcarty>
adrien: Maybe not any better than Marshal though, depending on your specific use case.
<adrien>
hcarty: they do work on windows (well, there is windows-specific code for them) but mmap() on *nix is not a good way to write data afaik so I avoided that
avsm has joined #ocaml
ttamttam has quit [Remote host closed the connection]
<hcarty>
adrien: I did not know that... I'll have to look up why that is the case
<hcarty>
Does anyone here have pointers to example OCaml-friendly emacs configurations
<hcarty>
?
<larhat>
hcarty: what do you mean by "ocaml-friendly"? tuareg-mode is pretty useful and has many features. And you can use utop as emacs-toplevel
metasyntax|work has quit [Ping timeout: 246 seconds]
<adrien>
hcarty: you didn't know about mmap and writing? that was mentionned on the caml-list some time ago (less than a year ago, probably in 2011) but I haven't tried it nor have much knowledge of it
<hcarty>
larhat: An example .emacs (or whatever the default emacs local configuration file is) with caml-mode and tuareg enabled
<hcarty>
larhat: I'm only slightly familiar with emacs and have been meaning to give it a try again
<adrien>
your pinky finger, save your pinky finger while you can!
<hcarty>
adrien: That's why I stopped my last emacs experiment and came crying back to vim :-)
<olasd>
now I'm hitting the control key with my left-hand palm... weird, but it works :>
<olasd>
(doesn't work on a laptop though)
metasyntax|work has joined #ocaml
<larhat>
hcarty: first of all, i highly recommend you to use el-get ( https://github.com/dimitri/el-get ) which simplifies package management.
<NaCl>
larhat: wasn't that the point of package.el?
<adrien>
hcarty: I first tried emacs on a laptop which had Ctrl and Fn keys inverted, making Ctrl even harder to reach (it also taught me that my fingers didn't like contortionism at all, even with a properly placed Ctrl key)
<NaCl>
vim bindings to emacs? :P
<adrien>
olasd: :o
<larhat>
NaCl: with el-get you can install packages from anywhere (url, git, bzr, ELPA, etc.)
<larhat>
adrien: i use CapsLock for Ctrl
<larhat>
anyway, you probably don't use it :-)
* NaCl
just grabs the packages from git and uses his own git
<adrien>
larhat: that's better indeed, but I can't put much pressure for very long on my pinky
<larhat>
NaCl: I used to do that, but i think that el-get is way better in extension management.
louis418 has joined #ocaml
louis418 has quit [Client Quit]
<NaCl>
adrien's poor pinky
ulfdoz has joined #ocaml
<adrien>
NaCl: yes, poor pinky ='(
edwin has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 260 seconds]
ulfdoz has joined #ocaml
_andre has quit [Quit: leaving]
bobry1 has quit [Quit: Leaving.]
<f[x]>
hm, mfp, I though of making that buffer a property of reader ..
<f[x]>
* thought
edwin has joined #ocaml
lopex has quit []
oriba has quit [Ping timeout: 260 seconds]
schme has quit [Ping timeout: 240 seconds]
schme has joined #ocaml
schme has quit [Changing host]
schme has joined #ocaml
oriba has joined #ocaml
larhat has quit [Quit: Leaving.]
ttamttam has joined #ocaml
avsm has quit [Quit: Leaving.]
lopex has joined #ocaml
ttamttam has quit [Quit: ttamttam]
schme has quit [Read error: Operation timed out]
avsm has joined #ocaml
schme has joined #ocaml
schme has quit [Changing host]
schme has joined #ocaml
junsuijin has joined #ocaml
ankit9 has quit [Ping timeout: 258 seconds]
avsm has quit [Quit: Leaving.]
oriba has quit [Quit: oriba]
ikaros has quit [Quit: Ex-Chat]
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
Anarchos has joined #ocaml
avsm has joined #ocaml
avsm has quit [Client Quit]
lopex has quit []
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
bobry has joined #ocaml
mdelaney has joined #ocaml
lpereira has joined #ocaml
tac-tics has joined #ocaml
ygrek has joined #ocaml
ftrvxmtrx has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
oriba has joined #ocaml
zsparks has quit [Read error: Operation timed out]
ttamttam has joined #ocaml
ttamttam has left #ocaml []
everyonemines has joined #ocaml
technomancy has quit [Remote host closed the connection]
ftrvxmtrx has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
pcavs has joined #ocaml
pcavs has left #ocaml []
metasyntax|work has quit [Quit: WeeChat [quit]]
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
lpereira has quit [Quit: Leaving.]
everyonemines has quit [Quit: Leaving.]
edwin has quit [Remote host closed the connection]
junsuijin has quit [Quit: Leaving.]
surikator has joined #ocaml
tac-tics has left #ocaml []
ygrek has quit [Quit: Leaving]
mdelaney is now known as mdelaney-afk
patronus has quit [Read error: Connection reset by peer]
patronus has joined #ocaml
mjonsson has joined #ocaml
adrien has quit [Ping timeout: 260 seconds]
gildor has quit [Ping timeout: 260 seconds]
adrien has joined #ocaml
gildor has joined #ocaml
Amorphous has quit [Ping timeout: 240 seconds]
Amorphous has joined #ocaml
surikator has quit [Quit: Computer is sleeping. I'm probably not.]
surikator has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
jaar has quit [Ping timeout: 260 seconds]
wtetzner has joined #ocaml
wtetzner has quit [Remote host closed the connection]