Alpounet changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.1 out now! Get yours from http://caml.inria.fr/ocaml/release.html
ikaros has quit [Read error: 110 (Connection timed out)]
Associat0r has joined #ocaml
ikaros_ has quit ["Leave the magic to Houdini"]
tmaedaZ is now known as tmaeda0
tmaeda0 is now known as tmaedaZ
schme has quit [Remote closed the connection]
schme has joined #ocaml
joewilliams has quit [Remote closed the connection]
avsm has joined #ocaml
pad has joined #ocaml
joewilliams has joined #ocaml
WuJiang_ has joined #ocaml
WuJiang has quit [Read error: 110 (Connection timed out)]
yakischloba has quit ["Leaving."]
maskd has quit ["leaving"]
avsm has quit ["Leaving."]
<dark> orbitz, ddj=?
<dark> orbitz, link pls =)
<orbitz> dr dobbs journal
<dark> hm
<orbitz> dark: the email is about this free book "F# Survival Guide"
<infoe> wonder if the F# survival guide is more informative than F# wikibooks
tmaedaZ is now known as tmaeda0
caligula__ has quit [Read error: 104 (Connection reset by peer)]
caligula__ has joined #ocaml
jeddhaberstro has quit [Client Quit]
valross has joined #ocaml
caligula_ has joined #ocaml
caligula__ has quit [Read error: 60 (Operation timed out)]
valross has quit [Remote closed the connection]
valross has joined #ocaml
valross has quit [Remote closed the connection]
yakischloba has joined #ocaml
Alpounet has quit [Read error: 60 (Operation timed out)]
ulfdoz has joined #ocaml
joewilliams has quit [Remote closed the connection]
ttamttam has joined #ocaml
yakischloba has quit ["Leaving."]
ttamttam has quit ["Leaving."]
tmaeda0 is now known as tmaedaZ
Submarine has joined #ocaml
ski_ has quit ["Lost terminal"]
jonafan_ has joined #ocaml
ulfdoz has quit [Read error: 60 (Operation timed out)]
jorgenpt has joined #ocaml
<jorgenpt> Given foo: a -> b, and bar: int -> b -> a, how can I get a function baz that consists of a foo (bar 1)? (so that the new function will pass it's type 'b' parameter as the second one to bar, and not to foo)
<jorgenpt> If that makes sense. :-)
Yoric has joined #ocaml
<Asmadeus> I can't find anything elegant, but you can always define 'let baz x = foo (bar 1 x)'
jonafan has quit [Read error: 110 (Connection timed out)]
<mrvn> (fun b -> foo (bar 1 b))
Alpounet has joined #ocaml
pad has quit [Remote closed the connection]
<jorgenpt> Oh neat, thanks mrvn
ttamttam has joined #ocaml
Yoric has quit []
_unK has joined #ocaml
Submarine has quit [Read error: 60 (Operation timed out)]
demitar has joined #ocaml
_zack has joined #ocaml
dmentre has joined #ocaml
ygrek has joined #ocaml
valross has joined #ocaml
rwmjones_lptp has quit ["Leaving"]
rwmjones_lptp has joined #ocaml
rwmjones_lptp is now known as rwmjones
_zack has quit ["Leaving."]
Yoric has joined #ocaml
Pimm has joined #ocaml
kaustuv has joined #ocaml
_unK has quit [Remote closed the connection]
valross has quit ["Ex-Chat"]
Submarine has joined #ocaml
maskd has joined #ocaml
_zack has joined #ocaml
<Gertm> I'm starting with a little OCaml application to get the hang of the style. I want to make a list of all files in a directory, but I'm not quite sure how. I've got the Unix module to read the directory entries
<Gertm> but I'm not sure how to make a list of this
<det> What are you using to read the entries
<mrvn> Gertm: you start with the empty list [] and then add one entry at a time with entry::old_entries
<det> Sys.readdir will give you an array of entries
<det> do you really need a list ?
<Gertm> mrvn: yeah that's how I was going to go at it
<Gertm> det: ah, an array will do fine, thanks
<mrvn> But consider if you really need a list. Why not handle one entry at a time and then forget it again?
<Gertm> mrvn: that would be a better approach yeah
<Gertm> thanks, I'll need a bit of adjusting to this style of programming
avsm has joined #ocaml
<det> It's a PITA to write a recursive loop to get all the entries because Ocaml uses an exception to indicate no more entries
<det> So it is hard to be tail recursive
<mrvn> try Some Unix.readdir ... with End_of_file -> None
<mrvn> or similar
<det> yes
<det> you must convert to an option
<mrvn> There should be some syntax to write a recursion that ends in an exception.
<Gertm> yeahm that's what I was building
<Gertm> is there an idiomatic way to do 'loop until exception' ?
<Gertm> oh heh, same thing
<det> You have to convert to an option
<Gertm> okay
<mrvn> let temp = try Some (...) with Exception -> None in match temp with Some x -> ... | None -> end of recursion
<det> or use side effects
<det> PITA
<det> stblib should just return options
<det> I understand it is done for performance reasons
<mrvn> You can put that into a function though
<Gertm> thanks guys
_zack has quit ["Leaving."]
<mrvn> "Some" needs an extra allocation
<Yoric> hi
<mrvn> It is too bad options aren't encoded in memory as NULL for None and anything else for Some
<det> that cant work
<mrvn> Breaks 'a option option. :(
<mrvn> i.e. Some None
<det> breaks anything that needs full 32 bits
<mrvn> det: why? They are always encoded as pointer to a block containing the 32bit
<Gertm> you guys are making me want to stop learning ocaml :p
<det> mrvn, Some 0 ?
<mrvn> Gertm: ignore that. you don't need to know the internals how the compiler implements the details
<mrvn> det: ints are tagges with 1
<mrvn> tagged even
<det> Yoric, Hi
<Yoric> How do you do?
<det> I am well
<det> I just surprised myself about how easy it is to write a regular expression lexer from scratch
<det> very little code to compile to NFA and search
<mrvn> det: done that for writing a compiler
<det> I am now tokenizing a python-esque syntax
<det> with indent/dedent tokens
<det> now I need to make the parser
<det> ocamlyacc seems really attractive here, but I dont want to use any special tools for this
<det> I am hoping I can make some combinators that can mirror the structure of ocamlyacc
<mrvn> you wrote your own lexer. so keep going. :)
<det> mrvn, what was your compiler for ?
<mrvn> det: university course building one for a ocaml subset
<det> my lexer looks very much like what a ocamllex source file would look like
<det> except, not using a DSL for REs
<det> aka:
<det> let digit = Re.rep1 (Re.range '0' '9')
<det> s/digit/int/
<mrvn> is that [0-9]+?
<det> yes
<Gertm> I take it OCaml is mainly an academic language, or am I mistaken?:
<det> Gertm, You are mistaken
<Gertm> thank god for that :D
<det> I really hate that:
<det> type a = A of string
_andre has joined #ocaml
<det> "A" and "fun s -> A s" arent the same thing
<mrvn> There is no A
<det> In SML, they are the same
<mrvn> Yeah. Constructors should be first class objects with currying
Alpounet has quit [Remote closed the connection]
Alpounet has joined #ocaml
<kaustuv> the only way A can be a function is if we relax the lexical rules about naming of constructors
<mrvn> why?
ttamttam has quit ["Leaving."]
<mrvn> I see the problem rather on the other end, when you use the constructor partially applied.
<mrvn> Probably only the partial applied is a problem. You can already write type t = A | B of int let f = A, but not let f = B
Pimm has quit [Remote closed the connection]
tmaedaZ is now known as tmaeda0
<Leonidas> orbitz: have a link to that mail somewhere?
<Leonidas> (oh, I see, that was already asked *g*)
<Leonidas> rwmjones: what version of ocaml ships with fedora? Maybe it is an incompatibility of bitstring and ocaml 3.11.1?
<rwmjones> Leonidas, ocaml 3.11.1 and 3.11.2 depending on which version of fedora. You need some patches to bitstring to compile from source:
<Leonidas> I have applied the first but not yet the second. will try that one.
<Leonidas> rwmjones: but stupid question: why don't you include the patches into a proper upstream release?
<Leonidas> when I apply the empty case patch, the examples compile.
<Leonidas> gildor: debians ocaml-bitstring seems to be missing one patch, could you include it? http://cvs.fedoraproject.org/viewvc/devel/ocaml-bitstring/ocaml-bitstring-2.0.0-empty-case.patch?view=log Or should I better file a bug?
<_andre> anyone here good with OCamlMakefile?
<_andre> i have this makefile: http://codepad.org/btfl0cLX
<_andre> and when i run "make install" it says "No rule to make target `all', needed by `libinstall'"
ksson has joined #ocaml
<gildor> Leonidas: fill a bug, so that I can fix it when I'll have time and ask upstream (which is R. Jones from Red Hat) to release a new version with this patch ;-)
<Leonidas> gildor: ok, will do
<Leonidas> rwmjones: indeed, now I added the patch, rebuilt the package and installed it and lo and behold, it compiles without further changes.
<gildor> _andre: the %: target is strange, normal way of doing thing is include $(OCAMLMAKEFILE)
<gildor> _andre: trying something different is risky
<_andre> gildor: well, i copied that from the docs in the "Handling subprojects" section
<gildor> _andre: maybe outdated ?
<gildor> rwmjones: do you plan to do a release of ocaml-bitstring with the patch that Leonidas point me to ?
<_andre> gildor: if i do the include it says "No rule to make target `foo.cmi'"; it ignores the subproject settings
<gildor> _andre: most of the time I put the makefile in the subproject dir and set/include OCAMLMAKEFILE
Pimm has joined #ocaml
ikaros has joined #ocaml
<kaustuv> _andre: OCamlMakefile is a bit too magical. Is there a reason you can't use omake or ocamlbuild?
<_andre> kaustuv: just that i still haven't learned to use either of those :p
<kaustuv> _andre: I think learning omake is far easier than debugging OCamlMakefile, but ymmv
<gildor> _andre: ocamlbuild is nice too, as much documented as OCamlMakefile ;-)
<_andre> lol
<Leonidas> omake is IMHO quite ugly, but the omake -P mode makes up for that :)
<Gertm> Do I need to install something extra to get the Str module?
naufraghi has joined #ocaml
jimmyb2187 has left #ocaml []
<Gertm> open Str;; -> regexp;; -> Error: Reference to undefined global `Str' what's missing?
<kaustuv> Gertm: You just need to compile/link with str.cm(x)a
<Gertm> but I'd like to use it in the toplevel to test something
<kaustuv> #load "str.cma" ;;
<Gertm> ok now it works.
<Gertm> boy this gets confusing, are there good general rules to do this?
<kaustuv> Make a .ocamlinit in the directory you run the toplevel from and add all the #load commands there.
ttamttam has joined #ocaml
<kaustuv> This file is executed whenever the toplevel starts.
<Gertm> thanks, I'll make that now.
jimmyb2187 has joined #ocaml
dmentre has left #ocaml []
Associat0r has quit []
<Gertm> ah, the load makes sure the module is available and 'open' imports the functions in the current 'namespace'.. is that correct?
<kaustuv> Yes. You'll need to #load anything that's not in the standard library documented in chapter 20 of the manual
<rwmjones> gildor, yes, I do need to do that
<Leonidas> good to hear that, so all distros will have working packages
<Leonidas> hmm, I could create an Arch Linux package for that, actually..
<Camarade_Tux> btw, I found OCamlMakefile pretty nice when linking against C and I'm using it when I'm not using ocamlbuild (now, if only I knew why I can't get a .cmxs with ocamlbuild: is it unsupported or am I doing something wrong?)
<gildor> Camarade_Tux: mostly unsupported, but once someone write a rule for it, it should be ok
* rwmjones had forgotten how much svn sucks compared to git
<orbitz> i always forget how to use git
<thelema> orbitz: practice more
<rwmjones> git is horribly hard to learn, but once you become proficient, it is far better than anything else I've used
<thelema> there's quite a bit more to keep track of mentally with git. All the pointers and such.
<Camarade_Tux> gildor: ok, thanks, that's what I had inferred considering the error message I was getting
<Camarade_Tux> I'll probably have to write a rule considering I'll probably use mfp's ld-ocaml ( :-) )
_unK has joined #ocaml
<gildor> rwmjones: thanks
<Leonidas> rwmjones: thanks :) Will create an Arch package later today :)
<rwmjones> btw gildor, Leonidas, the CIL-tools part of bitstring is deprecated. No point in packaging that part.
<Leonidas> rwmjones: it does not build, make fails because it can't find extlib.
<Leonidas> ocamlfind ocamlc -g -package dynlink,unix,str,extlib,cil -I +camlp4 -I .. -c bitstring_import_c.ml
<Leonidas> ocamlfind: Package `extlib' not found
<Leonidas> I could install extlib, but this seems to be a new dependency, right?
<Leonidas> oh, it fails while compiling CIL
<Leonidas> that was previously not the case.
<rwmjones> hmm that wasn't good ... try 2.0.2 instead
lutter has quit ["Leaving."]
<rwmjones> there's no new dependency needed
<rwmjones> Leonidas, ^
<rwmjones> gildor, ^^
<Leonidas> rwmjones: that worked out of the box. Fine :)
* Leonidas writes a followup to his debian bug report
<Pimm> edo, go away
demitar has quit ["Ex-Chat"]
<det> Conclusion: ocamlyacc is waayyyy nicer than parser combinators :-)
<flux> det, tried menhir?
<det> no
<det> I was trying to avoid special tools
<flux> it's backwards compatible. but better!
<det> I wrote the lexer in pure code, and I am happy with that
<flux> also iirc it has nice documentation as well
<det> but parsing seems much less nice
<kaustuv> you actually prefer ocamlyacc to a suitably selected collection of parser combinators?
<det> yes
demitar has joined #ocaml
<det> the combinator code is harder to glance at and understand
<det> and I must eta expand all rules
<det> and use lots of parens
<kaustuv> Not sure what you mean by eta expand all rules, but since a general monadic combinator library implements full predictive parsing, you will generally observe that the combinatorized grammar follows exactly the natural grammar.
<det> yes, it is the same structure
<det> but awkward
<kaustuv> With yacc, on the other hand, you have to fight with the LALR(1) restriction
<det> and by eta expand I mean:
<det> all rules need to be recursive
<det> so I cant write simply:
Submarine has quit ["Leaving"]
<det> let parse_foo_bar_baz = parse_foo >>> fun s0 -> parse_bar >> fun s1 -> parse_baz >>> fun s2 -> return (s0, s1, s2)
<det> I have to write:
<det> let parse_foo_bar_baz tokens = let p = parse_foo >>> fun s0 -> parse_bar >> fun s1 -> parse_baz >>> fun s2 -> return (s0, s1, s2) in p tokens
<det> compare that to ocamlyacc:
<det> foo_bar_baz: foo bar baz { $1, $2, $3 }
<det> maybe that's not fair because I am using parse_ prefix
<det> but even without:
<kaustuv> if your parser type is: type 'a parser = token list -> 'a * token list, then you can do without it
<det> let foo_bar_baz tokens = let p = foo >>> fun s0 -> bar >> fun s1 -> baz >>> fun s2 -> return (s0, s1, s2) in p tokens
<kaustuv> err, token list -> ('a * token list) option, obviously
<det> I dont see how I can avoid it
<det> rules need to be recursive
<det> mutually or self
<det> ocaml will complain without eta expansion
<det> I dont most "practical" combinator libraries use 1 look ahead as well
<det> its hard to get error messages otherwise
<det> because you have no idea where the error occured
<det> s/dont/think/
<det> You have no recursive rules there
<kaustuv> well, if you have recursive rules in your grammar, you will need recursive parsers. How can you possibly avoid that?
<kaustuv> combinators certainly don't *require* more recursion than already exists
<det> I am not saying it needs avoiding
<det> I am saying that it forces your to eta expand all rules which are recursive
<det> mutually or self
<gildor> _andre: is there a difference between OCaml Uint and https://forge.ocamlcore.org/projects/uint64lib/
<det> which you really dont want to worry about
<det> typically all rules would be defined with "let rec ... and ... and"
<det> so you end up eta expanding all rules
yakischloba has joined #ocaml
<det> it is workable, but it is much less nice than ocamlyacc
<kaustuv> det: http://ocaml.pastebin.com/m7d7f81fa -- recursion without what you call "eta expansion"
<det> So you are doing something else that is even more intrusive than eta expansion? :-)
<kaustuv> I have no idea what you are complaining about
<_andre> gildor: didn't know about uint64lib :/
<kaustuv> I think you are confused about what OCaml is. In an eager language you cannot achieve what you seem to want.
<det> kaustuv, what ?
<ksson> kaustuv: all he's saying is that the ocamlyacc code is much more readable
joewilliams has joined #ocaml
<kaustuv> det: you can't say let rec foo = bar and bar = foo in ocaml
rwmjones has quit ["This computer has gone to sleep"]
<kaustuv> det: which is the essence of mutual recursion
<det> kaustuv, are you being serious or are you trolling me ?
rwmjones has joined #ocaml
<kaustuv> det: ah well, I see I'm wasting my time.
kaustuv has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<gildor> _andre: no problem, I can create your project anyway, but maybe you should be interested cooperating with Jeff Shaw
<gildor> _andre: should I create the project or do you want time to think about it ?
<gildor> (I can perfectly live with 2 project about uint, but you can maybe cooperate with/contact Jeff)
<_andre> sure, i'll send him an email
Snark has joined #ocaml
<gildor> _andre: should I create the project or do you want time to think about it ?
<_andre> you can create it
<_andre> please
<gildor> _andre: done, wait a little for the svn repository
<_andre> thanks!
<gildor> (hourly cron job)
<_andre> actually you don't need to create one, i'm using github
<_andre> i'll use the forge to store releases
<_andre> (the new project page won't let me submit a request without choosing either svn or cvs)
<gildor> _andre: do you need darcs/hg/bzr/git ?
<_andre> no, i'll use github for the repository
Yoric has quit []
<gildor> _andre: ok perfect
lutter has joined #ocaml
<ttamttam> rwmjones: trying 2.0.2 of ocaml-bitstring on mingw and 3.11.2+rc1
<ttamttam> But I had to make some manual modifications
<rwmjones> ok do you have patches?
<ttamttam> "manual" means I don't know how to make something that would not break something else.
<ttamttam> For example, I had to suppres -fPIC from CFLAGS
<ttamttam> is there any way to adapt CFLAGS with autotools ?
<ttamttam> and I had to copy byteswap.in.h into byteswap.h
yakischloba1 has joined #ocaml
<rwmjones> we certainly should use automake, but we don't at the moment ...
<ttamttam> The CFLAGS I used is a mix between Makefile.in and the output of ocamlc -config
<ttamttam> I don't know how to adapt automaticaly
jonafan_ is now known as jonafan
Submarine has joined #ocaml
yakischloba has quit [Read error: 110 (Connection timed out)]
yakischloba1 is now known as yakischloba
<flux> (yeah, I'm lagging the caml ml)
<flux> although perhaps it's more limited than I thought..
<flux> there should be some means of allocating within that shared memory block and 'defragmenting & copying' data into it
<flux> (differing from marshalling in that it could be used directly, assuming everyone has the region mapped into the same space)
itewsh has joined #ocaml
onigiri_ has joined #ocaml
<det> Hmm, my parser combinators are failing because my grammar is left recursive, I need to figure out how to fix that :x
ulfdoz has joined #ocaml
_andre has quit ["*puff*"]
itewsh has quit ["There are only 10 kinds of people: those who understand binary and those who don't"]
Camarade_Tux has quit [Read error: 60 (Operation timed out)]
Camarade_Tux has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
Amorphous has joined #ocaml
onigiri_ has quit []
naufraghi has quit []
pad has joined #ocaml
lutter has quit ["Leaving."]
ikaros has quit ["Leave the magic to Houdini"]
Snark has quit ["Ex-Chat"]
yakischloba has quit ["Leaving."]
Narrenschiff has joined #ocaml
Pimm has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
joewilliams has quit [Remote closed the connection]
pad has quit [Read error: 54 (Connection reset by peer)]
pad has joined #ocaml
pad has quit [Client Quit]
yakischloba has joined #ocaml
joewilliams has joined #ocaml
tvn2009 has joined #ocaml
tvn2009 has quit [Remote closed the connection]
lutter has joined #ocaml
onigiri_ has joined #ocaml
slash_ has joined #ocaml
onigiri_ has quit []
_unK has quit [Remote closed the connection]
pad has joined #ocaml
ulfdoz_ has joined #ocaml
BigJ2 is now known as BigJ
ulfdoz has quit [Read error: 60 (Operation timed out)]
ulfdoz_ is now known as ulfdoz
avsm has quit ["Leaving."]
jeddhaberstro has joined #ocaml
demitar has quit ["Ex-Chat"]
jeddhaberstro has quit [Client Quit]
ttamttam has quit ["Leaving."]
slash_ has quit [Client Quit]
Yoric has joined #ocaml
Yoric has quit []
ygrek has quit [Remote closed the connection]
rwmjones has quit ["This computer has gone to sleep"]
ksson has quit ["leaving"]
joewilliams has quit [Remote closed the connection]
avsm has joined #ocaml
ulfdoz has quit [Read error: 110 (Connection timed out)]
avsm has quit ["Leaving."]
joewilliams has joined #ocaml
ikaros_ has joined #ocaml
ikaros has quit [Read error: 104 (Connection reset by peer)]
chthonic_ has joined #ocaml