Taaus changed the topic of #ocaml to: http://caml.inria.fr/oreilly-book/
graydon has quit []
skylan_ has joined #ocaml
skylan_ has quit [Client Quit]
skylan_ has joined #ocaml
skylan has quit [Read error: 104 (Connection reset by peer)]
olczyk has joined #ocaml
<olczyk> Can anyone suggest an example of ocaml?
<olczyk> Something just long enough to learn from, but not so large as to be overwhelming.
<olczyk> Say 100-500 lines?
<olczyk> Something more "real-world". Web-browser or something. But web-browsers are probably top comlicated.
<Taaus> Go look at the 'Hump'...
<Mongo> real world == more than 100-500 lines. :)
<olczyk> For example, you are president of some group, and you have to do three things
<olczyk> to announce meetings. Send mail to members, send out notice to newsgroups
<olczyk> and update a web page.
<olczyk> So yolu write a small program that does these things for you.
<olczyk> About 100 lines.
<olczyk> Read the partitions on a hard drive, find entries which are duplicates ( by name,size
<olczyk> and CRC).
<olczyk> Maybe 300 lines.
<olczyk> The problem is that anything more than 500 lines and I won't have a chance to
<olczyk> look at it.
<olczyk> Also comments in English ( bacause my French sucks).
<olczyk> Doesn't ocaml already come with a regex library? I ask because I notice several at the "Hump".
skylan_ is now known as skylan
emu has quit [carter.openprojects.net irc.openprojects.net]
emu has joined #ocaml
<smkl> olczyk: yes, but it's not very good
<olczyk> smkl: What's not vey good.
<smkl> the regex library distributed with ocaml
<olczyk> Ahh.
<olczyk> So is there anything in the Hump that would make a good program for a beginner to look
<olczyk> through?
<olczyk> ocamlwc looks like it has possibilities.
<smkl> oops, must go
<olczyk> Bye.
<Mongo> Any suggestions for errors of type 'unbound constructor Blah' when I try and use Blah as a type for a functor?
<Mongo> so I have:
<Mongo> module type GRAPH = functor(E: EDGE) -> sig .. end
<Mongo> module type REGEXPARSER = functor(G: GRAPH) -> functor(E: EDGE) -> sig ... end
<Mongo> module NormalRegexParser: REGEXPARSER = functor(G: GRAPH) -> functor(E: EDGE) -> struct module GInst = G(E) ... end
<Mongo> And I'm trying to use all these with something like: "let d = NormalRegexParser (NormalGraph) (RecordEdge)", where NormalGraph and RecordEdge are implementations of their respective module types.
jao has quit [Read error: 113 (No route to host)]
Yurik has joined #ocaml
* gl is away: mioum.
gl has quit [Remote closed the connection]
<smkl> Mongo: you should use something like: module M = NormalRegexParser (NormalGraph) (RecordEdge)
gl has joined #ocaml
gl has quit ["La foule est une somme d'erreurs qu'il faut corriger."]
gl has joined #ocaml
<Mongo> "Signature mismatch: Modules do not match: sig .. end is not included in Graph.GRAPH"
<Mongo> Looking at the the contents of the sig (module NormalGraph: functor (..) -> sig .. end), it's identical to GRAPH, except that in the sig, t is defined as "('a,'b) Normalgraph.NormalGraph(E).t", instead of as a generic t.
<smkl> "type t" is different from "type ('a,'b) t". but if you don't have that error, i can't help without seeing the code
olczyk has quit [Read error: 113 (No route to host)]
gl has quit ["La foule est une somme d'erreurs qu'il faut corriger."]
gl has joined #ocaml
<Mongo> GRAPH defines it as 'type ('a,'b) t', whereas NormalGraph does 'type ('a,'b) t = { mutable nodes: 'a list; mutable edges: ('a,'b) E.t list }' (where E is a functor param)
<Mongo> when I try and 'module M = NormalRegexParser (NormalGraph) (RecordEdge)', which creates the Graph, I get the error listed above. It's signature matches Graph with the exception of the ('a,'b)t.
<Mongo> I can post full code somewhere, but I've been in situations where I'm the one helping people, and I never liked people who posted code and said 'fix this for me'. :P
<smkl> wait, sig .. end cannot match GRAPH because graph is a type of functor, not structure .. what is NormalGraph?
<Mongo> module NormalGraph: GRAPH = functor(E: EDGE) -> struct .. end
<smkl> does it error if you do: module G : GRAPH = NormalGraph ?
<Mongo> module type GRAPH = functor(E: EDGE) -> sig .. end
<smkl> is this all in same file, or do you have NormalGraph at a file called normalGraph.ml?
<Mongo> Where would I do that? In normalregexparser? Ideally, I'd like to make it independant of graph type, since it's well, a functor. :)
<Mongo> latter
<smkl> ok you should have NormalGraph instead of Normalgraph in the instantation
<Mongo> Is it just that I'm new to the language, or could the error messages really be improved? :)
<Mongo> From I can see, test.ml *is* using Normalgraph in the instantiation.
<Mongo> The error is the only thing that's displaying NormalGraph (along with normalgraph.ml, that is)
<smkl> what you need is Normalgraph.NormalGraph. because you have opened Normalgraph you can use just NormalGraph
<Mongo> Er. Doh. I mixed up the names in your last bit of advice. Makes more sense now. :)
<smkl> i'm sure most error messages from ocaml could be better
<Mongo> I keep playing around with the case I'm using, since it wants one kind in some places, and others elsewhere...
<Mongo> Filenames are Upper-initial, lower-rest. And modules are case-exact?
<Mongo> Of course, now that I do that, I get "Reference to undefined global `Recordedge'" when trying "module MyParser = NormalRegexParser (NormalGraph) (RecordEdge);;" And yes, I've already done "open Recordedge"
<smkl> at least on unix, filenames can have upper letters later
<smkl> you are probably not linking recordededge.cmo
<Mongo> Hrm? recordedge.cmo exists, and I just recompiled it to ensure it was up to date. Do I have to manually link the file somehow?
<smkl> perhaps you can use the compiler like: ocamlc -c recordedEdge.cmo to have different case
<smkl> the files are linked into executable with: ocamlc -o exec a.cmo b.cmo etc.
<Mongo> Well, I was trying to compile test.ml, but it is giving me an error at the end of the file. "File "test.ml", line 16, characters 0-0: syntax error". So instead, I put my current directory into the commandline via -I and started OCamlWin.exe, and attempted to put in test.ml a piece at a time at the prompt.
<Mongo> Yeah, I know about that (the -o). But I'm trying to compile the program before I try and link it. :)
<Mongo> and yes, specifying a different case to -c does seem to help the case-ish-ness of the filenames.
<smkl> try #load "foo.cmo" with the toplevel
<smkl> the ocaml toplevel syntax might be a bit confusing. there are two alternatives, using "... ;;" like at the toplevel or "let .. = ... let .. = ..."
<Mongo> I usually use a;\nb;\nc;\nd for files. And "a;;\n" etc in the interpreter
<smkl> "let a = 1; let b = 2" is not valid
<Mongo> I usually get syntax errors with it, and then switch to 'let ..=.. in let ..=.. in begin a..;b.. end'
<Mongo> reloading everything into a fresh ocaml interpreter and trying 'module MyParser = NormalRegexParser (NormalGraph) (RecordEdge);;' again, it gives an entirely different error.
<Mongo> This module is not a functor; it has type sig module NormalRegexParser : functor (G : Graph.GRAPH ) -> (E: Edge.EDGE) -> sig ... end end
<smkl> now you didn't open NormalRegexParser
<smkl> usually the functor has a name like Make in ocaml
<smkl> so you'd have NormalRegexParser.Make ...
<Mongo> Ah. Good point (didnt open). I suppose I just need to use ocaml more, to get a feel for how to interpret what errors really mean. :|
<Mongo> Ah, and that would allow me to avoid opening files, wouldn't it...
<smkl> yes. you could also use NormalRegexParser.NormalRegexParser but ...
<Mongo> Yeah. I wanted to avoid that. :) I liked how putting the code raw in X.ml made a module X which was auto-loaded, but couldn't figure out how to combine that with functors.
<Mongo> Anyways, after refactoring it all to use the .Make syntax (no more opens!), I still get the "Reference to undefined global `RecordEdge'" error... :|
<smkl> did you do: #load "recordEdge.cmo"
<Mongo> Erg. keep getting distracted. I do very much appreciate your help. Anyways, loading that helps. Then loading NormalGraph helps. But then I'm unable to load NormalRegexParser because of undefined global Str.
<smkl> try #load "str.cma". if that doesn't work, see the manual page for Str library
<Mongo> Yay. Finally compiles/parses/runs that line of code. Can you explain why I needed to manually #load the .cmo files, if it can automatically figure out which .ml and .mli files to load?
<smkl> the .cmo files might have initialization code, order of that code matters, perhaps that is one reason. usually it is easiest to use a makefile that builds the program or toplevel with all the modules linked in
<smkl> btw, if you only have an interface, it's best to use an .ml file instead of .mli
<Mongo> .mli is intended to correspond to a .ml ?
<smkl> yes
<smkl> (then you need to link in more files, though)
tav` has joined #ocaml
tav has quit [Read error: 104 (Connection reset by peer)]
<Mongo> Any idea why I'd get "Cannot find file std_exit.cmo" when trying to link together my application?
<Mongo> scratch that.
<Mongo> I get a syntax error at the end of my test.ml script, which I'm trying to compile into an exe. Line 13, characters 0-0 Syntax error. Can't figure out what's needed to fix it. Suffixing the last line with nothing or a semicolon, I get the same error.
<Mongo> Same with converting it over to the ;; style, per one of the examples in the ora book
jao has joined #ocaml
<smkl> try making a function let main () = ... and then let _ = main ()
<Mongo> Tring to use a begin .. end to capture my code. But reducing it to "let main () = begin let a = 0 end" still gives me problems. Replacting the inner code with a print_string works fine, however.
<Mongo> And of course, it's a "Syntax Error". Specifically, on the end.
gl has quit ["La foule est une somme d'erreurs qu'il faut corriger."]
gl has joined #ocaml
<Mongo> Is there something wrong with my understanding of the begin .. end syntax?
ott has joined #ocaml
<ott> hello all
<smkl> Mongo: begin ... end is other way of saying ( ... )
<smkl> "let a = 0" syntax only works at top level
<smkl> otherwise "let a = 0 in ..." must be used
<smkl> hello ott
<Mongo> Can you explain why http://jall.org/ocaml/test.ml is failing, then?
<smkl> nope, my compiler accepts it
<Mongo> Ack! I just reverted to the code I had uploaded, and that seems to work fine. I apologize for that.
<Mongo> I get a "Fatal error: cannot load shared library dllstr\nReason: The specified module could not be found." when attempting to run my compiled executable. Not sure if you can help with that, since you're not using OCamlWin, iirc.
<smkl> did you link it with str.cma?
<Mongo> yeah, it said it needed it.
<Mongo> Do I need to run it from the ocaml/bin directory?
<Mongo> that didn't seem to help.
<smkl> no idea
<smkl> anyways, i think you need to know how dynamic linking is handled by your linker, VC or cygwin
<Mongo> I have both VC and cygwin/GCC installed. I downloaded the binary version of ocamlwin, however.
<Mongo> I suppose I can just test it on my linux box, once I get it all compiling. I'm assuming support is better there than on windows.
<smkl> yes, ocaml is clearly an unix program
tav` has quit [Read error: 104 (Connection reset by peer)]
tarball_ has joined #ocaml
<tarball_> hello
<smkl> hi
<ott> tarball_: hello
<tarball_> never heard of Ocaml before...
ott has quit [Read error: 104 (Connection reset by peer)]
tarball_ has left #ocaml []
tav` has joined #ocaml
gene9 has joined #ocaml
owll has joined #ocaml
* gene9 is away: I'm busy
gene9 has quit ["Client Exiting"]
owll has quit ["Client Exiting"]
gene9 has joined #ocaml
gene9 is now known as gene9_afk
gene9_afk has quit ["Client Exiting"]
Yurik has quit ["Client Exiting"]
Yurik has joined #ocaml
<Yurik> re
Yurik is now known as Yurik[sleepy]