<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>
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]
<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_>
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