lamawithonel_ has quit [Remote host closed the connection]
f[x] has joined #ocaml
Associat0r has joined #ocaml
joewilliams_away is now known as joewilliams
lopex has quit []
dnolen has joined #ocaml
enthymeme has quit [Quit: quittin' time!]
sepp2k has quit [Quit: Leaving.]
ymasory has quit [Quit: Leaving]
ymasory has joined #ocaml
ymasory has quit [Client Quit]
ymasory has joined #ocaml
ymasory has quit [Read error: Connection reset by peer]
joewilliams is now known as joewilliams_away
jamii has joined #ocaml
nannto_ has joined #ocaml
enthymeme has joined #ocaml
joewilliams_away is now known as joewilliams
Modius_ has joined #ocaml
joewilliams is now known as joewilliams_away
vivanov has joined #ocaml
Modius has quit [Ping timeout: 260 seconds]
<vivanov>
is loop tail-recursive?: let x = ref 0 let rec loop accum i = x := !x + 1; if i = 0 then accum else loop (i * accum) (i - 1) ;; it doesnt give stack overflow error even though it evaluates (x := !x + 1) first before calling itself
ymasory has joined #ocaml
ymasory has quit [Client Quit]
dnolen has quit [Quit: dnolen]
Justin927 has joined #ocaml
Justin927 has left #ocaml []
ankit9 has quit [Remote host closed the connection]
philtor has quit [Ping timeout: 240 seconds]
<adrien>
vivanov: looks like it is: there's nothing left to do after the recursive call to loop
ygrek has joined #ocaml
<vivanov>
adrien: ok, ic -- thx a lot :)
jderque has joined #ocaml
ygrek has quit [Ping timeout: 250 seconds]
ankit9 has joined #ocaml
ftrvxmtrx has quit [Quit: This computer has gone to sleep]
Associat0r has quit [Quit: Associat0r]
Snark has joined #ocaml
enthymeme has quit [Ping timeout: 246 seconds]
boscop_ has joined #ocaml
boscop has quit [Ping timeout: 250 seconds]
jderque has quit [Quit: leaving]
pdhborges has joined #ocaml
ftrvxmtrx has joined #ocaml
jonafan has quit [Ping timeout: 240 seconds]
jonafan has joined #ocaml
caligula has quit [Ping timeout: 240 seconds]
caligula has joined #ocaml
<ski>
vivanov : just as `<expr>' is in tail-position wrt `let <decl> in <expr>', it is in tail-position wrt `<comm>; <expr>'
<ski>
(and similarly for the expressions in the branches of a `match' -- i would assume the wrapped expression in a `try' is *not* in a tail-position, though -- see <http://martin.jambon.free.fr/extend-ocaml-syntax.html#lettry> for something related)
ikaros has joined #ocaml
<vivanov>
ski: thanks -- very interesting
Cyanure has joined #ocaml
<ski>
(obviously the branches of an `if' is the same as the branches of a `match')
<vivanov>
right
<ski>
also, the branches of a `function' and the body of a `fun' is in tail-position wrt to the *call* to the function (not to the function expression itself)
<ski>
all this becomes quite apparent if you write a (sensible) CPS translator, such as in the papers "Abstracting Control" and "Representing Control" (i don't recall which of them was relevant here)
<ski>
(iirc those papers were by Andrzej Filinksi, but i might be wrong)
<vivanov>
sky : ok
<vivanov>
"wrt to the *call* to the function (not to the function expression itself)" -- didnt understand
<ski>
if you have `let f = fun x -> g (h x) in f 42'
<vivanov>
ok
<ski>
then `g (h x)' is not in tail-position wrt `fun x -> g (h x)' but, so to speak, wrt `f 42' (though that's not syntactically an enclosing expression, so this terminology starts to break down here)
<ski>
in continuation-speak : `g (h x)' is executed with the *same* continuation as `f 42' is
<vivanov>
ski: thanks a lot -- i guess i need to do some reading to get it :)
pdhborges has quit [Quit: Leaving.]
<ski>
the continuation of the evaluation of an expression is what will happen after the expression is evaluated
<ski>
if you have a program `..(2 + f 42)..' then the continuation of `f 42' is `..(2 + <-->)..' where `<-->' denotes a hole, which is to be filled with the value of `f 42'
<ski>
so the continuation here is "add two, then continue with whatever `..<-->..' there does"
<ski>
the continuation represents what to do after, typically this expects to receive the value of the expression
<ski>
in `..(2 + f 42)..', the continuation of `f 42' is not the same as the continuation of `2 + f 42' -- because the former continuation has to remember to add two before doing the same as the latter continuation
<ski>
typically in an implementation continuations are stored on a stack (but there are other kinds of implementation)
<ski>
so if you have e.g. `let rec f n = if n = 0 then 1 else n * f (n - 1) in f 5', then the recursive call `f (n - 1)' has a different continuation than the current call `f n'
<ski>
and therefore the stack is growing
<ski>
(it has to remember to multiply by `n' before returning to the earlier continuation)
<ski>
the terminology "`<e0>' is in tail-position wrt `<e1>'" means roughly that, at run-time, the continuation of `<e0>' is the same as the continuation of `<e1>' (nothing more to remember to do)
<ski>
e.g. `<consequent>' as well as `<alternate>' is in tail-position wrt `if <condition> then <consequent> else <alternate>', because after evaluating `<consequent>' (alternatively `<alternate>', as the case may be), there's nothing more to do to compute the value of the whole conditional
<ski>
the relation "is in tail-position wrt" is defined syntactically, on sub-expressions, but is meant to catch some of the run-time behaviour of the corresponding continuations, when the code is evaluated
* ski
stops here before this gets any more incoherent
<vivanov>
ski: great -- thx very much -- its clear now :)
Tobu has joined #ocaml
mfp has quit [Ping timeout: 250 seconds]
mfp has joined #ocaml
pdhborges has joined #ocaml
<pdhborges>
is gasche here?
Anarchos has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
ulfdoz has joined #ocaml
_andre has joined #ocaml
jderque has joined #ocaml
lopex has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
vivanov has quit [Ping timeout: 250 seconds]
vivanov has joined #ocaml
lamawithonel has joined #ocaml
sepp2k has joined #ocaml
ygrek has joined #ocaml
Modius_ has quit [Quit: "Object-oriented design" is an oxymoron]
sepp2k has quit [Quit: Leaving.]
<hcarty>
Is there a simple/clean way to match an OCaml expression from ocamllex?
<hcarty>
I'm looking at the xstrp4 syntax extension and trying to see if it is feasible to extend the syntax from ${id,optional_tag} ${expr, optional_expr}
Tobu has joined #ocaml
ygrek has quit [Ping timeout: 250 seconds]
Yoric has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
<Anarchos>
hcarty maybe look at the source of the lexer of the ocaml compiler itself ?
dnolen has joined #ocaml
pdhborges has left #ocaml []
lamawithonel has quit [Remote host closed the connection]
<hcarty>
Anarchos: That's probably the safest way to go.
<hcarty>
Does camlp4 have a string -> expr function? (if such a thing makes sense...)
<hcarty>
I'm still rather new to messing with OCaml syntax, so I apologize if any of these questions are ridiculous :-)
<Anarchos>
hcarty we all were beginners at one time so no ridiculous questions
Tobu has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
<hcarty>
Woo-hoo! I think I have it working at very least at the dirty hack level :-)
<hcarty>
"let x = 3.14 in let s = <:here<$x, (fun () f -> string_of_float f)>> in s" gives you the string "3.14"
fraggle_ has quit [Remote host closed the connection]
<hcarty>
"let x = 3.14 in let s = <:here<$x, (fun () f -> string_of_float f)$>> in s" gives you the string "3.14" -- to correct a typo
<Anarchos>
i never played with syntax
<hcarty>
Ack, I still typed it incorrectly... but it works
<hcarty>
Anarchos: xstrp4 is interesting, but it seemed somewhat limited. You could have Perl-like $var interpolation in strings.
<hcarty>
But the values had to match the standard printf-like %d, %f, etc. supported values
<hcarty>
supported types rather
<adrien>
hcarty: while you're at it, you might want to check why "file" becomes "forbidden" with xstrp4 while it shouldn't be anymore (xstrp4 used to define it but stopped one version ago afair)
<hcarty>
adrien: I noticed that, but I don't remember if I found out why. I just picked up this project again a few minutes ago.
<hcarty>
adrien: I think my "fix" may have been to strip out everything but the <:here<>> quotation support :-)
<adrien>
heheh =)
<hcarty>
adrien: Any interest in testing the tweaked, any-expr-ready version?
<adrien>
I'm simply mentionning it so that if you stumble onto something you can look at it but don't worry too much
<adrien>
hcarty: what does it involve? (I should finish some code first)
<hcarty>
I definitely will look out for it
<hcarty>
adrien: A patch to the xstrp4 source code. No need to rush, as I would like to a bit more cleanup.
<hcarty>
If it stands up to a bit more testing I'll submit a patch to Gerd
<adrien>
hcarty: ok, tell me when you're ready
<hcarty>
I may be able to make ${expr, expr} work, but I'm not certain about that. It seems like it could be pretty fragile. No harm in trying though.
<adrien>
=)
Tobu has quit [Ping timeout: 248 seconds]
Tobu has joined #ocaml
Associat0r has joined #ocaml
edwin has joined #ocaml
fraggle_ has joined #ocaml
<adrien>
it's probably true but I'm wondering: if I have "let x = ref (Some weak_ref)", does a subsequent "x := None" keeps a reference to "weak_ref"?
avsm has joined #ocaml
<thelema>
adrien: huh? why would clearing an opt ref keep its old value?
<flux>
eikös habanero ole ns. porttikasvi? samalla laitteistolla on helppo siirtyä hampun kasvattajaksi.
<thelema>
flux: same back at you. :P
<adrien>
thelema: I'll be doing that inside a function, and I don't want the weak reference to be cleared
<flux>
oops
* adrien
couldn't get close to the meaning of a single word
<flux>
adrien, habanero perhaps?
<thelema>
the weak ref will be unaltered by x := None
<thelema>
other than that it might get GC'ed
<adrien>
flux: pepper?
dnolen has quit [Quit: dnolen]
<adrien>
thelema: so: "ignore !x; x := None" ?
<flux>
adrien, yes, a hot variety of chili pepper
<zorun>
looks like finnish, isn't it?
<thelema>
adrien: that is no different from x := None
<flux>
zorun, correct
<zorun>
:)
<zorun>
I almost got accustomed to finnish by listening to ievan polkka over and over...
dnolen has joined #ocaml
ankit9 has quit [Quit: Leaving]
<adrien>
thelema: !x will keep a reference to weak_ref, which is the only thing I want
<adrien>
but I expected that "x := None" would keep a reference too
dnolen has quit [Client Quit]
<adrien>
(since ocaml doesn't try very hard to be smart)
<thelema>
adrien: well, I recommend against weak refs in general
<adrien>
thelema: it's React; as far as I'm concerned, I'm keeping 100% of the weak references returned by React
<thelema>
but in this case, let y = !x in ... unpacks the ref, while x := None doesn't unpack the ref, so doesn't involve its contents
<adrien>
ok, so ignore !x; x := None
avsm has quit [Read error: Connection reset by peer]
<adrien>
(it's for a "destructor")
avsm has joined #ocaml
<thelema>
when that destructor finishes, !x will leave scope, yes
hto has quit [Ping timeout: 240 seconds]
boscop_ is now known as boscop
ftrvxmtrx has quit [Quit: This computer has gone to sleep]
lamawithonel has joined #ocaml
lopex has quit [Ping timeout: 252 seconds]
ygrek has joined #ocaml
yezariaely has joined #ocaml
joewilliams_away is now known as joewilliams
vivanov has quit [Quit: Lost terminal]
ygrek has quit [Ping timeout: 250 seconds]
_michi_ has joined #ocaml
thelema_ has joined #ocaml
thelema has quit [Read error: Connection reset by peer]
jderque has quit [Quit: leaving]
ymasory has joined #ocaml
hto has joined #ocaml
philtor has joined #ocaml
<philtor>
I downloaded and built deriving... passed the tests. How does one go about installing deriving?
<thelema_>
philtor: make install?
<philtor>
make: *** No rule to make target `install'. Stop.
<adrien>
philtor: a META file somewhere?
<philtor>
nope.
<philtor>
if there were I could use ocamlfind to install it, I suppose.
<thelema_>
lol, there's no install support in the package
<philtor>
Yeah, that's what I'm concluding.
<thelema_>
well, try running [make libinstall] in the lib/ dir
<hcarty>
There are at least two deriving repositories out there - one may have a META file
ocamlbuil has joined #ocaml
<adrien>
most probably, and I see "deriving-ocsigen" in godi
<thelema_>
grr, except you'll need a META file still
<thelema_>
[make rawinstall] in each of lib/ and syntax/
<ocamlbuil>
how can i include modules with ocamlbuild? i did "open Unix" in my source file and ocamlbuild -lib unix target but didnt work
<thelema_>
ocamlbuil: in _tags: "<filename.*>: use_unix"
<zorun>
weird, I'm using the same syntax as ocamlbuil and it works
<ocamlbuil>
thelema: where is this _tags?
<thelema_>
ocamlbuil: you should create it in the root of your project
<ocamlbuil>
like "<main.ml>: use_unix"?
<thelema_>
ocamlbuil: <main.*>: use_unix
<thelema_>
this tag needs to apply to .cmo, .cmx, etc.
<zorun>
thelema_: wait, his snytax should work
<zorun>
I guess the issue is somewhere else
<thelema_>
zorun: I expect it not to link properly with just <main.ml>
<zorun>
ocamlbuil: what are you using exactly to compile?
<ocamlbuil>
ocamlbuild
<zorun>
the command line?
<ocamlbuil>
yes
<zorun>
I mean, which command line exactly?
<ocamlbuil>
i tried ocamlbuild -lib unix main.native
<zorun>
weird, I use the same, it works perfectly fine
<zorun>
and with main.byte?
<ocamlbuil>
the same, i get Unbound module Unix
<zorun>
which version of ocaml are you using?
<ocamlbuil>
3.11.2
<thelema_>
ocamlbuil: ls `ocamlc -where` | grep unix
<ocamlbuil>
no such file or directory
<zorun>
wtf?
<thelema_>
ocamlbuil: huh? you don't have ocamlc?
<thelema_>
or ocamlc -where returns a directory that doesn't exist?
<thelema_>
in either case, your ocaml install is *broken*
<zorun>
yeah
<ocamlbuil>
ok, but with this _tags file it should work if my ocamlc is there?
<thelema_>
if you don't have unix.cma in your `ocamlc -where` directory, then it can't link in the unix library
<zorun>
what does "ocamlc -where" returns, by the way?
<hcarty>
ocamlbuil: You shouldn't even need the _tags file if the OCaml installation is complete
<thelema_>
ocamlbuil: the _tags file "true: use_unix" is equivalent to "-lib unix" on the command line
jamii has quit [Ping timeout: 250 seconds]
pdhborges has joined #ocaml
<philtor>
Ok, I got deriving-ocsigen installed via godi. How can I use this in the toplevel?
<thelema_>
pdhborges: thanks for the commit, can you remove the TODO from the wiki?
<thelema_>
generally the canonical version is identifiable by all the commits
<hcarty>
thelema_: For some definitions of canonical...
<thelema_>
yes, when "canonical" := "the version I should use"
<hcarty>
Unless you pick an experimental fork someone is actively playing with
<thelema_>
true, the lack of anyone else merging should indicate danger
<hcarty>
For example, the README in the deriving fork linked above says, "The patches in these repository are propositions..."
jamii has quit [Ping timeout: 250 seconds]
<thelema_>
hcarty: yeah, but this makes it pretty easy to decide among the three github branches, one of which is endorsed on the old google code page
<hcarty>
thelema_: I agree, although that one doesn't include what philtor was looking for (findlib and installation support)
<thelema_>
yes, but despite being endorsed, it's clearly not really under development
<thelema_>
s/but//
<hcarty>
Unless it's stable, of course
<thelema_>
of course
<pdhborges>
thelema_: is it possible to break hte inline examples into multiple lines?
<thelema_>
pdhborges: examples for documentation or quick tests?
<pdhborges>
documentation
<thelema_>
of course.
<pdhborges>
when I generate the docs
<pdhborges>
they are put in the same line
<thelema_>
a blank line should force a new line
<hcarty>
thelema_: Will that force a new paragraph as well?
<thelema_>
hcarty: I don't know.
<thelema_>
I'm just reading the docs: | blank_line force a new line.
<hcarty>
wrapping in [ ] may do it
<hcarty>
I don't know if breaks are maintained in []
<thelema_>
{v v} gives verbatim... {[ ]} for verbatim code
<Anarchos>
who already used ocamlweb ?
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
<pdhborges>
thelema_: I implemented rchop and lchop
<pdhborges>
but
<pdhborges>
currently I let it fail on sub if n < 0
<thelema_>
can't you add "if n >= String.length s then "" else
<thelema_>
oh, I misunderstod
<thelema_>
hmm, negative n should raise... Invalid_argument, no?
<pdhborges>
yes
<pdhborges>
but do I put the check on rchop
<pdhborges>
or let it fail on sub?
<thelema_>
which it does, but on the string.sub instead of the string.*chop
<thelema_>
hmm, double-checking lowers performance (slightly), fail on sub reduces usability of error message.
<thelema_>
Let's check in *chop for negative n
jderque has joined #ocaml
<pdhborges>
ok
avsm has quit [Quit: Leaving.]
wishi has quit [Quit: No Ping reply in 180 seconds.]
<pdhborges>
thelema_: finished
Yoric has quit [Quit: Leaving.]
<thelema_>
looks good to me. Thanks for including tests and better docs
vivanov has joined #ocaml
pdhborges has left #ocaml []
ftrvxmtrx has joined #ocaml
ygrek has joined #ocaml
Snark has quit [Quit: Ex-Chat]
Anarchos has joined #ocaml
jonathanrk has joined #ocaml
jonathanrk has left #ocaml []
schme has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
ankit9 has joined #ocaml
Tobu has quit [Remote host closed the connection]
Tobu has joined #ocaml
malouin has quit [Remote host closed the connection]
Tobu has quit [Remote host closed the connection]
* adrien
has been completely spoiled by ocamlbuild
Tobu has joined #ocaml
<Anarchos>
adrien acn you explain ?
<adrien>
I've forgotten bhow how to properly compile a library with several files: foo.ml depends on bar.ml
Yoric has joined #ocaml
<adrien>
I'm comparing to what ocamlbuild does and can't find the difference =/
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
<adrien>
woah...... I've split a file into two (tabs.ml -> tabs.ml + zipper.ml) and forgot to add "Zipper." or "open Zipper" to "tabs.ml"... completely stupid mistake /o\
rixed_ has joined #ocaml
<rixed_>
'lo! How can I write the type of all possible polymorphic variant? I'd like to define a record like type record={ field : [ `Foo | `Bar | ... ] } is it possible?
oriba has joined #ocaml
oriba has quit [Read error: Operation timed out]
vivanov has quit [Quit: Lost terminal]
<adrien>
all? or do you need "at least some elements"? or maybe an "'a record = { field : 'a }" (in case you have other fields in the record)?
philtor has quit [Ping timeout: 260 seconds]
<rixed_>
adrien: the field is meant to help intepret the meaning of another field (a string). If it's `Ip, then the string is an IP packet, if it's `Tcp then it's a TCP payload, if it's anything else then we do not intepret the string... See?
<rixed_>
So the field can actually countaint any variant.
<rixed_>
but I can't write [> `Ip | `Tcp ], it's a syntax error
enthymeme has quit [Read error: Connection reset by peer]
<adrien>
hard to say without seeing much but "type 'a t" seems to be enough
<adrien>
let f x = match x.x with | `Foo -> "foo";;
<adrien>
val f : [< `Foo ] t -> string = <fun>
<adrien>
what would that be missing?
<adrien>
s/missing/lacking/
<rixed_>
Ok, but it will force me to propagate this type parameter everywhere (type 'a record, etc...)
<rixed_>
and it does not feel right when all I need is a tag.
wagle has quit [Read error: Connection reset by peer]
<rixed_>
Well, for now I will merely enumerate the values implemented for my tag...
<rixed_>
\who
<rixed_>
:)
ankit9 has quit [Quit: Leaving]
ygrek has quit [Ping timeout: 250 seconds]
zsparks has quit [Ping timeout: 240 seconds]
ymasory has quit [Quit: Leaving]
rixed_ has quit [Quit: zzzZZZzzzZZZ]
wagle has joined #ocaml
<hcarty>
adrien: ${expr, expr} does seem to work, at least for some basic tests
_andre has quit [Quit: Lost terminal]
<hcarty>
adrien: I don't have position reporting working with this though... another part of camlp4 to figure out!
<hcarty>
s/position/error location/
fschwidom has joined #ocaml
fschwidom has quit [Remote host closed the connection]
fschwidom has joined #ocaml
jderque has quit [Quit: leaving]
zsparks has joined #ocaml
zsparks has quit [Ping timeout: 246 seconds]
zsparks has joined #ocaml
Tobu has quit [Ping timeout: 248 seconds]
edwin has quit [Remote host closed the connection]
Cyanure has quit [Remote host closed the connection]
kerneis has quit [Read error: Operation timed out]
kerneis has joined #ocaml
sepp2k has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
patronus has joined #ocaml
pdhborges has joined #ocaml
zsparks has quit [Ping timeout: 276 seconds]
patronus_ has quit [Ping timeout: 240 seconds]
Yoric has quit [Quit: Leaving.]
Tobu has joined #ocaml
ymasory has joined #ocaml
zsparks has joined #ocaml
ymasory has quit [Quit: Leaving]
<pdhborges>
thelema_: hi, is the doc dir deprecated?
ikaros has quit [Quit: Ex-Chat]
fschwidom has quit [Remote host closed the connection]
enthymeme has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
<thelema_>
pdhborges: mostly
<pdhborges>
thelema_: if the relevant content was added to the wiki would you delete it?
fraggle_ has joined #ocaml
Amorphous has quit [Ping timeout: 276 seconds]
impy has quit [Quit: impy]
impy has joined #ocaml
Amorphous has joined #ocaml
EM03 has joined #ocaml
<EM03>
anyone got a few moments for some theory talk?