<TheDracle>
smimou: Yeah, I was having trouble because stdout was copied over by the Unix module.
<TheDracle>
smimou: So how do I make it an "inializer"?
<TheDracle>
Ahem, initializer.
<smimou>
ok
<smimou>
I'll paste you the example of the man in pv
CapNemo has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
GreyLensman has joined #ocaml
jdrake has joined #ocaml
<ronwalf>
jlouis: It's a complex task- I'd much rather leverage a well tested toolkit, especially when it isn't part of the task I'm trying to accomplish
CapNemo has quit [Read error: 113 (No route to host)]
larsr has joined #ocaml
yauz_ has joined #ocaml
yauz has quit [Read error: 60 (Operation timed out)]
larsr has quit [Read error: 104 (Connection reset by peer)]
smimou has quit ["?"]
larsr has joined #ocaml
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
pac_ has quit ["leaving"]
mrsolo has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
avlondono_ has joined #ocaml
avlondono_ has quit ["Leaving"]
Herrchen has quit [Read error: 60 (Operation timed out)]
cjohnson has quit [bear.freenode.net irc.freenode.net]
yauz_ has quit [bear.freenode.net irc.freenode.net]
GreyLensman has quit [bear.freenode.net irc.freenode.net]
Hadaka has quit [bear.freenode.net irc.freenode.net]
mijdrol has quit [bear.freenode.net irc.freenode.net]
ronwalf has quit [bear.freenode.net irc.freenode.net]
Smerdyakov has quit [bear.freenode.net irc.freenode.net]
kosmikus|away has quit [bear.freenode.net irc.freenode.net]
fariseo has quit [bear.freenode.net irc.freenode.net]
greenrd has quit [bear.freenode.net irc.freenode.net]
gzl has quit [bear.freenode.net irc.freenode.net]
cmeme has quit [bear.freenode.net irc.freenode.net]
Hipo has quit [bear.freenode.net irc.freenode.net]
mijdrol has joined #ocaml
Hadaka has joined #ocaml
Hipo has joined #ocaml
ronwalf has joined #ocaml
GreyLensman has joined #ocaml
Smerdyakov has joined #ocaml
kosmikus|away has joined #ocaml
yauz has joined #ocaml
cjohnson has joined #ocaml
fariseo has joined #ocaml
gzl has joined #ocaml
greenrd has joined #ocaml
cmeme has joined #ocaml
Herrchen has joined #ocaml
ionOSu has joined #ocaml
GreyLensman has quit ["Leaving"]
tome_ has joined #ocaml
mrsolo has quit [Read error: 104 (Connection reset by peer)]
mrsolo has joined #ocaml
mrsolo has quit [Read error: 54 (Connection reset by peer)]
mrsolo has joined #ocaml
debona|r has left #ocaml []
monotonom has quit ["Don't talk to those who talk to themselves."]
debona|r has joined #ocaml
mijdrol_ has joined #ocaml
jason has joined #ocaml
<jason>
Hm, how do I include a separate .ml file containing type definitions into another .ml program?
<jason>
I try making a class definition in one .ml file, and then in the second one I say "open FirstFile"
<jason>
And then I try using it using a let statement, but when I say "in" it says there is a syntax error.
<jason>
On that specific token.
<jason>
Wakey wakey people..
<jason>
Person losing mind here...
vezenchio has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
<jason>
Anyone?
<jason>
vezen?
<jason>
Damn.
mijdrol has quit [Read error: 110 (Connection timed out)]
larsr has quit [Remote closed the connection]
seafood has left #ocaml []
tome_ has quit [Read error: 110 (Connection timed out)]
Snark has joined #ocaml
<Snark>
slt
Nutssh has joined #ocaml
Nutssh has quit [Client Quit]
Nutssh has joined #ocaml
<jason>
How do you implicitly return unit?
<Nutssh>
What do you mean?
<jason>
Like, I want a method to return unit.
<jason>
I want to say !unit.
<jason>
Something like that.
<Nutssh>
Ah. () is the value that has type unit. But you shouldn't generally need or want to explicitly do thiis.
<jason>
Hm, I tried !()
<jason>
And it says it returns 'a val.
<jason>
Actually 'a ref.
<Nutssh>
If you want to ignore the output of an expression, the function ignore(EXPRESSION) will ignore it.
<jason>
Ahh, Clever.
<Nutssh>
Thats because !<EXPRESSION> dereferences a reference cell, <EXPRESSION> must be of type <SOMETHING> ref,
<jason>
So, ! dereferences unit and it becomes a reference to some type that contains unit?
<Nutssh>
No, ! derefernces some sort of reference cell. unit is just some value, like [] is a list, ():unit
<Nutssh>
You use ! like let x = ref 23 ;; !x ;;
<jason>
Ah.
<jason>
Just to get the value 23.
<jason>
And !() gets some value that is (), probably garbage or something?
<jason>
I'm surprised it compiles.
<Nutssh>
No. !() won't compile. Look at the error closely. It is complaining that ! accepts only 'a ref as an argument, but the argument is unit. Type error.
<jason>
Ahh.
<jason>
Cool :)
<jason>
I thought it was some kind of return mechanism at first glance.
<jason>
Alright, more questions.
<jason>
I made a class in one .ml file.
<jason>
I want to use it from another one, so I do "open <NameOfFile>"
<Nutssh>
Don't make classes if you don't understand ref cells. :)
<jason>
When I do that in the other ml file, it seems to not want to allow me to execute any statements.
<jason>
Well, I'm trying to understand classes, I'm sure it will all come together.
<Nutssh>
No, All names are implicitly qualified with the modulel name... Anything in a file foobar.ml is available under the fully qualified name Foobar.somefunction.
<jason>
I don't understand the minor mechanics.
<jason>
Right.
<jason>
Nutssh: Yeah, but the weird thing is I can use any let statement I want.
<jason>
When I say "in" it complains about the in token.
<Nutssh>
Don't focus on ocaml classes they're big, hairy and complicated... And very seldom necessary unless you really want ad-hoc polymorphism (dynamic dispatch)
<jason>
Well, I wanted to make a smalltalkesque Socket object for playing with online MUDs.
<jason>
I already have a working eachLine function etc..
<jason>
It's mostly working the way I want it to so far.
<Nutssh>
open <MODULENAME> is namespace management, it means take every qualified name <MODULENAME>.<DEFINITION> and make it available in the current module under a shortname. Like the 'using namespace' in C++ or the import in java.
<jason>
Right.
<jason>
Why is it complaining about the 'in' statement then?
<jason>
Just a compiler fluke?
<Nutssh>
Whats the code?
<jason>
Because my let statment is screwey?
<Nutssh>
I'd say probably yes. :)
<jason>
Well, I just did this as a test: open JSocket; let bob = "Hello" in print_string bob;;
<jason>
And it complains about 'in'
<jason>
When I remove open JSocket, it works just fine.
<jason>
Does it have to do with the file extensions maybe? Like, what needs to be .ml and .mli?
<Nutssh>
; isn't a syntatic seperator. You don't need it.
<jason>
Well, I was just using it cause I was doing everything in one line for IRC.
<jason>
I'm not using it in the actual code.
<jason>
Can I post what I have somewhere for you to look at?
<jason>
Sorry about all of the confusion, I just really started with this stuff today.
<Nutssh>
; is distinct from ;; and ;; is unnecessary unless you're defining and then invoking code.
<Nutssh>
My advice is avoid classes for week.
<jason>
Well, hold on just a second :P
<jason>
This isn't about classes.
<jason>
This is about modules
<jason>
I can use this code just fine all inside the same .ml file.
<Nutssh>
Yes. Paste the code someplace and put up a URL. Also put up the error message.
<jason>
Know any good pastebins for ocaml code?
<jason>
Thanks a bunch by the way.
<Nutssh>
Spreading the ocaml cheer. The language is superb. It took garbage collection 30 years to become mainstream. We've got 10-15 years. :)
<jason>
Is GC really mainstream yet?
<Nutssh>
The reason I reccomend against classes is that you will get obscure type errors when you start passing them as arguments. I just had to deal with that and after making things more and more obtuse I concluded it wasn't worth it and came up with a cleaner design using the classes. For the most part, they're *never* necessary unless you want dynamic dispatch. This is the first time in a year that I even considered them.
<Nutssh>
java.
<jason>
I suppose.
<jason>
C# too now.
<jason>
C++ is still very widely used.
<jason>
Strangely enough a lot of physicists and mathematicians use C++.
<jason>
Which, I consider to probably be the worst possible language to use for either of these fields.
<jason>
Can you join #paste?
<jason>
Hehe.
<jason>
I'm having I hard time finding some stupid online place to post it.
<jason>
The code is very brief.
<Nutssh>
Got a website?
<jason>
No, not for a long time.
<jason>
I did when I was a kid.
<jason>
Kinda got sick of maintaning it.
<jason>
Lol.
<jason>
Html has to be the most tedius thing in the universe.
<Nutssh>
I do it for research results. I want people to find it if they're looking for it.
<Nutssh>
jason: You're behind a nat, aren't you?
<jason>
Behind a firewall, yes, didn't think of that.
<jason>
Sorry.
<jason>
Um, email it to you?
<jason>
What research are you doing?
<jason>
Wait, what do you mean by nat?
<jason>
Lol.
<jason>
I saw nat and thought firewall for some reason
<Nutssh>
no, if you can run from not behind a NAT so it can get through, I'll read it. If not, then not.
<jason>
Hm.
<Nutssh>
Network Address Translation. (aka, the brokenness of the 'home router') I won't work around other people's breakage.
<jason>
Right, I have to set up port forwarding to this.
<jason>
I'm using DHCP.
kosmikus|away is now known as kosmikus
<jason>
Too much work, I need to sleep :)
* Nutssh
doesn't care. your breakage, your problem.
<Nutssh>
I'm off for a couple of weeks, but look me up when you see me around.
<jason>
Sure.
<jason>
Thanks for your help.
<jason>
My brain is a bit overloaded for the night.
<jason>
Lol.
<jason>
Later :)
jason has quit ["Client Exiting"]
jdrake has quit [Read error: 110 (Connection timed out)]
<jlouis>
ronwalf: (RDF) I understand that. I am just ranting
mattam has joined #ocaml
smimou has joined #ocaml
kinners has joined #ocaml
Nutssh has quit ["Client exiting"]
kinners has quit [Read error: 110 (Connection timed out)]
dan|el has quit [Read error: 60 (Operation timed out)]
shawn_ has quit [Read error: 104 (Connection reset by peer)]
Nutssh has joined #ocaml
shawn has joined #ocaml
pac_away has joined #ocaml
pitecus has joined #ocaml
shawn has quit [Read error: 104 (Connection reset by peer)]
pitecus has left #ocaml []
Nutssh has quit ["Client exiting"]
jdrake has joined #ocaml
monotonom has joined #ocaml
sanity has joined #ocaml
<sanity>
can anyone point me to some easy-to-understand information on coroutines and continuations in ocaml?
sanity has left #ocaml []
<mellum>
Does Ocaml have them? Didn't think so
Smerdyakov has quit ["Client exiting"]
sanity has joined #ocaml
<sanity>
is anyone awake?
<mellum>
sanity: yes
<sanity>
mellum: can you give me any pointers to a newbie-compliant explanation of how to use continuations in ocaml?
<mellum>
I don't think you can.
<sanity>
oh, i heard that you could :-(
<sanity>
although that would explain why I can't find any references to it
<mellum>
SML-NJ has them IIRC.
<sanity>
does it compile to efficient native code like Ocaml?
<mellum>
I think so.
<mellum>
although since it supports continuations, probably not quite as efficient :)
<Smerdyakov>
Why are you writing it with that syntax?
<ronwalf>
What do you suggest?
<Smerdyakov>
What are you writing?
<ronwalf>
An OWL parser
<Smerdyakov>
I mean, are your lines with "Statement (...)" supposed to be OCaml code?
<ronwalf>
Yes, although I'm still shaky with the syntax
<Smerdyakov>
OK. I'm not sure what the code is supposed to represent.
<Smerdyakov>
Perhaps I should not attempt to participate in this conversation for that reason. :)
<TheDracle>
Smerdyakov: I have a class in one .ml file, how do I use it in another one? I tried "open <FileName>" without the ml extension.
<Smerdyakov>
TheDracle, are you doing this in the toplevel?
<TheDracle>
Smerdyakov: How do I know which one is toplevel?
<TheDracle>
I was looking for maybe a main option for the compiler or something.
<Smerdyakov>
TheDracle, the interactive prompt of the "ocaml" command is called "a toplevel."
<ronwalf>
I'm trying to map the basic RDF concepts to Ocaml in a natural way
<Nutssh>
TheDracle, you don't need to use open, you can use a fully qualified name. FooModule.somefunc
<TheDracle>
Smerdyakov: No, just making files and compiling.
<TheDracle>
Nutssh: Okay :)
<Nutssh>
Did you capitalize it? A file 'foobar.ml' defines a module called 'Foobar'.
<Nutssh>
open is equivalent to java import or C++ using.
<TheDracle>
Oh, I did.
<Smerdyakov>
Using 'open' is rarely a good idea.
<Smerdyakov>
It makes it hard to determine where things are defined.
<TheDracle>
So, should I not capitalize the file name?
<Nutssh>
Its your choice. Module names, syntatically must be capitalized. I believe post 3.05 versions of ocaml will check 'foobar.cmi' and 'Foobar.cmi' for a module called Foobar.
<TheDracle>
So, how do I let it know that the class exists in another file I'm compiling without using open?
<Smerdyakov>
Several options.
<Smerdyakov>
1) Use the fully-qualified name. new Module.className
<Smerdyakov>
2) Introduce a shorthand for the module. module M = Module;; new M.className
<TheDracle>
I tried that, it says "Unbound class"
<Smerdyakov>
3) Introduce a shorthand for the class. class c = Module.className (I'm unsure about this last one, but that's how you do it for, say, functions.)
<Smerdyakov>
Then you probably don't have the compiler building from all the right files.
<Nutssh>
TheDracle, are you compiling the interfaces first or compiling in dependency order?
<TheDracle>
ocamlc unix.cma module.ml programusingmodule.ml -o Test
<TheDracle>
Hm.
<Nutssh>
it should be available with 'new Module.className <args>'
<TheDracle>
Agh :) Hehe, it was my stupidity that caused the problem.
<TheDracle>
I kept saying MyModule.
<TheDracle>
Only the first character was supposed to be uppercase.
<TheDracle>
Thanks :)
<TheDracle>
Java strikes again!
<jdrake>
evil java
<TheDracle>
Heh.
<TheDracle>
Hey Java is a functional language you know: myFile.eachLine(new Proc() {public exec(String inString){System.out.println(inString)}};
<TheDracle>
Just, an incredibly ugly one..
<Smerdyakov>
It clearly doesn't qualify, because it doesn't have closures.
<TheDracle>
Anonymouse inner class.
<TheDracle>
Mouse :P.
<TheDracle>
Hehe.
<Smerdyakov>
Nope, that's not a closure.
<Smerdyakov>
You have to explicitly declare all closed-over variables as class members.
<Smerdyakov>
A closure would include method local variables as well.
<TheDracle>
Right, you have to declare them final, but they are available.
<Smerdyakov>
No, they are not.
<TheDracle>
Final variables are available.
<Smerdyakov>
The key point of closures is that the programm does _not_ have to determine or declare which variables will be closed over.
<TheDracle>
Right, Java just tries to make sure the variables exist after the function exits because it also has stack allocated primitives.
<TheDracle>
So, it has closures, but certainly not fully functional ones.
CosmicRay has joined #ocaml
smimou has quit ["?"]
smimou has joined #ocaml
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
__mattam__ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
__mattam__ is now known as mattam
mattam has quit [Nick collision from services.]
mattam has joined #ocaml
mattam_ has joined #ocaml
mattam_ has left #ocaml []
Research has joined #ocaml
lambdawar has quit [Remote closed the connection]
Nutssh has quit ["Client exiting"]
<jdrake>
what would be the effect of having a few let _ = functions in a file?
<monotonom>
side effects.
<Riastradh>
That question makes very little sense.
<jdrake>
in this one example there are two separate let _ = declarations. I am puzzled as to why
<monotonom>
execute the file. you will see.
<jdrake>
i already have executed it actually
<monotonom>
if the declarations perform I/O, you will have seen their effects.
<monotonom>
If it said "let _ = 1+1" of course it would be pointless :)
ionOSu has quit ["Leaving"]
jdrake has quit [Read error: 60 (Operation timed out)]
<TheDracle>
Why is there no List.get?
<Smerdyakov>
What would it do?
<TheDracle>
Get a specific element of a List?
<TheDracle>
By number.
<TheDracle>
There is an Array.get.
<Riastradh>
That function isn't very useful.
<Smerdyakov>
How about List.nth?
<TheDracle>
Ah.
<Riastradh>
And it already exists under another name!
<Smerdyakov>
Use with care. It takes time proportional to the index you request.
whee has quit []
<TheDracle>
Right.
<Riastradh>
...which is why it's not very useful.
<TheDracle>
I just want to grab the first index of an array of ip_addresses.
whee has joined #ocaml
<TheDracle>
Right, the iterators are more generally useful, I understand.
<Riastradh>
...you mean an ip_address list?
<whee>
TheDracle: there's a List.nth
<TheDracle>
Right, I found it.
<TheDracle>
Why is there a List.nth and a Array.get? Seems kinda inconsistent.
<whee>
because they're different things
<whee>
Array.get is O(1) and List.nth is O(n) (at least that's what I would expect)
<whee>
you shouldn't really be using lists if you need to be using functions like nth constantly
<Riastradh>
TheDracle, you're trying to get the first element of an ip_address list?
<TheDracle>
Yeah.
<Riastradh>
That's what hd is for.
<TheDracle>
hd?
<Riastradh>
List.hd, rather.
<TheDracle>
Header, okay.
<Riastradh>
(short for 'head,' along with which is tl, for 'tail)
<TheDracle>
Yeah.. I'm using emacs and it is tabbing things in an odd manner.
<Riastradh>
f x p
<TheDracle>
I'm having to use spacing to make the meaning of the code readily clear.
vezenchio has quit ["With little power comes little responsibility"]
Snark has quit ["Parti"]
smimou has quit ["?"]
pac_away has left #ocaml []
<monotonom>
If you write in ocaml more, you will find yourself writing the idiom of a sequence of a million let's, and then you'll see why they are all aligned at the same column.
bk_ has joined #ocaml
smimou has joined #ocaml
smimou has quit ["?"]
Nutssh has joined #ocaml
smimou has joined #ocaml
cjohnson has quit [Read error: 110 (Connection timed out)]
<ronwalf>
What do people use for parsing xml?
<Smerdyakov>
We don't parse it. It is a big dummy head.
<monotonom>
I use Java or Glasglow Haskell.
<ronwalf>
I was thinking of ocaml solutions :)
<ronwalf>
I've used Python in other places
<ronwalf>
pxp? I see that one come up a bunch
zxy_ has joined #ocaml
<monotonom>
Does the Hunk have an xml parser?
<Smerdyakov>
No, I don't.
buggs^z has quit [Connection timed out]
<monotonom>
The Hump.
<ronwalf>
There's no finalizer method in classes, is there?
<Riastradh>
No.
cjohnson has joined #ocaml
Nutssh has quit ["Client exiting"]
cjohnson has quit ["Drawn beyond the lines of reason"]