<adrien_>
-rw-r--r-- 1 root root 954226 Oct 22 2011 /opt/ocaml/lib/ocaml/std-lib/stdlib.a
ggole has joined #ocaml
introom has joined #ocaml
introom has quit [Remote host closed the connection]
introom has joined #ocaml
ollehar has joined #ocaml
bernardofpc has quit [Quit: leaving]
bernardofpc has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
osnr has quit [Ping timeout: 276 seconds]
<mrvn_>
How do I specify implicit subtyping for methods in a class type?
<mrvn_>
class type foo = object method foo : string end and bar = object inherit foo method bar : string end and t = object method push : #foo -> unit end;;
<mrvn_>
The method push has type (#foo as 'a) -> unit where 'a is unbound
<mrvn_>
method push : 'a . (#foo as 'a) -> unit ==> The universal type variable 'a cannot be generalized: it escapes its scope.
mrvn_ is now known as mrvn
breakds has joined #ocaml
cdidd has joined #ocaml
<mrvn>
Damn, the problem seems to be the "and"
<ggole>
Don't you need a type variable argument for that?
<mrvn>
ggole: 'a . (#foo as 'a) -> unit?
<ggole>
Uh
<ggole>
Let's see
<ggole>
class type foo = object method foo : string end and bar = object inherit foo method bar : string end and ['a] t = object constraint 'a = #foo method push : #foo -> unit end
<ggole>
Type checks: I'm not sure if it is what you want though
<mrvn>
That wouldn't subtype the argument. That just creates different types depending on the argument.
<ggole>
Oh, hmm
<mrvn>
ggole: t#push (new foo) and t#push (new bar) need to work.
<mrvn>
t#push ((new bar) :> foo) is anyoing to type.
<ggole>
Right.
<mrvn>
It works fine if I declare each class type on its own. But if I declare them as a group with "and" it fails.
<mrvn>
And I have a recursion between the two classes so they need "and"
csakatoku has joined #ocaml
clog has joined #ocaml
<adrien_>
hmm, I can't remember for sure: when linking against a pack, is the whole pack always fully pulled?
csakatoku has quit [Remote host closed the connection]
<mrvn>
lets see what the mailinglist says to my problem
<pippijn>
adrien_: bytecode or native?
<adrien_>
native
<pippijn>
then I don't think so
<pippijn>
I suppose it goes to the system linker, which links only reachable symbols
<pippijn>
not reachable, referenced
<whitequark>
pippijn: won't that be the same? reachable from toplevel
<pippijn>
if false then unreachable ()
<whitequark>
well, this depends on your definition of "reachable" :)
<pippijn>
just wanted to make sure
<whitequark>
it's a bikeshed anyway.
<whitequark>
also do you have some time?
<pippijn>
a little bit
<whitequark>
good
<mrvn>
pippijn: well, false might be true one day :)
<whitequark>
pippijn: the Cyclone paper mentioned that they needed to manually set function effects, though only once in 100KLOC
<whitequark>
do you happen to know why? I couldn't reaily imagine a case where this would be neede
<whitequark>
*needed.
<pippijn>
whitequark: sorry, can you remind me of what effects are here?
<pippijn>
it's been some years since I touched that
<adrien_>
hmm, I believe the whole pack is pulled
<whitequark>
pippijn: as I understand it: the list of regions which the function may touch. by default Cyclone infers effects as just a set of regions occuring in the signature
<whitequark>
since it only has the heap and LIFO arenas, I don't see why that wouldn't suffice for anything
<mrvn>
ggole: makes for ugly types in errors though.
<pippijn>
whitequark: I don't know
<pippijn>
whitequark: let me check my code
ollehar has quit [Ping timeout: 252 seconds]
<pippijn>
I seem to have some explicit heap region annotations
<whitequark>
hmm
<pippijn>
whitequark: sorry, I don't remember why it's required
<pippijn>
maybe it's just a compiler weakness
<whitequark>
I can see why you would want to annotate your code with a heap region
<whitequark>
no, not like that
<ggole>
mrvn: mmm, I can't see how to do it
<pippijn>
I think you need it for arguments
<whitequark>
I can see why effects in heap region may require explicit annotations
<ggole>
Not that my object-fu is particularly strong
<whitequark>
looking at the inference algorithm
<mrvn>
ggole: I think it is a bug in the type system that it fails with "and"
<ggole>
If you separate it so that foo and bar recur, but t does not, it type checks
<ggole>
But it will just fail later when you try to define a class of type t
csakatoku has joined #ocaml
<mrvn>
ggole: foo and bar aren't recursive, that is just plain inheritance.
<mrvn>
foo and t are recusrive (or w and t in my last paste)
<ggole>
Right
avsm has joined #ocaml
Neros has joined #ocaml
csakatoku has quit [Ping timeout: 264 seconds]
csakatoku has joined #ocaml
dsheets has joined #ocaml
tobiasBora has quit [Read error: Connection reset by peer]
tobiasBora has joined #ocaml
jbrown has quit [Remote host closed the connection]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
osnr has quit [Ping timeout: 246 seconds]
mye has quit [Quit: mye]
<orbitz>
Generic question: when tokenizing something, take for example JSON, does the tokenizer know about strings and escapesequences and all that?
<whitequark>
yes
<orbitz>
A better phrasing of my question: string literals are 1 token, correct?
<mrvn>
usualy
<pippijn>
orbitz: not necessarily
<orbitz>
i thin kfor my needs it makes sense
<mrvn>
"foo" BAR "baz" in C would be multiple tokens
<pippijn>
orbitz: it should know enough about escaping to know when a string starts and ends
<pippijn>
that's it
<pippijn>
it doesn't need to know \n or so
<orbitz>
ok
<mrvn>
then again that would be 3 string literals with string concatenation
<pippijn>
so you can match it with "([^"]|\\.)*"
<mrvn>
orbitz: often you have a special case in your tokenizer for strings and comments. It's hard / impossible to do them with normal regexps.
<pippijn>
[^"\\]
<pippijn>
for comments, if you have nested ones, yes
<pippijn>
or if you have funny rules like "*)" is not the end of a comment
<whitequark>
mrvn: macros don't exist in C at the tokenization time
<whitequark>
so "foo" BAR "baz" is a syntax error :)
<mrvn>
whitequark: cpp tokenizes too
<whitequark>
but it doesn't concatenate strings I think
<whitequark>
so there's no reason for "foo" "bar" to be a single token either
<orbitz>
I'm not sure discussing the semantics of C are necessarily a productive use of our time :) thank you for the help
amirmc has joined #ocaml
introom has quit [Remote host closed the connection]
<mrvn>
you should ask on a channel about dns server
<mrvn>
ups
tobiasBora has quit [Quit: Konversation terminated!]
ollehar has joined #ocaml
<wmeyer`>
orbitz: the lexer in ocaml is more than just regexp matcher, it allows to build non backtracking finite state machine.
<wmeyer`>
because rules can be called explicitly from each production
amirmc has quit [Quit: Leaving.]
amirmc has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
demonimin has quit [Ping timeout: 256 seconds]
ollehar has quit [Ping timeout: 246 seconds]
demonimin has joined #ocaml
avsm has quit [Ping timeout: 264 seconds]
dsheets has quit [Ping timeout: 245 seconds]
amirmc has quit [Ping timeout: 246 seconds]
ulfdoz has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
iZsh has quit [Quit: Coyote finally caught me]
osnr has quit [Ping timeout: 245 seconds]
tane has joined #ocaml
ulfdoz has quit [Ping timeout: 260 seconds]
snearch has joined #ocaml
Anarchos has joined #ocaml
<Anarchos>
how can i do a full compact right after each call to an external C function linked with ocaml ?
<mrvn>
let fn arg = let res = c_fn arg in Gc.compact (); res
<Anarchos>
mrvn i would prefer to insert this in the interp.c file , just after C_CALL1.... C_CALLN
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
osnr has quit [Client Quit]
csakatoku has quit [Remote host closed the connection]
avsm has joined #ocaml
osa1 has quit [Ping timeout: 276 seconds]
<jpdeplaix>
avsm: Is that your debian repo is down ? I have a 404 :/
<Anarchos>
/join ocaml-fr
<avsm>
jpdeplaix: i've got an ubuntu one. not had a chance to rebuild the debian one yet.
<avsm>
jpdeplaix: i really hope the debian NEW queue unblocks soon. OPAM's been stuck in the incoming queue there for over a month. http://ftp-master.debian.org/new.html
ulfdoz has joined #ocaml
<jpdeplaix>
avsm: ok, so do we switch to the ubuntu repo ?
<avsm>
jpdeplaix: i'm not entirely sure. looks like libc has had a bump, so it doesn't cleanly work on wheezy
<avsm>
but apt-get -t experimental on wheezy bumps the libc and lets it work
* Anarchos
whishes to be skilled enough to debug the GC...
ollehar has joined #ocaml
<avsm>
i've gone back to source installs on debian until i've had a chance to figure it out (or someone else tells me what the right thing to do is)
csakatoku has joined #ocaml
dsheets has joined #ocaml
<jpdeplaix>
avsm: it seems to work on sid
ivan\ has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<avsm>
confusing. any chance you could reply to the ppa thread (preferably just cc opam-devel, not the caml-list_ with your findings?
Drup has quit [Ping timeout: 240 seconds]
ulfdoz has quit [Ping timeout: 264 seconds]
csakatoku has quit [Remote host closed the connection]
osa1 has joined #ocaml
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
iZsh has joined #ocaml
gnuvince- has joined #ocaml
ulfdoz has joined #ocaml
csakatoku has joined #ocaml
darkf has quit [Quit: Leaving]
avsm has quit [Quit: Leaving.]
csakatoku has quit [Ping timeout: 248 seconds]
ggole has quit []
osa1 has quit [Ping timeout: 246 seconds]
yacks has joined #ocaml
gnuvince- has quit [Changing host]
gnuvince- has joined #ocaml
gnuvince- is now known as gnuvince
chris2 has quit [Ping timeout: 246 seconds]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
snearch has quit [Quit: Verlassend]
pkrnj has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
ollehar has joined #ocaml
mfp has joined #ocaml
osa1 has joined #ocaml
bondar has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
<wmeyer`>
adrien: ping
<Anarchos>
wmeyer` pong..
<osa1>
what's wrong with exception declaration: exception 'a NonLocalPoly of 'a ?
csakatoku has joined #ocaml
<mrvn>
osa1: that would require runtime types
<osa1>
mrvn: um .. how?
<mrvn>
how do you want to use the 'a without knowing the type?
<osa1>
mrvn: how do you know 'a in list type?
csakatoku has quit [Ping timeout: 260 seconds]
<mrvn>
osa1: type inference. But you can't do that when catching an exception.
<osa1>
yeah I pasted that link for myself, I'm not 100% sure about OCaml terms
<orbitz>
I think in ocaml and an adt == variant == what haskell calls an adt
<mrvn>
In the Janestreet link why does 'a return need to be a polymorphic record?
<orbitz>
isn't it because it's meant to be generic? they say yo udon't need it if you use it in one place but they want it to work everywhere
Drup has joined #ocaml
<def-lkb_>
mrvn: record are the usual way to introduce explicit quantification
Snark has quit [Quit: leaving]
<def-lkb_>
mrvn: and we need that polymorphism so that r.return can be used in any context (after application, it has the type forall 'a. 'a)
<mrvn>
but why do you need that?
<mrvn>
with_return should always return the 'a type, unless you do that broken thing of having the return escape its scope.
<mrvn>
def-lkb_: I'm looking for an example where return doesn't escape but it still doesn't work without the 'b
<def-lkb_>
mmm, but the purpose of return is escaping?
<mrvn>
no
<def-lkb_>
(and it is not possible to produce a value of that type without escaping or looping)
<mrvn>
def-lkb_: The return is supposed to be used up in the function passwd to with_return
<mrvn>
def-lkb_: Look at the last example on https://ocaml.janestreet.com/?q=node/91. If it escapes all you can do is throw an uncatchable exception.
<def-lkb_>
mrvn: yes… by escape I meant escaping the local stack-frame up to the enclosing with_return
kaustuv has joined #ocaml
<mrvn>
def-lkb_: but I got it. Say you have a string return and code like this: ... if foo then r.return "" else 5 ...
<osa1>
I'm wondering how can we get a similar effect of exceptions used as non-local returns in a purely functional settings without exceptions. with exceptions we can return from arbitrarily nested contexts(i.e. function calls), this is not easily possible in functional setting, without using Error monad transformers etc. like we do in Haskell ...
<mrvn>
r.return never returns so its return type can unify with int.
<orbitz>
osa1: I use Core's Result monad quite a bit
<def-lkb_>
osa1: with delimited continuations ?
<mrvn>
osa1: by match f ... with Exception x -> Exception x | Restult y -> ...
<osa1>
orbitz: hmm that's same thing as ErrorT in Haskell, I guess?
<mrvn>
osa1: on every level
<orbitz>
osa1: I don't know about ErrorT, but it's effeivelty the Either monad
<osa1>
mrvn: yeah currently that's how we do in Haskell (implicitly using monads, or explicitly)
<kaustuv>
In an opam package, can I copy an entire directory using a .install file? E.g., can I say:
<kaustuv>
share: ["examples"]
<def-lkb_>
mrvn: precisely, sorry I wasn't able to make this use case more explicit, but it's exactly the purpose of this extra amount of polymorphism
<osa1>
orbitz: right
<kaustuv>
and have it copy foo.0.0/examples to share/foo/examples ?
<osa1>
hmm, I've never thought of delimited continuations ..
<orbitz>
osa1: what problem are you tryingto solve
<mrvn>
what are delimited continuations?
<mrvn>
osa1: I would just implement exceptions by passing an exception handler as extra continuation.
<osa1>
orbitz: I don't have a problem in mind, I'm just exercising, I guess
<mrvn>
let fn cont raise arg = if arg then cont 0 else raise Foo;;
<mrvn>
raise `Foo even
<osa1>
mrvn: that's a good idea. delimited continuation solution is also similar as the idea, I think
<mrvn>
def-lkb_: but what are delimited continuations?
<osa1>
I know normal continuations(implemented them in an interpreter, none of the expressions were returning anything, return values were passed to continuations etc.), are delimited ones too different?
<def-lkb_>
delimited ones behave more like functions: instead of capturing the complete stack of execution, delimited continuations are built with control operators that permit to restrict the extent
<mrvn>
The implementation sounds downright evil.
<mrvn>
Messing wiht the stack and all
<osa1>
mrvn: you're not thinking in terms of stack while implementing. implementation is actually very easy in high level languages.
<def-lkb_>
yes, delimited continuation are built by capturing a chunk of stack
<osa1>
mrvn: I had implemented a language with non-delimited continuations in Haskell, if you're interested http://github.com/osa1/toylisp it has call/cc
<mrvn>
osa1: normal continuations are simple. That is just a closure.
<mrvn>
or in haskell you have monads
kaustuv has left #ocaml []
<mrvn>
Say I have a functor, e.g. Set, and I use int Set at several points in my code. Should I create a global module IntSet or instantiate the functor where needed?
* osa1
has a final exam in few hours and will continue investigating non-local returns later ...
<mrvn>
You can't have a ocaml value without the runtime system lock
<mrvn>
and interne must be initialized before being added as root I believe
<Anarchos>
mrvn this C++ constructor is called in a callback so i own the runtime system lock
<Anarchos>
mrvn the problem is htis initialization i think
<mrvn>
then what is the caml_acquire_runtime_system() doing there? That will deadlock.
<Anarchos>
mrvn good point...
<mrvn>
looks more like it is called from a C thread that the ocaml runtime knows nothing about: caml_c_thread_register();
<Anarchos>
mrvn yes sorry you're really right
<Anarchos>
you mean i should call caml_c_thread_register then caml_acquire_runtime_system then CAMLparam ?
<mrvn>
hmm, haden't even thought of that. what do the docs say?
<Anarchos>
mrvn nothing apart that caml_c_thread_register is used to register C threads to the runtime system
<mrvn>
I'm not sure you can do CAMLparam1 later in the function.
<mrvn>
But I would think that needs the runtime lock
<Anarchos>
mrvn ok thank you i will investigate more
avsm has quit [Quit: Leaving.]
<mrvn>
maybe split the function in 2. Glue::Glue(value ocaml_objet) { caml_c_thread_register(); caml_acquire_runtime_system(); self.Glue_with_lock(ocaml_objet); caml_release_runtime_system(); } Glue::Glue_with_lock(value ocaml_objet) { CAMLparam1(ocaml_objet); interne = ocaml_objet; caml_register_global_root(&interne); CAMLreturn0; }
<Anarchos>
mrvn i am not sure if the "interne = ocaml_objet; " is correct to do the assignment in the global root interne, to trnasform ocaml_objet in a global root
<mrvn>
interne = 0; works too.
<mrvn>
or Val_unit
<mrvn>
Anyhing the GC won't get confused about.
<mrvn>
Where does the ocaml_objet come from? Because without the runtime lock that value isn't valid so you can't pass it to another function.
<Anarchos>
mrvn ocaml_objet is an OCaml classes that i want to mimic in the C++ side...
<Anarchos>
the ocaml runtime makes a callback in C which calls this C++ class
<mrvn>
If it comes from ocaml then it has the ocaml runtime lock. Call Glue() then before giving it up
<Anarchos>
mrvn i will try your solution :)
<mrvn>
Getting it to run cleanly with a mixture of ocaml and c threads will be hard to test.
<Anarchos>
mrvn i have a graphical application wich runs pretty smoothly
<Anarchos>
with 3 threads
<Anarchos>
time to go to bed
Anarchos has quit [Quit: Vision[0.9.7-H-130604]: i've been blurred!]