foxen5 has quit [Read error: 104 (Connection reset by peer)]
docelic|away is now known as nudedude
rox has quit [Remote closed the connection]
Kinners has joined #ocaml
rox has joined #ocaml
foxen5 has joined #ocaml
mattam has quit ["'night"]
jao is now known as jao_away
rox is now known as rox|don
rox|don is now known as rox|do_not_distu
Kinners has quit ["leaving"]
giedi__ has quit [Read error: 60 (Operation timed out)]
giedi__ has joined #ocaml
uzdav has joined #ocaml
<uzdav>
hallo
<uzdav>
Just wondering... I really need something like: type 'a 'b node = F of ('a -> 'b) | Epsilon How should I represent that? Or would you suggest using a Functor module?
<whee>
you can represent it just like that if you wanted
<uzdav>
Ok. I tried it but got syntax errors, and thought maybe it couldn't be done. (No documentation I've seen has shown more than one type parameter.)
<uzdav>
ocamlc -c test.ml
<uzdav>
File "test.ml", line 1, characters 8-9:
<uzdav>
Syntax error
<uzdav>
Program: type 'a 'b node = Foo | Bar of 'a -> 'b
<whee>
hmm
<whee>
I'm not used to normal syntax, how does 'type ('a, 'b) node = F of ('a -> 'b) | Epsilon' work?
<uzdav>
ocamlc -c test.ml
<uzdav>
Compilation finished at Mon Jan 6 22:34:09
<uzdav>
Thanks!
<uzdav>
Can you explain that syntax? Why are there more than one syntaxes anyway? Is the "normal" syntax being phased out?
<uzdav>
Is this using the preprocessor?
<whee>
the normal syntax isn't going anywhere, I just find the revised syntax using camlp4 is more consistant
<uzdav>
Being new to ocaml, I was thinking it'd be better to learn just one way first. Do you think it's better to learn with the new, or to "cut my teeth" on the old first, so I can appreciate the new better?
<whee>
like for the code I just pasted, I don't know why they decided on using a syntax that looks like the types are in a tuple
<whee>
it's good to know both, most of the code floating around is in the normal syntax
<uzdav>
That's why I asked you to explain it, but as soon as I hit return I realized it was pretty clear what it meant, having seen it in action.
<whee>
I would start learning with the standard syntax, and then pick up revised afterwards if you decide you like it
<uzdav>
I've become rather comfortable with the syntax that is in the documentation. Is the revised syntax documented in any PDF file I can print out?
<uzdav>
The documentation I've read is about 1/2 of the O'Reilly book, and about the first 100 pages of the user's manual.
<steele>
it's documented in the camlp4 reference manual
<whee>
I prefer the verbosity of the revised syntax, there's less problems for me
<steele>
polin8: Unix.getcwd
<polin8>
steele: thanks
<uzdav>
I don't mind verbosity. I'm a C++ programmer at heart. :)
<polin8>
Reference to undefined global `Unix'
<whee>
you need to include unix.cma during complication
<whee>
or unix.cmxa or something
* polin8
nods
<polin8>
i remamber now
<polin8>
have to make a fake interpreter environment right
<polin8>
with the appropriate modules compiled in
<whee>
if you're doing it with the toplevel yes
<polin8>
thanks
<whee>
look into ocamlmktop for that
<steele>
#load "unix.cma";; is enough for interactive use
<whee>
that's assuming your platform supports dynamic loading
<uzdav>
I asked if there is a way to evaluate a string in ocaml, and was told no. Then I got to thinking... how does the toplevel evaluate strings if it can't be done? Or is the toplevel different? (Maybe is a program that embeds the bytecode compiler, and does a mini-compile and evaluates that for each sentence entered?)
<steele>
but for scripting you need the modules compiled in
<steele>
uzdav: it compiles to bytecode, yes
<steele>
there is no native toplevel
<uzdav>
Is there a module for embedding that functionality directly into an ocaml program without having to make a C program?
<polin8>
ok, last stupid question for the night, then I'll leave you all alone ;)
<polin8>
getcwd returns a string but has type ()
<polin8>
val getcwd : unit -> string
<uzdav>
thank you!
<polin8>
is what that means, yes? so how do I access the string, pwd = Unix.getcwd says its () used as string
<polin8>
well printf "%s" pwd daes
<whee>
are you providing a unit argument to the getcwd call?
<uzdav>
you have to pass () to the function
<steele>
getcwd is a function that takes a value of type unit and return a string
<polin8>
thats it
<polin8>
exactly what I typed, thanks
<steele>
g'night. have to get up in 4 hours ;(
<uzdav>
good night. Thanks for your help.
<uzdav>
I was wondering about something else in Ocaml. The error messages are kind of "not-so-helpful". Some specific examples I've encountered:
<uzdav>
syntax error without saying anything about context, what it was expecting, etc. Do you know if any work is planned to be done in improving the diagnostics?
<whee>
doubt it :)
<uzdav>
do they accept patches to the compiler very easily?
<whee>
if they're useful, I would hope so
<uzdav>
One problem I ran into that took hours to debug was 2 records that both happened to have the same field name. The first was mutable, the second was not. I attempted to set the field, but it kept reporting that the field was not mutable. Of course, I flip to the .mli and sure enough it's DECLARED as mutable. I'd like a warning when one record field hides another. Seems perfectly reasonable to me. (Though once I'm more experienced, maybe that
<uzdav>
opinion will change.)
<whee>
all the field names were the same?
<whee>
oh, nevermind
<whee>
I didn't know it behaved like that. heh
<uzdav>
No, two totally unrelated records that both had a field with the same name (used for different purposes). That was the only intersection. :) The 2nd was only declared in the .ml file, and I didn't realize the collision happened until I whittled the code down to a tiny file.
<uzdav>
These are not showstopper problems, but maybe the people who use this language most would appreciate an outsider's perspective on how to improve things. I don't meant to be offensive, but maybe getting used to how it is, one stops thinking of ways to improve certain things.
<steele>
there is a reason for that behavior:
<steele>
# type a = { b: int} ;;
<steele>
type a = { b : int; }
<steele>
# type b = { b: string };;
<steele>
type b = { b : string; }
<steele>
# let f x = x.b;;
<steele>
val f : b -> string = <fun>
<steele>
type inference wouldn't get the type of f if there were different namespaces for record names
<whee>
right, but try with something like type a = {foo : int; bar : int} and b = {foo : string}
<whee>
there's no way to create something of type a
<uzdav>
exactly, and there is no warning.
<whee>
that should be a warning or something :\
<uzdav>
Another problem I've encountered regarding records: suppose I call a function and I'm sure it returns record of type "a".
<uzdav>
(f ()).b <- 9;;
<uzdav>
and type a is a record that has a mutable field b, which I tried to set above.
<uzdav>
The type checker fully knows the type that f returns. Yet if it actually returns type "b", then my only error is "Unbound record field label b."
<uzdav>
(Ooops, suppose f really returns record type "c" instead.)
<uzdav>
Why cant the error message include the fact that f returns type "c"? The compiler HAS to know this, and if I'm sure it returns one type and I'm wrong, then it's a big waste of time to try and figure out what it really returns (since it could immediately be reported.)
<whee>
I'm curious as to what ghc (haskell compiler) does in these cases, but I can't remember the name of the type that's like a record. bah. heh
<sam_>
uzdav, valid complaints..
<uzdav>
I can see tricky issues like type aliases (type c2 = c), but even that'd be better than nothing (I think).
<whee>
fields, that's it. woo
<uzdav>
fields? I think in Haskell it's called a record:
<steele>
i somehow like the erlang syntax for records
<uzdav>
type Person = record
<uzdav>
name : String;
<uzdav>
crap!
<uzdav>
nevermind
<uzdav>
I'm looking in my book, but it's giving a pascal example as a comparison.
<steele>
let a = #person { name = "foo" ..}
<whee>
heh
<whee>
steele: now if only the erlang dns would fix itself :\
<uzdav>
do the ocaml and haskell communities get along, or is there any kind of tension?
<whee>
wait a minute, I don't think there is a record-esque type in haskell
<whee>
I think they just take standard data constructors and add labels to achieve it
<uzdav>
My only haskell book gives this example:
<steele>
whee: one would think they run a cluster of erlang with dns data in a mnesia db
<whee>
uzdav: I don't think there's any tension, theres different goals between the languages
<steele>
erlang nodes i mean
<uzdav>
type Person = (String,String,Int)
<whee>
I wanted to finish my erlang irc bot, but I don't have any recent docs on me :\
<uzdav>
Compares it to the pascal record I started typing above.
<sam_>
IIRC standard ml allows you to have multiple records types with same named members, but requires some explicit typing then
<whee>
uzdav: that's just a tuple there, I don't think they do have a record type like ocaml
<whee>
you just label the fields in a standard data declaration and use those labels to access elements
<uzdav>
I think you're right. It then said they can have labels, but I'm still not sure that's the same thing. (My book is "The Craft of Functional Programming)
<uzdav>
do people use Objects in ocaml very often? I haven't run across any real examples except in the books.
<sam_>
i'm still waiting for some cool group of open source hackers who are _not_ language researchers to make a decent functional language ala ML.. maybe then i'd be half satisfied
<whee>
sam: I'm extremely pleased with haskell even if it is a research language
<whee>
uzdav: okay, haskell will complain and not even let you use two labels with the same name
<whee>
so that is probably a better solution heh
<uzdav>
maybe. :) Unless you really want to hide the old one. I've seen some examples of where modules do that with functors. (I think.)
nudedude has quit ["Client Exiting"]
<sam_>
whee, i like a lot of things about haskell, but i'm an oldskool coder who thinks that speed does matter
<whee>
haskell isn't slow, though
<whee>
depending on application, of course :)
<sam_>
though.. my experiences with haskell were with hugs.. i know ghc is supposed to be a lot better
<uzdav>
That's why I'm tyring out ocaml now. It has a very nice feel to it, and it has very fast runtimes.
<whee>
I've got an ocaml and haskell version of one of my programs (course scheduler), and the haskell version is actually faster
<uzdav>
my experience with haskell was with gofer
<steele>
and what about ram usage?
<sam_>
yeah, speed is relative.. for me speed means that you can program a real time mp3 decoder easily. for someone else speed might mean that you can code a text processing program that does a batch thing in 10 seconds
<whee>
I haven't done memory comparisons
<whee>
sam: well that's not really an application for functional programming
<uzdav>
for me, speed is processing 500 stock quotes in a second. :)
<steele>
perphaps it's just ghc that needs so much mem
<whee>
lemme do some memory comparisons now
<sam_>
whee, not for pure functional programming.. that's why i prefer unpure languages such as ml
<sam_>
whee, and even then.. if ml used something like clean's uniqueness typing, you could say it was pure too, but still capable of real time programming
<sam_>
i wouldn't mind processing 500 stock quotes an hour at the moment.. <- is looking for a job and only jobs available in this area seem to be in the financial industry :-)
<steele>
whee: do you use vim for haskell code?
<whee>
yes
<whee>
steele: ocaml version uses ~75% of the memory of the haskell vesrion
<whee>
but it's still slower :P
<steele>
that's cool ;)
<whee>
indeed
<steele>
then i guess ghc just has more to do than ocaml{c,opt}
<steele>
it takes >> 200MB when compiling gtk+hs here
<whee>
heh the compiler can be a memory hog sometimes
<whee>
I should package up this scheduler sometime and release it :|
<whee>
it was my excuse to learn parsec
<uzdav>
is there any way to just "comment to end of line", or plans for a future release? I find (* ... *) cumbersome for just 1 line.
<uzdav>
I think even C adopted // to do this. :)
<sam_>
another thing in my wishlist too.. no
<whee>
use camlp4 and add it :)
<polin8>
ugh
<polin8>
wrong window
<uzdav>
do you have to change your makefile to run camlp4, or is it automatic (like the c preprocessor?)
<whee>
you need to use the -pp flag to enable it
<whee>
even then, doing custom extensions is a pain with command line additions
<whee>
there's a bit to add :\
<uzdav>
that's unfortunate.
<whee>
first you compile a file that contains the extensions, then you have to load that file when you compile new code
<uzdav>
yikes! is there a way to link that in like making a new toplevel?
<whee>
don't believe so
<sam_>
there's just something about having your source code depend on compiler command line parameters
<steele>
mkcamlp4 creates camlp4 executables with almost the same options than ocamlmktop. See further.
<uzdav>
so how easy is it to use the new syntax you were talking about?
<whee>
the new syntax is just adding -pp camlp4r to the compiler command line
<whee>
that part is packaged nicely
<whee>
it's just a pain to define your own extensions
<uzdav>
oh. I see. It's so easy in lisp. :)
<whee>
it'd be great if camlp4 were integrated further, but the ocaml development team doesn't like the camlp4 guy. heh
<whee>
I don't know why. it's pretty stupid :P
<uzdav>
It still seems like an intelligent makefile could handle all of this. compile the extension, then compile the rest of the application passing in the right arguments to invoke it with that extension.
<steele>
yeah, there is also some findlib magic for camlp4 extensions
<whee>
there's OCamlMakefile that does handle invoking the right preprocessor depending on the comment in the particular file
<whee>
I use that for my projects; standard make handles it all
<uzdav>
I just downloaded that this weekend and have already converted my application to use it. All of 3 files (2 .ml, 1 .mli). Works like a charm.
<whee>
with that you just add (*pp camlp4r *) to the top of the files and it'll use the revised syntax preprocessor for that file when it compiles
<whee>
it's pretty nice
<uzdav>
So the makefile actually reads the source files before compiling them? Wierd.
<uzdav>
however, that is pretty clever, whatever they do.
<sam_>
a clever trick that just shows the power of the language, or a big kludge needed because of the brokeness of the language.. depends on the viewpoint :-)
<uzdav>
you're a cynic, aren't you? :)
<uzdav>
It feels like a kludge, IMHO, but if the camlp4 were integrated this would be a non-issue, I think.
<sam_>
nah, i don't consider myself a cynic :-) just been following this thing for too long and come to the conclusion that it's more likely that someone creates a new language much like ocaml that will have all the issues fixed, than that ocaml will get them fixed
<uzdav>
well, good night. Gotta get up early.
<sam_>
alright, scared another one off ;-)
<uzdav>
:)
<sam_>
g'nite
<uzdav>
Thanks whee for your help. I've got a lot of progress since that 'a 'b node is compiling...
uzdav has quit ["[x]chat"]
Zadeh_ has joined #ocaml
Zadeh has quit [Read error: 113 (No route to host)]
asqui has quit [calvino.freenode.net irc.freenode.net]
sam_ has quit [calvino.freenode.net irc.freenode.net]
polin8 has quit [calvino.freenode.net irc.freenode.net]
asqui has joined #ocaml
polin8 has joined #ocaml
sam_ has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
sam_ has quit [calvino.freenode.net irc.freenode.net]
polin8 has quit [calvino.freenode.net irc.freenode.net]
polin8 has joined #ocaml
sam_ has joined #ocaml
asqui has quit [Read error: 60 (Operation timed out)]
Torquema1a has joined #ocaml
xtrm has quit [Remote closed the connection]
xtrm has joined #ocaml
Torquemada has quit [Read error: 60 (Operation timed out)]
lament has joined #ocaml
<polin8>
well, it was almost the last question ;)
graydon has quit ["xchat exiting.."]
<polin8>
whats the simplest way to check the type of a variable or function?
<polin8>
well, maybe thats the wrong question
<polin8>
readdir returns the next entry in a directory as a string
<polin8>
so let handle = opendir foo in
<polin8>
readdir handle
<polin8>
will list .
<polin8>
calling it again will list ..
<polin8>
etc
<polin8>
when it gets to the end of the dir it raises an exception
<polin8>
I'm trying to list the contents of the dir
<polin8>
so my thought was
<polin8>
while !sometypefunction (readdir handle) = exception
<polin8>
which now that I think about it wouldn't work anyway
<polin8>
since handle would move the pointer in the dir
asqui has joined #ocaml
mattam has joined #ocaml
foxen5 has quit [Read error: 104 (Connection reset by peer)]
foxen5 has joined #ocaml
Segora has quit [Read error: 110 (Connection timed out)]
foxen5 has quit [Read error: 104 (Connection reset by peer)]
foxen5 has joined #ocaml
foxen5 has quit []
lament has quit ["PROSECUTORS WILL BE TRANSGRESSICUTED."]
asqui has quit [calvino.freenode.net irc.freenode.net]
sam_ has quit [calvino.freenode.net irc.freenode.net]
polin8 has quit [calvino.freenode.net irc.freenode.net]
asqui has joined #ocaml
polin8 has joined #ocaml
sam_ has joined #ocaml
sam_ has quit [calvino.freenode.net irc.freenode.net]
polin8 has quit [calvino.freenode.net irc.freenode.net]
asqui has quit [calvino.freenode.net irc.freenode.net]
asqui has joined #ocaml
polin8 has joined #ocaml
sam_ has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
Yurik has joined #ocaml
Yurik_ has joined #ocaml
Yurik has quit [Read error: 104 (Connection reset by peer)]
<Yurik_>
re
Yurik_ has quit [Read error: 104 (Connection reset by peer)]
esabb has joined #ocaml
karryall has joined #ocaml
rox|do_not_distu is now known as rox
<karryall>
uit
karryall has quit []
<polin8>
morning
karryall has joined #ocaml
<xtrm>
hello karryall
<polin8>
i have a beginner's question
<polin8>
I'm trying to print the contents of a directory using readdir
<polin8>
readdir returns a string until it reaches the end of the directory, then it raises an exception
<polin8>
is there something in ocaml akin to python's try statement?
<polin8>
ie try readdir until exception
<whee>
try blah with exception
<polin8>
thanks
<whee>
usually you do a pattern match style exception list
<polin8>
try blah with
<polin8>
| exept1
<polin8>
execpt2
<polin8>
moving the | to the right spot
mattam_ has joined #ocaml
asqui has quit [Success]
<karryall>
xtrm: salut
mattam has quit [Read error: 110 (Connection timed out)]
mrvn_ has joined #ocaml
lam has quit ["Changing server"]
mrvn has quit [Read error: 60 (Operation timed out)]
lam has joined #ocaml
<lam>
docelic has joined #ocaml
merriam has quit [SendQ exceeded]
Segora has joined #ocaml
<Segora>
hi
asqui has joined #ocaml
graydon has joined #ocaml
mattam_ is now known as mattam
merriam has joined #ocaml
smklsmkl is now known as smkl
systems has joined #ocaml
skylan has quit [Read error: 54 (Connection reset by peer)]
systems has quit [Killed (NickServ (Nickname Enforcement))]
Systems has joined #ocaml
Dalroth has joined #ocaml
derfy has joined #ocaml
derfy has left #ocaml []
graydon has quit [Remote closed the connection]
Systems has quit [Read error: 113 (No route to host)]
graydon has joined #ocaml
karryall has quit ["ERC vVersion 3.0 $Revision: 1.328 $ (IRC client for Emacs)"]
<mattam>
ouch, 'No public or protected classes found to document.'
<mattam>
oops
graydon has quit [Read error: 110 (Connection timed out)]
graydon has joined #ocaml
Dalroth has quit [calvino.freenode.net irc.freenode.net]
lam has quit [calvino.freenode.net irc.freenode.net]
mrvn_ has quit [calvino.freenode.net irc.freenode.net]
sam_ has quit [calvino.freenode.net irc.freenode.net]
polin8 has quit [calvino.freenode.net irc.freenode.net]
Dalroth has joined #ocaml
lam has joined #ocaml
mrvn_ has joined #ocaml
polin8 has joined #ocaml
sam_ has joined #ocaml
lam has quit [Remote closed the connection]
mrvn has joined #ocaml
mrvn_ has quit [Read error: 104 (Connection reset by peer)]
lam has joined #ocaml
asqui has quit [Read error: 60 (Operation timed out)]
asqui has joined #ocaml
lament has joined #ocaml
Torquema1a has quit ["brb"]
Torquemada has joined #ocaml
rox has quit ["Client Exiting"]
rox has joined #ocaml
two-face has joined #ocaml
<two-face>
hi
<sam_>
hi
jao_away is now known as jao
esabb has left #ocaml []
lament has quit [Read error: 104 (Connection reset by peer)]
two-face has quit ["Client Exiting"]
docelic is now known as docelic|opiates
jao is now known as jao_away
asqui has quit [Connection timed out]
lindril has joined #ocaml
asqui has joined #ocaml
lament has joined #ocaml
docelic|opiates is now known as docelic
Dalroth has quit []
Kinners has joined #ocaml
asqui has quit [Read error: 60 (Operation timed out)]
asqui has joined #ocaml
lament has quit ["PROSECUTORS WILL BE TRANSGRESSICUTED."]