mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab OCaml 3.10.2 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
hsuh has joined #ocaml
LordMetroid has quit ["Leaving"]
seafood_ has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
Amorphous has joined #ocaml
Ched- has quit [Read error: 110 (Connection timed out)]
Ched- has joined #ocaml
seafood_ has quit []
Smerdyakov has quit ["Leaving"]
bzzbzz has quit ["leaving"]
marmottine has quit [Remote closed the connection]
johnnowak has joined #ocaml
seafood__ has joined #ocaml
seafood__ has quit [Read error: 104 (Connection reset by peer)]
seafood_ has joined #ocaml
Mr_Awesome has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
mbishop has quit [Remote closed the connection]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
mbishop has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
johnnowak has quit []
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood_ has quit []
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
Snark has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
seafood__ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
struk_mac has joined #ocaml
ygrek has joined #ocaml
bluestorm has joined #ocaml
seafood__ has quit []
bluestorm has quit ["Konversation terminated!"]
kelaouchi has quit [Read error: 113 (No route to host)]
seafood_ has joined #ocaml
seafood_ has quit []
seafood_ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood_ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood has quit ["Lost terminal"]
seafood has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
seafood has quit [Remote closed the connection]
seafood has joined #ocaml
Tetsuo has joined #ocaml
seafood has quit [Client Quit]
seafood has joined #ocaml
smimou has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
vbmithr_ has joined #ocaml
seafood_ has joined #ocaml
seafood__ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood__ has quit [Client Quit]
seafood has joined #ocaml
vbmithr has quit [Read error: 110 (Connection timed out)]
l_a_m has joined #ocaml
OChameau has joined #ocaml
hkBst has joined #ocaml
tty56 has joined #ocaml
Dzlk has joined #ocaml
Yoric[DT] has joined #ocaml
vixey has joined #ocaml
petchema has joined #ocaml
seafood has quit []
<vixey> does it make sense to compile one language into ocaml, then compile that.. to get an efficient program?
<vixey> I read that ocaml's very fast
<flux> I would say it would be a reasonable approach
<vixey> thanks flux
<flux> if your compiler is also in ocaml, you can use quotations to generate the code, to perhaps slightly reduce the amount of work
<flux> I don't know how that would work,though
<vixey> ocaml quotations are basically s-expressions?
<flux> something similar, yes. you can write ocaml code and that gets converted into data structures representing the code
<flux> and from that you can go into producing ascii output with the printing modules. I really don't know how to do that ;)
ygrek has quit [Remote closed the connection]
<Yoric[DT]> hi
ygrek has joined #ocaml
seafood has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit []
seafood_ has joined #ocaml
seafood has quit [Read error: 110 (Connection timed out)]
Dzlk has left #ocaml []
l_a_m has quit [Remote closed the connection]
<vixey> hi Yoric[DT]
<vixey> which printing modules did you mean flux?
<Yoric[DT]> Camlp4Printer/*
hsuh has quit [Read error: 110 (Connection timed out)]
<vixey> is it bad to want to do: let rec x = ref (!x) ?
<flux> uh.. what would that do?
<vixey> something like void *x; x = &x;
<vixey> should I use something like type 'a maybe = Nothing | Just of 'a;; instead to denote unbound variables?
<flux> yes.
<flux> vixey, what would be the type of x anyway?
<flux> perhaps you can do something similar that if you can answer that
<vixey> I see what you mean, there's no valid type for it
<vixey> type term =
<vixey> Variable of term ref maybe
<vixey> | Compound of string * (term array);;
<vixey> I'll probably use this instead
<flux> there's a builtin type 'option' with constructors None and Some, btw
Smerdyakov has joined #ocaml
<vixey> they've used open Syntax and open Parser in here, but never defined modules with those names
<vixey> is a module named Syntax made just by having a file syntax.ml?
<Smerdyakov> Yes. That's basic OCaml.
<Smerdyakov> (Might be time to read some of the manual in a general way if you didn't know that.)
<Smerdyakov> That bit of information is definitely in there.
<vixey> thanks Smerdyakov
l_a_m has joined #ocaml
hsuh has joined #ocaml
bzzbzz has joined #ocaml
seafood_ has quit [Read error: 110 (Connection timed out)]
seafood has joined #ocaml
<flux> hmm, there isn't any existing "unit module type", is there? I can't write module Foo () = struct .. end either
<Smerdyakov> [sig end]
<flux> well yes, but it's not as nice :)
<flux> and when defining a module, I need to give it a name?
<Smerdyakov> Functor arguments always need names in OCaml.
<flux> although I suppose it is a bit hackish to create identical modules
hsuh has quit [Remote closed the connection]
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
seafood has quit [Client Quit]
struk_mac has quit [Read error: 110 (Connection timed out)]
<vixey> I wrote this http://rafb.net/p/UxpzyV41.txt
<vixey> are there a lot of weird things here that should be done differently?
<flux> looks reasonable
struk_mac has joined #ocaml
struk_mac has quit [Connection reset by peer]
struk_mac2 has joined #ocaml
<petchema> vixey: pattern matching is not limited to one level, you could match directly against Variable (Name _) etc. and capture parts of the pattern with 'as'
<vixey> even through a ref?
<petchema> a ref is just a record with a single mutable field, are you sure you need a ref in the first place?
<vixey> ah match ref 1 with {contents = 1} -> 2;;
<vixey> that's cool
<petchema> mmh yes, you sometimes mutable the content. I hope it's ok (no backtracking?)
<vixey> what is backtracking?
pango_ has quit [Remote closed the connection]
<petchema> undoing some unifications because you found a dead end (or because you want to try all possible unifications, if you model allows choices at some unification steps)
pango_ has joined #ocaml
<Smerdyakov> "Backtracking" applies to a broader notion of choice than just unification.
delamarche has joined #ocaml
struk_mac2 has quit ["This computer has gone to sleep"]
Axioplase has joined #ocaml
Linktim has joined #ocaml
<petchema> sure
<vixey> I put undoing of side effects in the try's with claus
<vixey> e
struk_mac has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
<petchema> using only immutable datastructures would be less error prone
<vixey> I'm not keen on the complexity going up by a few orders though
<petchema> have you tried
<vixey> yes
<vixey> (not in ML though)
<struk_mac> seems like a classical argument
<Smerdyakov> vixey, you can use a monad to make the complexity increase negligible.
<vixey> Smerdyakov: I don't really see how that is possible
<Smerdyakov> vixey, then you don't understand what monads are.
<Yoric[DT]> I'm curious.
<Yoric[DT]> Is there a theorem stating that every imperative algorithm can be monadified into a functional program without fundamentally altering the algorithm ?
<vixey> what is a monad?
<Smerdyakov> Yoric[DT], it's completely trivial, if you're just looking at the final observable behavior. For instance, write a functional x86 simulator.
<vixey> I read about them in beauty in the beast
<Yoric[DT]> Smerdyakov: it looks trivial, but is it ?
<Smerdyakov> vixey, a very standard state monad would handle your situation.
<Smerdyakov> Yoric[DT], yes, it's trivial to implement a functional interpreter for OCaml. I'm sure it would only need small modifications to 'ocamlrun'.
<Yoric[DT]> I mean, the whole point of monads (or at least one of the main points) is to apply functional discipline to imperative constructions.
<Yoric[DT]> But, as always, applying a discipline means discarding some algorithms.
<Smerdyakov> Well, make up you're mind about exactly what you're asking, Yoric[DT]. :P
<Yoric[DT]> :)
<Smerdyakov> s/you're/your
<Smerdyakov> vixey, I'm not going to try to explain monads here. There are many references online. I don't know which references are appropriate.
<Yoric[DT]> vixey: take a look at "Don't fear the monads", it's a nice video explaining monads
<Yoric[DT]> (although, if you're already familiar with some functional programming, the first part may not be necessary)
<Yoric[DT]> Smerdyakov: Let me rephrase: what is the complexity of your x86 simulator?
<Yoric[DT]> (also, note the absence of spacing between "simulator" and "?" :))
<Smerdyakov> Yoric[DT], for OCaml, it makes more sense to talk about the OCaml bytecode language than x86, so I will switch to that.
<Yoric[DT]> ok
<vixey> Smerdyakov: If I thread state through the unification function then I still have to perform a rewrite at the end (as well as doing lookups in the state at ever node of the terms being unified) so it doesn't seem to be any less complex
<Smerdyakov> Yoric[DT], I think it's trivially complex to implement in ML.
<Smerdyakov> vixey, are you talking about code complexity or runtime complexity?
<vixey> runtime
<Yoric[DT]> I was talking about algorithmic complexity.
<Smerdyakov> vixey, oh, I thought you meant the other.
<Smerdyakov> Using a balanced tree to represent the mutable store, there's an easy argument for no more than logarithmic increase in time complexity in functionalization.
<Yoric[DT]> mmmhhhh.....
* Yoric[DT] thinks he found a bug in Enum.fold.
<Yoric[DT]> Oh, no.
<Yoric[DT]> Confusing two functions.
<hcarty> Yoric[DT]: Is this frama-c project related to your C analysis project?
<Yoric[DT]> Not yet.
<Yoric[DT]> But we're going to merge.
<hcarty> Very cool
<Smerdyakov> Yoric[DT], are you personally interested in C analysis, or is it a desperate funding thing? :)
<hcarty> Are frama-c and your project (and/or the combined form of them) something that is or will be useful for simplifying C library binding generation for OCaml? I am not a CS person, and am unfamiliar with the details of what a project like this involves
<Yoric[DT]> Desperate funding, I'm afraid.
<Yoric[DT]> hcarty: if you need a name, my project is ExtraPol.
<Yoric[DT]> (and it's not as wide as Frama-C)
<Yoric[DT]> I don't think either would simplify C library bindings, I'm afraid.
<Yoric[DT]> CIL might, possibly.
<Yoric[DT]> (it's the underlying library for Frama-C and now for a part of ExtraPol)
<Smerdyakov> Yoric[DT], what's novel about what you
<hcarty> Yoric[DT]: Ok, thanks.
<Smerdyakov> Yoric[DT], what's novel about what you're going to do?
<Yoric[DT]> Essentially, it's a form of dependent typing + types and effects for C, applied to system security.
<Smerdyakov> Gotcha. The Deputy project at Berkeley has been doing dependent types for C for a while, but not types and effects, as far as I know.
<Yoric[DT]> Smerdyakov: do you have a link ?
<Yoric[DT]> Sounds interesting.
<Yoric[DT]> (although ExtraPol has reached early testing stage, so it might be a bit too late to draw inspiration :))
<Smerdyakov> There's htis: http://deputy.cs.berkeley.edu/
<Smerdyakov> It is probably out of date.
<Yoric[DT]> Thanks,
<Smerdyakov> They have most of a realistically-configured Linux kernel checked for memory safety.
<Yoric[DT]> Nice.
<Yoric[DT]> Quite different from our objective, but nice.
<Yoric[DT]> In ExtraPol, the idea is to find out which system calls are performed -- and the value of their arguments.
<Yoric[DT]> So as to be able to reject statically things like [fopen("/etc/passwd", "r")] .
Kopophex has joined #ocaml
RobertFischer has joined #ocaml
<fremo> like in systrace & co ?
OChameau has quit ["Leaving"]
bluestorm has joined #ocaml
struk_mac has quit ["This computer has gone to sleep"]
<Yoric[DT]> fremo: systrace is dynamic, we want to do that statically.
<flux> cil is apparently providing a base for many projects
filp has joined #ocaml
RobertFischer has quit []
Kopophex has quit [Connection timed out]
Kopophex has joined #ocaml
konryd has joined #ocaml
<konryd> hello everyone, I wonder if it is possible to write a function, which, using pattern matching, would be able to print to std output in a poliphormic manner?
<bluestorm> isn't
<bluestorm> but you may use sum types
<bluestorm> type data = Int of int | Float of float
<bluestorm> let print = function Int i -> print_int i | Float x -> print_float x
<Yoric[DT]> rwmjones: ping
<fremo> is there a C checker can check ocaml-C bindings ?
Linktim has quit [Remote closed the connection]
<Yoric[DT]> Not that I know of.
<flux> actually, I've read of one
<flux> but I don't think it's maintained, and I don't think its coverage was great
<flux> perhaps google will find it
tty56_ has joined #ocaml
olasd has quit [Read error: 110 (Connection timed out)]
<fremo> I would like a binding ofthe FLTK graphic toolkit, I didn't found one, I may try one day to write one but I am kind of afraid about writing C/C++ code...
tty56_ has quit [Client Quit]
* Yoric[DT] wonders why, in ExtLib, [append e e] actually succeeds in appending [e] to itself.
<Yoric[DT]> That's not moral.
<flux> hm?
<flux> in a mutating fashion?
<Yoric[DT]> I mean, with my definition of --, [let e = 1 -- 10 in append e e]
<hcarty> fremo and flux: http://www.cs.umd.edu/~furr/saffire/
<Yoric[DT]> produces the enumeration 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
<Yoric[DT]> which is a bit scary
<hcarty> Yoric[DT]: Is that really a bad thing?
<Yoric[DT]> It's not normal.
<Yoric[DT]> Besides the fact that I chanced upon this behaviour when a hack of mine failed, it shouldn't be possible to read an enumeration twice without cloning it.
<Yoric[DT]> Otherwise, this defeats the whole semantics of enumerations.
<Yoric[DT]> Now, it might well be a bug in my additions to Enum.
<Yoric[DT]> Ok, it is.
<Yoric[DT]> But it's still immoral :)
<hcarty> Does append clone the source enums?
<Yoric[DT]> Nope.
<Yoric[DT]> But my print function clones the result of append, which in turn closes the source enums.
delamarche has quit []
<Yoric[DT]> s/closes/clones/
Snark has quit ["Ex-Chat"]
<Yoric[DT]> So the bug is in the debugging code.
<Yoric[DT]> Or maybe not.
* Yoric[DT] wonders.
<Yoric[DT]> I guess I'll just add that to the documentation.
tty56 has quit [Read error: 110 (Connection timed out)]
RobertFischer has joined #ocaml
struk_mac has joined #ocaml
konryd has quit []
ofaurax has joined #ocaml
<fremo> hcarty: thanks !
l_a_m has quit [Remote closed the connection]
ygrek has quit [Remote closed the connection]
jeremiah has quit [Read error: 104 (Connection reset by peer)]
<hcarty> fremo: You are quite welcome. Happy to point out something from (near) my home turf :-)
<Yoric[DT]> mmmmhhhh.....
delamarche has joined #ocaml
<Yoric[DT]> appending the wrong enumerations leads to all sorts of nasty surprises when you actually try to clone them
pango_ has quit [Remote closed the connection]
jeremiah has joined #ocaml
Demitar has joined #ocaml
mfp has quit [Read error: 104 (Connection reset by peer)]
pango_ has joined #ocaml
comglz has joined #ocaml
mfp has joined #ocaml
comglz has quit ["Lost terminal"]
struk_mac has quit ["This computer has gone to sleep"]
arrakis_ has joined #ocaml
<arrakis_> hello, is there someone who can help me with a camlp4 grammar and related ASTs?
<Yoric[DT]> I might be able to help tomorrow.
<Yoric[DT]> Right now, tooooo tired.
<arrakis_> can I contact you privately (via e-mail) so you can answer whenever (and if) you're willing to?
<Yoric[DT]> I'd prefer IRC.
<Yoric[DT]> Other people might drop in and give a hand.
<arrakis_> ok, no problem
<Yoric[DT]> Plus if the question is too hard, I can always pretend I'm afk without being quite as rude :)
<arrakis_> :)
<mbishop> that's the best part of IRC
<delamarche> hahaha
delamarche has quit []
<arrakis_> I bet my question isn't so hard because I'm an ocaml newbie :(
<orbitz> just ask mate
<bluestorm> so
<bluestorm> just ask ?
<arrakis_> well, I'm trying to define a simple grammar and simply print the AST generated
<bluestorm> why did you choose camlp4 ?
filp has quit ["Bye"]
<bluestorm> (i mean, ocamlyacc could do the grammar part, is there a reason for this specific choice ?)
<arrakis_> I was looking around for a way to implement a parser and I stumbled across camlp4, maybe it isn't the right tool at all
<bluestorm> hmm
<bluestorm> camlp4 is probably a good tool to write a parser in
<bluestorm> the problem is the poor documentation right now
<bluestorm> first
<bluestorm> what camlp4 are you speaking about ? what is your ocaml version ? >= 3.10 ?
<arrakis_> 3.10.2
<bluestorm> ok
<bluestorm> so it's the new camlp4 :]
<bluestorm> (the older one being.. camlp5)
<arrakis_> yes, I was reading that before coming here
<gildor_> someone knows something about enter/leave_blocking_section
<arrakis_> just to make thing clear, this is just a simple parser for a (little) subset of pi-calculus, nothing complex so if you say that ocamlyacc is more suitable for the job I'll go and look at some documentation for it
<bluestorm> actually i'm not sure ocamlyacc is simpler. There are differences because camlp4 is more or less recursive-descent while ocamlyacc is LR, and some grammars are nicer to work with in one of those setup
<bluestorm> but overall the camlp4 parsing should be fine
<arrakis_> ok
<bluestorm> (it's just that i've never tried it)
struk_mac has joined #ocaml
<bluestorm> so you've defined an empty grammar and tried to add some rules ?
<arrakis_> well, this (http://pastebin.com/d70135265) is what I came up with and it (sort of) works, the only thing I'd like to be able to do is print (on the toplevel) those AST that the parser generates
<bluestorm> ah
<bluestorm> if you want to use the actual value printer of the toplevel, you should have a parsing function (and not let _ = ...) and get the value (right now, are you doing anything with it ?)
<bluestorm> let parse input = PiGram.....
<bluestorm> and the in the toplevel (parse "foo";;)
<arrakis_> yes, I just don't know how to tell the toplevel to use this file, a simple #use doesn't work
<bluestorm> aah
<bluestorm> do you have ocamlfind ?
Mr_Awesome has quit ["aunt jemima is the devil!"]
<bluestorm> (and btw, do you have a sane toplevel with directional keys actually working ?)
<arrakis_> I guess I don't, unless it's installed by default
<bluestorm> hmm try "ocamlfind -list" in a terminal
<arrakis_> yes, I use rlwrap
<bluestorm> fine
<arrakis_> nope, going to install it
<bluestorm> hmm
<bluestorm> the next time you install ocaml, you should try godi
<bluestorm> it's quite fantastic (and comes with ocamlfind)
<bluestorm> anyway once you've got ocamlfind, you can do lots of things to load things nicely in the toplevel
<bluestorm> (however, some nasty camlp4 bugs may remain)
<arrakis_> compiling...
<arrakis_> mmm, it seems I don't have the required module Tk...
<bluestorm> hmm
<bluestorm> how did you compile it
<bluestorm> (your code, not in the toplevel)
<bluestorm> ?
<arrakis_> I was talking about findlib, not my code
<arrakis_> however my code was compiled using: ocamlc -I +camlp4 camlp4lib.cma -pp camlp4of.opt pa_pi.ml
LordMetroid has joined #ocaml
<arrakis_> isn't there a portable way to load this file of mine at the toplevel without ocamlfind? 'cause I might have to run this things on some machines I don't have admin rights on and I won't be able to install it
<bluestorm> arrakis_:
<bluestorm> if you replace your last line with
<bluestorm> let parse input = PiGram.parse_string process (Loc.mk "<string>") input
<bluestorm> then compile it
<bluestorm> ocamlc -I +camlp4 camlp4lib.cma -pp camlp4of.opt -c test.ml
<bluestorm> then you can load it as a bytecode from the toplevel :
<bluestorm> ocaml -I +camlp4 camlp4lib.cma
<bluestorm> #load "test.cmo";;
<bluestorm> # Test.parse "if true then stop else stop";;
<bluestorm> - : Test.proc = Test.Cond (Test.Bval Test.True, Test.Zero, Test.Zero)
<bluestorm> the idea of loading the bytecode directly is to avoid the processing phase from the toplevel, wich can be a bit painful
<arrakis_> wow, thank you very much
<arrakis_> I was just lunching ocaml without the -I ..., what a fool
<arrakis_> s/lunching/launching/
ofaurax has quit ["Leaving"]
bluestorm has quit ["Konversation terminated!"]
hkBst has quit ["Konversation terminated!"]
arrakis_ has quit ["Leaving"]
struk_mac has quit ["This computer has gone to sleep"]
m3ga has joined #ocaml
Tetsuo has quit ["Leaving"]
m3ga has quit [Client Quit]
RobertFischer has quit []
authentic has left #ocaml []
authentic has joined #ocaml
Axioplase has quit [Read error: 110 (Connection timed out)]
vbmithr_ has quit ["Zz"]
authentic has left #ocaml []
authentic has joined #ocaml
authentic has left #ocaml []
authentic has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
LordMetroid has quit ["Leaving"]
RobertFischer has joined #ocaml
RobertFischer has quit []
Mr_Awesome has joined #ocaml