Mr_Awesome has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has joined #ocaml
mwc has joined #ocaml
<_W_>
there, that took a while
hsuh has joined #ocaml
<_W_>
now to actually learn the language ;)
netx has quit ["Leaving"]
seafood_ has joined #ocaml
onigiri has quit [Remote closed the connection]
netx has joined #ocaml
AxleLonghorn has joined #ocaml
middayc has left #ocaml []
authentic has quit [No route to host]
rogo has quit [Read error: 113 (No route to host)]
postalchris has quit [Read error: 110 (Connection timed out)]
thermoplyae has joined #ocaml
dobblego has quit ["Leaving"]
mwc has quit [Remote closed the connection]
ben____ has joined #ocaml
ben____ is now known as ziph
thermoplyae has quit ["daddy's in space"]
mwc has joined #ocaml
thermoplyae has joined #ocaml
hsuh has quit ["rcirc on GNU Emacs 23.0.60.1"]
jdev has joined #ocaml
<_W_>
stupid question, but how do I turn an integer or float to its string representation (in base 10)?
<_W_>
I can't find it mentioned in the tutorial
<jdev>
string_of_int and string_of_float?
<_W_>
thanks
<_W_>
now, for a slightly harder, is there a general way to turn any parameterized type into a string? like Java's toString()
<thermoplyae>
some third party libraries support something like it (sexplib, i'm told)
<thermoplyae>
not in the standard library though, no
<_W_>
oh wait I see the solution, I can just pass in a function that turns the type to a string
<_W_>
<3 functional programming
Robdor has joined #ocaml
mfp has quit [Read error: 110 (Connection timed out)]
mwc_ has joined #ocaml
Robdor has quit [Remote closed the connection]
evn has joined #ocaml
jdev has quit ["5"]
goalieca has joined #ocaml
mwc_ has quit ["Leaving"]
postalchris has joined #ocaml
postalchris has quit [Client Quit]
mwc has quit ["Leaving"]
<_W_>
I've often found that a good way to learn a new language is to write a program and get other to critique it, suggest different idioms, style changes, etc
<_W_>
with that in mind, I would greatly appreciate it if someone told me all the flaws of my first ocaml program; http://pastebin.com/m9ef55a2
evn has left #ocaml []
<_W_>
going to bed this time, but checking this window and/or logs when I get back up
dibblego has joined #ocaml
ry4n_ has joined #ocaml
goalieca has quit [Nick collision from services.]
ry4n_ is now known as goalieca
Robdor has joined #ocaml
zenhacker_rouan has joined #ocaml
<thermoplyae>
i suggest _ to catch trivial patterns instead of whatever variable you're using, and structural equality is shorter than lengthy match expressions for something like "l <> Empty" rather than "match l with ... "
ry4n_ has joined #ocaml
goalieca has quit [Nick collision from services.]
ry4n_ is now known as goalieca
|Catch22| has quit [Read error: 113 (No route to host)]
ry4n_ has joined #ocaml
<thelema>
_W_: instead of Tree(a,l,r) when (match r with Empty -> false | r -> true) -> max r | Tree(a,l,r) -> Some a , try writing Tree(a,l,Empty) -> Some a | Tree (a,l,r) -> max r
goalieca has quit [Nick collision from services.]
goalieca has joined #ocaml
<thelema>
_W_: similarly, in prettyPrint, Tree(a,Empty,Empty) -> toString a
ry4n__ has joined #ocaml
ry4n__4 has joined #ocaml
ry4n_42 has joined #ocaml
<ry4n_42>
nickserv ghost freenodepass
<ry4n_42>
doh
<ry4n_42>
time to change that
<thelema>
ry4n_42: I've done that before... Once.
<mbishop>
if that really was your pass, you needed to change it anyway :)
n2 has joined #ocaml
goalieca has quit [Nick collision from services.]
n2 is now known as goalieca
* Optikal__
goes to gmail and puts in ry4n_42 gmailpass
<mbishop>
heh
ry4n_ has quit [Read error: 110 (Connection timed out)]
<goalieca>
using a proper password now i bet
ry4n_ has joined #ocaml
ry4n__ has quit [Read error: 110 (Connection timed out)]
<ry4n_>
my luck
<ry4n_>
don't ever use shaw
<ry4n_>
they suck as an isp
ry4n__4 has quit [Read error: 110 (Connection timed out)]
<Optikal__>
You use allegro?
<Optikal__>
Didn't SDL make it obsolete?
<ry4n_>
allegro5 is gonna make sdl obsolete
ry4n_42 has quit [Read error: 110 (Connection timed out)]
<Optikal__>
Why?
<Optikal__>
Is it going to finally start using hardware acceleration?
<ry4n_>
well.. allegro4 has the "little features" that made things easier.. but sdl was faster and lighter
<ry4n_>
yup. full opengl backend
<ry4n_>
does all 2d drawing of primitives that way too
<ry4n_>
then it will have openal for audio
<ry4n_>
with all "features" bundled in
<Optikal__>
how far along is it?
<Optikal__>
and is it object oriented?
<ry4n_>
its alpha still.. but what's there is stable
<ry4n_>
its mostly c but no global variables and uses thread local storage
<ry4n_>
i'm working on the timer systems. those are hella good now
<ry4n_>
sub millisecond on a lot of systems :D
<ry4n_>
also wrote flac/ogg/wav support for the new audio backend.. but that hasn't been updated in svn yet
<mbishop>
now write ocaml bindings :P
<ry4n_>
ya. i'm an ocaml n00b though :P
<ry4n_>
to be honest i gave up on haskell
<ry4n_>
it was nice but wasn't very practical for things i do
<Optikal__>
Not enough nads. You need Mo' nads.
<Optikal__>
ha!
<mbishop>
heh
<ry4n_>
no shit. i always get the answer "monads are so easy.. just go read the category theory"
<ry4n_>
and that still doesn't help me actually make a useful design
<Optikal__>
What, did the analogies to space suits and toxic waste not help?
* ry4n_
is a grad student in engineering but apparently isn't good enough at math to be able to program haskell
<ry4n_>
if i sat down for a year and learned how to thing "mathematically" .. well that would be a waste of a year :P
<Optikal__>
Yeah, engineers don't need to write proofs
<ry4n_>
i do pde's and vector spaces for research..
<Optikal__>
Just need to know which tools to use for the job
<ry4n_>
haskell was such a pita to organize code.
<ry4n_>
that's all
<thermoplyae>
i'm a mathematician and i still can't manage haskell
<ry4n_>
i'm not clever enough on a daily basis
<thermoplyae>
and the spacesuits and toxic waste line basically summarizes every tutorial i've ever attempted
<ry4n_>
i get the STM monad. its simple and elegant.
<ry4n_>
but how do you actually write a program with loops and state
<ry4n_>
my numeric code can't be done easily in haskell
<ry4n_>
not everything is fibonacci
<thermoplyae>
what got me on my most recent attempt was layered monads
<thermoplyae>
doing something like getting cli arguments means a list in a list in an IO, and for me that means the adventure is over
<ry4n_>
lol. and the whole program would have to deal with monads because 1 function did an io
<mbishop>
I stopped using haskell when I was messing around with time, and just wanted to do a simple timing function (grab current time, subtract from new current time) but I couldn't figure it out
<mbishop>
even #haskell was no real big help
<mbishop>
Although it was apparently mostly due to the time module being not so good
<thermoplyae>
the only thing i've really taken from haskell is their typeclass thing, which would be /fantastic/ to see in ocaml
<thermoplyae>
but i imagine the odds are low, since, you know, efficiency
<mbishop>
but even then, I couldn't figure out how to do simple subtraction on the times since they were IO ints heh
goalieca has quit [Read error: 110 (Connection timed out)]
<ry4n_>
two weird things about ocaml. no operator overloading, +. is weird to me. and no SMP??
<thelema>
thermoplyae: agreed. I'd like to have all the overhead taken care of at compile time.
<thelema>
ry4n_: as to overloading - call it the price to pay for type inference
<flux>
ry4n_, there is CoThreads library for parallel computing
<ry4n_>
well.. is inference done on a per-function basis?
<mbishop>
I was never a fan of overloading anyway
<thermoplyae>
i can imagine a solution that would work until you start linking across files
<thermoplyae>
after that overloading overhead is unavoidable as far as i can tell. disappointing
<mbishop>
You'd think the + / +. would be annoying, but it really isn't
* mbishop
shrugs
<flux>
isn't? it is :)
<thermoplyae>
i've gotten used to it, but it would be nice to do away with
<thermoplyae>
and to have something like print instead of print_*
<thermoplyae>
so on and so forth
<mbishop>
not fore me, I mean sometimes I see an error and go "oh, right, that's a float" but it's not really a big deal for me
<flux>
the most common mistake I do when writing complex equations is missing one "." somewhere; of course, easily fixed
<mbishop>
it's like putting "rec" in the function, you should know the function is going to be recursive anyway, so it's not that hard to forget it
<ry4n_>
you know what though.. ocaml's syntax looks a little rough at first.. but i was still able to "get the job done"
<flux>
I think "." is more akin to neeting 'rec' at each call site
<flux>
s/neeting/needing/
<ry4n_>
with haskell. it was a few days before i could do anything
<thermoplyae>
fwiw, ocaml certainly has plenty of things on haskell. the 'match' construct is way better than haskell's multiple definitions, imo
<thelema>
flux: some people use constructs like let x = process x on purpose in a non-recursive way.
<flux>
thelema, true, I'm not against that and infact I do that a lot too
<thermoplyae>
i'm willing to forego typeclasses to actually get something done, and still in a reasonably friendly way
<flux>
thelema, but my point was that the 'rec' is at the function definition, not when you call it. similarly to using floating point operators: you always tell it at the call site, not where you define the values you operate on
<ry4n_>
how close is F# to ocaml
<flux>
I suppose I could use the example FLOAT camlp4 extension and it would remove or atleast reduce the pain
<mbishop>
the syntax is moderately close (without #light), and the semantics are pretty different
<flux>
without oop they are quite similar; some operators have different precedency? (atleast of ! I know)
<ry4n_>
hmm.. so for portability.. say i wanted to run it in .net for fun
<flux>
mbishop, whta kind of other semantic differences are there?
<thelema>
flux: let rec x puts this variable x within the following scope - it acts on the scope of what follows, not the actual use of x in that scope.
<mbishop>
flux: they changed the module system too, right?
<mbishop>
I thought they had replaced the OO stuff with .Net OO stuff, and the module system with a .Net module system
<mbishop>
maybe I'm wrong though
<flux>
mbishop, yeah, no ocaml modules there
<ry4n_>
well that would make sense
<flux>
thelema, how would you know the difference, semantically the same, no?-)
<thermoplyae>
it would be nice to be able to specify operator associativity and precedence, rather than thumbing through the manual each time i declare something infix
<thermoplyae>
that might be controllable through camlp4, i've never used it before so i'm not sure what that's capable of
<flux>
thermoplyae, I think it's a two-edged sword.. with default precedencies you atleast will always know the parse tree from reading the code.
<thelema>
thermoplyae: that'd require more complicated lexing/parsing than what currently occurs.
<thermoplyae>
flux: i suppose that's true
<flux>
that may be the rationale for the SML approach too: you cannot include operator precedencies from other modules
Robdor has quit [Remote closed the connection]
<ry4n_>
is there a c++ style enum
<ry4n_>
or something "fast" that basically just makes integer constants
olleolleolle has joined #ocaml
l_a_m has joined #ocaml
thermoplyae has quit ["daddy's in space"]
<ry4n_>
i think type direction = North | .. should work
ygrek has joined #ocaml
<flux>
they are basically integer constants. however you won't be able to map those directly into integers (or back) without an explicit mapping table.
love-pingoo has joined #ocaml
filp has joined #ocaml
olleolleolle has quit []
Yoric[DT] has joined #ocaml
<Yoric[DT]>
hi
<bla>
Hi.
OChameau has joined #ocaml
rwmjones has joined #ocaml
ry4n__ has joined #ocaml
ziph has quit []
ry4n__ has quit [Remote closed the connection]
ry4n_ has quit [Read error: 110 (Connection timed out)]
linktim_ has quit [Read error: 110 (Connection timed out)]
letrec has quit []
letrec has joined #ocaml
linktim_ has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
RobertFischer has joined #ocaml
bongy has joined #ocaml
lordmetroid_ has joined #ocaml
xavierbot has quit [Read error: 110 (Connection timed out)]
romanoffi has joined #ocaml
LordMetroid has quit [Read error: 110 (Connection timed out)]
lordmetroid_ has quit [Client Quit]
linktim__ has joined #ocaml
ben___ has joined #ocaml
linktim_ has quit [Read error: 110 (Connection timed out)]
bongy has quit ["Leaving"]
bongy has joined #ocaml
ben___ is now known as ziph
bongy has quit ["Leaving"]
bongy has joined #ocaml
<AxleLonghorn>
_W_: that's because the "in" is defining the scope in which the let binding is found. If you remove "in", it means you're defining the let binding at the top level. Which requires you to put ";;" after each binding.
<AxleLonghorn>
i.e: let rec find n = function ... ;;
<AxleLonghorn>
or, if you use a function that you're going to define after the function you're defining, you can put an "and" where you'd put the ";;".
<flux>
actually top level definitions don't require ;;
<flux>
but if you don't separate with ;;, you can only have top-level definitions
<AxleLonghorn>
explain
Hamtaro has joined #ocaml
<Hamtaro>
Bonjour
<flux>
I can write a program let a = "foo" let main () = Printf.printf "hello %d\n" foo let _ = main ()
<AxleLonghorn>
Hamtaro: hello
<flux>
and it's a whole program you can compile
<AxleLonghorn>
isn't that just the compiler inferring the ;; ?
<flux>
you cannot however have a program let a = "foo" Printf.printf "hello %s" a, you must enter if let a = "foo" ;; Printf.printf "hello %s" (optional ;;)
<flux>
not really
<Hamtaro>
Peut-on utiliser la fonction read_int() dans une fonction et donner la valeur à un élément d'un tableau ?
<flux>
axlelonghorn, if you look closely, you will find that infact ;; doesn't even belong to the language specification
<AxleLonghorn>
huh
<flux>
uh, never mind, infact it does :)
<Hamtaro>
Comme ceci : let fun n tab = if n > 0 then begin tab.(n) <- read_int() end;; ?
<flux>
but it's between modules
<AxleLonghorn>
k
<ziph>
# 1 ;; ;; ;;
<coucou747>
let pi = 4. *. (atan 1.);;
<thelema>
flux: no, it's between top-level phrases
<coucou747>
can I do something better to have the value of pi ?
<hcarty>
AxleLonghorn: My understanding is that it is the compiler finding the end of each expression. Using ";;" in compiled code can hide errors at times
<hcarty>
coucou747: That's what I use, or a value from a library
<flux>
I'll quote the relevant paragraph here: "For compatibility with toplevel phrases (chapter 9) and with Caml Light, an optional ;; is allowed after each definition in a structure. The ;; has no semantic meaning. Also for compatibility, ;; expr is allowed as a component of a structure, meaning let _ = expr, i.e. evaluate expr for its side-effects."
<hcarty>
I have found that using ;; ends up hiding small typing issues which turn up as errors later on
<thelema>
hcarty: using ;; at the end of my top-level phrases. It makes sure that I've completed the phrase at the point I think I've completed it. (it helps me localize phrasing errors in what I've written.)
<flux>
in my experience ;; localizes errors better. I don't use it anyway, though
<hcarty>
So using ;; at a given point would report some cascading error there, rather than further along in the source?
<thelema>
when working with code that doesn't compile because of a missing 'in' or an extra ;, adding ;; keeps the error before it, instead of having the error get reported later
<hcarty>
Ok, I see
<hcarty>
tuareg generally catches that sort of thing for me, but that would be a very useful debugging aid
linktim_ has joined #ocaml
Hamtaro has quit [Read error: 110 (Connection timed out)]
vpalle has joined #ocaml
ygrek has quit ["Leaving"]
ygrek has joined #ocaml
linktim__ has quit [Read error: 110 (Connection timed out)]
AxleLonghorn has left #ocaml []
pango has quit [Remote closed the connection]
Morphous_ has joined #ocaml
pango has joined #ocaml
evn has joined #ocaml
Morphous has quit [Read error: 110 (Connection timed out)]
ziph has quit []
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
jlouis has quit ["kern-upgrade"]
Mr_Awesome has joined #ocaml
jonathanv is now known as jonafan
middayc has joined #ocaml
middayc has quit []
filp has quit ["Bye"]
evn has quit []
Mr_Awesome has quit ["aunt jemima is the devil!"]
bluestorm has joined #ocaml
psnively has joined #ocaml
jderque has joined #ocaml
OChameau has quit ["Leaving"]
bongy has quit ["Leaving"]
TheArthur has joined #ocaml
julm has quit [Read error: 110 (Connection timed out)]
Julm has joined #ocaml
evn_ has joined #ocaml
kfor has joined #ocaml
kfor has left #ocaml []
<_W_>
what do you typically use to write network applications in ocaml?
<psnively>
Can you be more specific?
<psnively>
e.g. the smart-ass answer would be "sockets."
<_W_>
ok, how do I use sockets
<_W_>
that's a simple one, no?
<psnively>
But I imagine you mean something like: how would I go about writing a web crawler?
<_W_>
I can't find a single example on the web
<psnively>
Er, no, which is why it's the smart-ass answer.
<psnively>
One sec.
<_W_>
no psnively, I actually mean what API do I use, what kind of module