mfp changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.11.2 released | Inscription for OCaml Meeting 2010 is opened http://wiki.cocan.org/events/europe/ocamlmeetingparis2010
naufraghi has quit [Quit: naufraghi]
Drk-Sd has joined #ocaml
suricator has joined #ocaml
<suricator> Hi guys, i am trying to compile a program which starts with "open Unix"... but i get the error "Error: No implementations provided for the following modules: Unix referenced from server.cmx". Any thoughts?
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
_unK has quit [Remote host closed the connection]
suricator has quit [Quit: suricator]
valross has joined #ocaml
yakischloba has quit [Quit: Leaving.]
elehack has joined #ocaml
threeve has joined #ocaml
tmaedaZ is now known as tmaeda
quidnunc has joined #ocaml
enthymene has quit [Quit: commute!]
yakischloba has joined #ocaml
jeddhaberstro has joined #ocaml
orbitz has quit [Ping timeout: 264 seconds]
Drk-Sd has quit [Read error: Connection reset by peer]
orbitz has joined #ocaml
Drk-Sd has joined #ocaml
yakischloba has quit [Quit: Leaving.]
mutew has quit [Ping timeout: 268 seconds]
quidnunc has quit [Read error: Connection reset by peer]
maskd has quit [Quit: leaving]
yakischloba has joined #ocaml
elehack has quit [Quit: Goodbye...]
Mr_Awesome has joined #ocaml
companion_cube has quit [Ping timeout: 256 seconds]
jeddhaberstro has quit [Quit: jeddhaberstro]
companion_cube has joined #ocaml
Drk-Sd has quit [Quit: dodo.]
enthymene has joined #ocaml
orbitz_ has joined #ocaml
orbitz has quit [Ping timeout: 245 seconds]
orbitz_ has quit [Ping timeout: 246 seconds]
bzzbzz has quit [Quit: leaving]
orbitz has joined #ocaml
Modius_ has quit [Quit: I'm big in Japan]
Modius has joined #ocaml
Modius has quit [Max SendQ exceeded]
Modius has joined #ocaml
joewilliams_away has left #ocaml []
cognizant-cog has joined #ocaml
synod has joined #ocaml
synod has quit [Client Quit]
synod has joined #ocaml
cognizant-cog has quit [Quit: ChatZilla 0.9.86 [Firefox 3.5.8/20100214235838]]
<synod> Can an object method be openly polymorphic in a type variable that the class hasn't bound?
<synod> I've a collection-like class representing a metric space with a polymorphic fold function. The compiler complains that the type variable is unbound. What gives?
yakischloba has quit [Quit: Leaving.]
threeve has quit [Quit: threeve]
<synod> Ok, how about map? Can you write a map method that transforms a polymorphic class of one type to another?
yakischloba has joined #ocaml
mutew has joined #ocaml
ulfdoz has joined #ocaml
<det> synod, more specific on that last example ?
<synod> det: I have a type 'a collection and I'd like to do a#map (fn : 'a -> 'b) : 'b collection
<synod> I don't particularly care about descendent classes wanting self-type back, so a new collection is ok
<synod> I have the polymorphic fold and now I'm trying to write the map in terms of the fold but it won't type.
<det> what is the type error
<synod> it wants to be ('a -> 'a) -> 'a collection
<synod> and when I try to type it explicitly, i get syntax errors in "method map : 'b collection. ('a -> 'b) -> 'b collection"
<synod> specifically at the period
<synod> or the type parameter
<synod> I've tried parens, too
<det> you dont want collect on the left of the period
<synod> no? doesn't map return a 'b collection?
<det> Im not sure you need that kind of typing anyways
<det> can you paste your code somewhere
<synod> sure
<synod> one sec
<det> anyways, you specify type variables on the left of the period, not types
<det> that program compiles for me
<synod> det: yes, except the type of map is ('a -> 'a)...
<det> if I remove the reference to euclidean
<synod> ah sorry
<synod> if I explicitly type map, I get "This type scheme cannot quantify 'b : it escapes this scope"
<synod> when I use the period correctly @_@
<det> I will brb in a few
<synod> ok np
mutew has quit [Ping timeout: 264 seconds]
<det> back
<det> Why dont you use List.fold_left ?
<det> method fold f accu = List.fold_left f accu points
<det> seems to be equiv to your fold
<synod> yes, it is... my fold used to pass subspaces into f
<synod> it should probably be List.fold_left
<synod> even if I pass subspaces... I can wrap f
<det> why use objects anyways ?
<synod> ahahaha... indeed
<synod> this used to be a record
<synod> I went to objects because... it seemed to make more sense?
<synod> My record was accumulating various functions and hash table indexes
<det> why not a module ?
<synod> and I wanted to build dynamically updating subspaces
<synod> how would I carry the state in a module? a record?
<flux> synod, did you resolve the problem yet?
<synod> do I use module-level indexes then?
<synod> flux: nope
<flux> synod, you can have this: class foo = object method identity : 'a. 'a -> 'a = fun a -> a end
<flux> (or for more type variables: method map: 'a 'b. ('a -> 'b) -> 'a list -> 'b list = fun .. )
<synod> flux: thanks. that's basically what i did to get fold to type (though just using List.fold_left as det recommended is better)
<flux> oh right, I missed that
<det> you can carry state in a record, yes
<det> it can be mutable or immutable
<flux> hmm, I wonder if you can use constraints in that, I think not
<synod> det: ok, i think that's basically what i used to have unless you're suggesting i move the polymorphism from the record type to the module as a functor?
<det> You can certainly type this using objects, I just dont understand the need to use objects
<flux> using modules has the advantage of that you can put types (and other modules) inside them
<flux> and the main disadvantage (they are not first class) goes away then ocaml 3.12 comes..
<flux> the more cumbersome syntax/scoping issue still remains, if that's an issue at all
infoe has quit [Ping timeout: 265 seconds]
<det> oh, you want a generic connection class ?
<synod> det: it's not strictly necessary... i was doing fine with a record and some functions until I decided my record looked a lot like an object and I was tired of writing awkward Space.add s pt stuff everywhere
<det> Do you really need this generic connection class ?
<synod> det: generic connection class?
<det> <synod> det: I have a type 'a collection and I'd like to do a#map (fn : 'a -> 'b) : 'b collection
<synod> ah collection
<synod> it's actually a generic metric space class
<synod> but it functions basically like a collection with some further membership constraints and some special search methods based on spatial indexes
<synod> and yes, i'd like it to be generic... I need to map operation from spaces of one type to spaces of another
<synod> i think i'm going to ditch the object stuff and go back to the record... map was supersimple
<det> This is probably best
<det> I dont think you are using any features of the object system
<synod> not other than better method-like functions and the ability to reference self...
<det> Your code is confusing too
<synod> but you are correct, everything i need is expressible with records
infoe has joined #ocaml
<synod> det: how so?
<det> what is add supposed to do
naufraghi has joined #ocaml
<synod> det: add a point to the space's point set?
<det> it doesnt though
<synod> o_O
<det> or maybe I misunderstand the syntax
<synod> no mutation...
<det> {< >} copies the current object?
<synod> so technically it makes a new space with a point set containing another point
<synod> yes
<synod> it is like record's { blah with foo = bar } but respecting subclasses
avsm has joined #ocaml
<det> Ok, I cant figure out how to make map type with your object example
<synod> det: ok. i think polymorphic classes are just unfriendly to bind-like operations because the class type closes the type variable
<det> I think the problem is that is is used recursively
<synod> a class user can't write a function that maps the internal state at all so you have to create a new object anyway
<mrvn> If you don't need inheritance then skip objects.
<synod> which is a cludge
<mrvn> synod: with functional style you create a new one anyway.
<synod> mrvn: new via "new" not new memory
<synod> mrvn: which breaks your inheritance behavior
<mrvn> synod: sure, the output won't have the same inheritance.
<mrvn> Unless the map function is a member function of the class that does so.
<mrvn> (fun x -> x#map)
<synod> mrvn: huh? you still can't write a generic 'a -> 'b map with that
<mrvn> synod: Sure. The map function itself is pretty simple.
seafood has joined #ocaml
<mrvn> create empty output type, iterate over input type, apply f and insert the result into the output
<synod> mrvn: you are where det was 15 min ago
<synod> mrvn: if you are in a 'a collection, you cannot write a map method that takes a ('a -> 'b) and gives you a 'b collection
<synod> at least not without something very sneaky -- the naive approach types the fn arg of map to ('a -> 'a)
<det> I'll break it down into a simple example
<mrvn> synod: You need a create method that is 'a. unit -> 'a
<mrvn> got to catch a train, back in an hour.
ttamttam has joined #ocaml
<synod> This fails: class ['a] collect lst = object (self) val lst : 'a list = lst method map : 'b. ('a -> 'b) -> 'b collect = fun fn -> (new collect (List.map fn lst)) end;;
<synod> without explicitly typing the map method, map only takes 'a -> 'a
<synod> and still breaks inheritance
<synod> anyway, i've got to go home, thanks det
<det> Bye
Yoric has joined #ocaml
<det> I would expect to type that as:
<det> method map: 'b. ('a -> 'b) -> 'b seq = fun f ->
<det> but Ocaml complains:
<det> Error: This type scheme cannot quantify 'b : it escapes this scope.
ulfdoz has quit [Ping timeout: 260 seconds]
<flux> I think the problem is that 'a and 'b might get remapped before that error
enthymene has quit [Quit: rcirc on GNU Emacs 23.1.1]
<flux> try what happens with: method map: 'c. ('a -> 'c) -> 'c seq = fun f ->
<flux> actually I think it's complaining about that 'a. but pastebin.ca is being superslow on me, can't see the code :)
Submarine has joined #ocaml
<det> remapping isnt the problem
yakischloba has quit [Quit: Leaving.]
avsm has quit [Quit: Leaving.]
<flux> soo, that works, bt doesn't do what you want?
<det> it forces the type from 'a -> 'a
<det> map should be 'a -> 'b
<det> but how can you give it that type ?
Gooffy has joined #ocaml
<det> You can forget all code even, and just try to declare a class type with the desired code
<det> aka
<det> class type ['a] a_seq = object
<det> val xs : 'a list
<det> method map : 'c. ('a -> 'c) -> 'c a_seq
<det> method prepend : 'a -> a_seq
<det> end
<det> which Ocaml complains about
<det> and I think prepend should be -> 'a a_seq
<det> in fact you can forget all types except the one for map
Yoric has quit [Quit: Yoric]
<mrvn> re
<det> re ?
<mrvn> I arrived at work
<det> oh ok
<mrvn> det: The problem is that in signatures you can't have 'a. ...
<mrvn> class ['a] seq = object method map : 'b. ('a -> 'b) -> 'a seq = fun f -> new seq
<mrvn> end;;
<mrvn> class ['a] seq : object method map : ('a -> 'b) -> 'a seq end
<mrvn> Notice how the 'a. disapears?
<det> that is the wrong type
<det> you want to return 'b seq
<mrvn> I know. Just to demonstrate the 'a. disapearing
<mrvn> or rather 'b.
ikaros has joined #ocaml
Submarine has quit [Ping timeout: 264 seconds]
jonafan has quit [Read error: Connection reset by peer]
<det> this isnt about that though
<det> how can you give map the correct type ?
<det> the inferred type isn't what you want
<det> this is the case with fold as well, but annotations solves the fold case, annotations to the map case makes ocaml complain
<mrvn> class ['a] seq = object method map : 'b. (int -> 'b) -> 'b = fun f -> Obj.magic 0 end;;
<mrvn> class ['a] seq = object method map : 'b. ('a -> 'b) -> 'b seq = fun f -> Obj.magic 0 end;;
<mrvn> Why does the second one give an error?
_zack has joined #ocaml
<det> because 'b is being used as a parameter to seq
<det> which is recusrive
<mrvn> I have an inkling you need object (self : 'self) here but 'self isn't polymorphic then.
seafood has quit [Quit: seafood]
seafood has joined #ocaml
domiel has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
seafood has quit [Quit: seafood]
Yoric has joined #ocaml
Mr_Awesome has quit [Ping timeout: 265 seconds]
Mr_Awesome has joined #ocaml
Mr_Awesome has quit [Read error: Connection reset by peer]
avsm has joined #ocaml
mehdid has joined #ocaml
boscop has quit [Read error: Connection reset by peer]
_unK has joined #ocaml
rwmjones has quit [Quit: Terminated with extreme prejudice - dircproxy 1.2.0]
rwmjones has joined #ocaml
maskd has joined #ocaml
<flux> albeit it might be a bit unwieldly for a real program :)
<flux> perhaps an interactive graph explorer?
ulfdoz has joined #ocaml
avsm has quit [Ping timeout: 252 seconds]
avsm has joined #ocaml
<flux> I fed my irc protocol parsers to it and even that looks quite large..
avsm has quit [Ping timeout: 265 seconds]
avsm has joined #ocaml
Mr_Awesome has joined #ocaml
ulfdoz has quit [Ping timeout: 276 seconds]
Associat0r has joined #ocaml
Associat0r has quit [Client Quit]
Drk-Sd has joined #ocaml
valross has quit [Quit: Ex-Chat]
_andre has joined #ocaml
seafood has joined #ocaml
avsm has quit [Ping timeout: 260 seconds]
naufraghi has quit [Ping timeout: 265 seconds]
avsm has joined #ocaml
naufraghi has joined #ocaml
pimmhogeling has joined #ocaml
TaXules has joined #ocaml
Alpounet has joined #ocaml
bzzbzz has joined #ocaml
mutew has joined #ocaml
seafood has quit [Quit: seafood]
avsm has quit [Ping timeout: 260 seconds]
beaver has joined #ocaml
mutew has quit [Ping timeout: 245 seconds]
beaver has left #ocaml []
avsm has joined #ocaml
avsm has quit [Ping timeout: 246 seconds]
jao has joined #ocaml
Submarine_ has joined #ocaml
avsm has joined #ocaml
boscop has joined #ocaml
<flux> if derdon comes back, maybe someone could point him towards that piece of software, because it appears to do a lot of what he wants
<flux> I think it uses the ocaml sources to do that, because those are rqeuired during the build process
<flux> it refers to some (for example) Parse.implementation which doesn't appear to come from itself (oug)
threeve has joined #ocaml
Drk-Sd has quit [Quit: {'EXIT', Drk-Sd, "bye"}]
yakischloba has joined #ocaml
mehdid has quit [Ping timeout: 276 seconds]
yakischloba has quit [Client Quit]
<rwmjones> does Dario Teixeira ever show up on here?
Modius has quit [Quit: I'm big in Japan]
mehdid has joined #ocaml
domiel has quit [Quit: Ex-Chat]
jonafan has joined #ocaml
avsm has quit [Ping timeout: 256 seconds]
mehdid has quit [Quit: leaving]
mehdid has joined #ocaml
joewilliams has joined #ocaml
joewilliams has quit [Client Quit]
derdon has joined #ocaml
joewilliams has joined #ocaml
joewilliams has quit [Client Quit]
joewilliams_away has joined #ocaml
joewilliams_away has left #ocaml []
ccasin has joined #ocaml
yakischloba has joined #ocaml
Gooffy has quit [Quit: Leaving.]
ikaros has joined #ocaml
ikaros has quit [Client Quit]
tmaeda is now known as tmaedaZ
avsm has joined #ocaml
jao has quit [Ping timeout: 264 seconds]
ttamttam has quit [Quit: Leaving.]
f[x] has quit [Ping timeout: 248 seconds]
joewilliams_away has joined #ocaml
joewilliams_away is now known as joewilliams
Submarine_ has quit [Ping timeout: 240 seconds]
Yoric has quit [Quit: Yoric]
Drk-Sd has joined #ocaml
<derdon> can anyone explain this odd output to me? http://paste.pocoo.org/show/182128/
_zack has quit [Quit: Leaving.]
<thelema> integer overflow?
<mrvn> Error: Unbound value range
<mrvn> # fac 20;;
<mrvn> - : int = 2432902008176640000
<mrvn> # fac 21;;
<mrvn> - : int = -4249290049419214848
<mrvn> Overflows later on 64bit systems.
Submarine has joined #ocaml
naufraghi_ has joined #ocaml
Submarine has quit [Client Quit]
Submarine has joined #ocaml
naufraghi has quit [Ping timeout: 265 seconds]
naufraghi_ is now known as naufraghi
enthymene has joined #ocaml
<derdon> thelema: how can I avoid it?
<thelema> derdon: Big_int?
<derdon> thelema: ah, right
<derdon> thx
<thelema> np
olegfink has quit [Quit: WeeChat 0.2.6.3]
olegfink has joined #ocaml
olegfink has quit [Client Quit]
olegfink has joined #ocaml
* mrvn would avoid it by not calling fac with large values
* mrvn just had an evil idea. Passing a C function from one module to another with type 'a c_pointer, A.get_c_fun : unit -> (unit -> char c_pointer), B.loop : (unit -> char c_pointer) -> unit.
<mrvn> The C stub in B should call a C stub from A.
<mrvn> (unit -> char c_pointer) c_pointer actually.
<mrvn> char *fn(void)
<flux> hmm
ulfdoz has joined #ocaml
lokydor has joined #ocaml
<flux> module Native : sig type 'a ptr type symbol = string type 'a signature val int : symbol -> int ptr val fn : 'a signature -> symbol -> 'a fun_ptr .. (* signature construction fns etc *) end
<flux> but actually perhaps a good idea is to look at what's been already done
<flux> what was that ocaml lib that allowed embedding C-code?
<mrvn> That would look up a symbol at runtime?
<flux> yes, dlopen or something
<mrvn> Mine was simpler. A provides the pointer and B takes it.
<flux> although I suppose something for binding an .o-file would be interesting as well, at link time
<mrvn> Can you have external foo : somethin = "symbol"?
<flux> yes
<flux> but of course, if you are referring to c libs, the code needs to be ocaml-aware
<flux> except in very narrow special cases perhaps (sin?)
<mrvn> external my_c_fun : (unit -> char c_pointer) c_pointer = "my_c_fun"
<mrvn> No need for a A.get_c_fun ()
<flux> but instead A.call A.my_c_fun () ?
<mrvn> flux: The value is to be used in another C stub.
<flux> ah, ok
Yoric has joined #ocaml
<mrvn> value other(value ml_fn) { allocator_t fn = (allocator_t)ml_fn; char *mem = fn(); }
<mrvn> Or would you write that stub as value other(allocator_t fn)?
Yoric has quit [Client Quit]
<flux> hmm, libaio's svn last commit message: gildor-admin Move to git
<flux> it would be darn nice to give the git url there also :)
<mrvn> indeed
<mrvn> url = ssh://goswin@git.ocamlcore.org/gitroot/libaio-ocaml/libaio-ocaml.git
<flux> ssh://-prefix not good for me
<mrvn> url = git+ssh://goswin-guest@git.debian.org/git/pkg-ocaml-maint/packages/libaio-ocaml.git
<mrvn> No account there?
<flux> does that work for plain git also?
<flux> actually I might have ocamlcore account, hmm..
<flux> hah, yes
<mrvn> It works somehow but I think then the path differs.
<mrvn> You need git.d.o if you want to build debs.
<mrvn> use the project overview to get the url for anon access.
<flux> hmph, svn change history not imported
<flux> ssh worked fine
sshc has quit [Quit: leaving]
sshc_ has quit [Quit: leaving]
sshc has joined #ocaml
<mrvn> flux: There where only 9 commits total and 7 of them typo style changes.
<flux> well yeah ;)
<mrvn> For libfuse I need a way to allocate a buffer in such a way that the later write() callback will have a properly aligned Bigarray for libaio. That's where I was thinking of using the "pass a C pointer around" hack.
<mrvn> flux: Any idea how to do Bigarray.Array1.sub in C?
pad has joined #ocaml
<flux> no idea. look at the source?
<flux> should be pretty simple I think..
<mrvn> probably. I hate that the caml docs are always only half complete.
slash_ has joined #ocaml
<mrvn> This gets slightly tricky. The fuse main loop allocates a buffer, reads the requests, parses it and calls the right callback. In most cases the callback copies the contents and calls the ocaml function for the callback. Except for write(), there the ocaml callback gets a Bigarray referencing the data directly to safe on copying. But then the buffer must remain valid as long as the ocaml code holds a reference to the Bigarra
Yoric has joined #ocaml
* mrvn has to learn about htread-local-storage.
<mrvn> s/ht/th/
<flux> thelema, does batteries work with a custom toplevel? (with the custom ~/.ocamlinit) I'm just trying something out and I got a bunch of errors on startup..
ccasin has quit [Quit: Leaving]
<mrvn> hmm TLS is easy. Just add __thread. :)
Yoric has quit [Quit: Yoric]
<mrvn> Just to be sure: When I compile ocaml code with -thread then a C stub can use TLS and get a a thread local variable per ocaml thread, right?
<flux> I wouldn't be so sure about that
<flux> what about green threads?
<flux> I don't think they are threads according to that model
<flux> however, for native compilation I think it should work.. (test first ;-))
<flux> maybe you can support not having TLS also?
<mrvn> "Chapter 24 The threads library" says it uses POSIX 1003.1c threads for Unix. I don't care about Win32 and te docs say nothing about mac.
<mrvn> I can support non-threaded, threaded with TLS, threaded and write callbacks Bigarray is only valid for the duration of the callback or threaded and write callbacks always copied the data.
_andre has quit [Quit: leaving]
Yoric has joined #ocaml
ccasin has joined #ocaml
Yoric has quit [Client Quit]
avsm has quit [Quit: Leaving.]
Yoric has joined #ocaml
seafood has joined #ocaml
avsm has joined #ocaml
<mrvn> flux: I posted my TLS question on the ML. Lets see what smarter minds (than me) will say.
<mrvn> n8
julm has quit [Ping timeout: 260 seconds]
Yoric has quit [Ping timeout: 248 seconds]
pimmhogeling has quit [Ping timeout: 265 seconds]
Yoric has joined #ocaml
<thelema> flux: I just pushed a fix to batteries' toplevel support - it's been broken since the _uni changes
Submarine has quit [Ping timeout: 256 seconds]
julm has joined #ocaml
joewilliams is now known as joewilliams_away
seafood has quit [Quit: seafood]
julm has quit [Client Quit]
julm has joined #ocaml
pimmhogeling has joined #ocaml
pimmhogeling has quit [Ping timeout: 276 seconds]
joewilliams_away is now known as joewilliams
Yoric has quit [Quit: Yoric]
ulfdoz has quit [Ping timeout: 246 seconds]
<synod> Can you inherit from one inline object to another?
<thelema> no, you can only inherit from a class
<synod> Is there a type-checking reason for that? Why can't I wrap objects on the fly like I can with functions?
<thelema> Since there's no class name for the object.
<synod> Hmm... ok perhaps not inheritance because that implies a class hierarchy.
<synod> Can I selectively late bind on an object I already have?
<synod> And add or override structural constraints
<thelema> All method calls are late-bound
<synod> only via inheritance, though, right?
<synod> or is there another mechanism for late binding?
<thelema> The class body of an immediate object cannot be extended.
<synod> What about shadowing an immediate object's methods?
<synod> but not changing the class type
<thelema> with another method? You can't change the class body.
<thelema> well, you can't extend the class body...
<thelema> hmm...
<synod> Right... seems like it should be type kosher
<synod> but I can't find any mechanism to do it
<thelema> why do you want to do this?
<synod> Curiosity? My theoretical use is to wrap vector-like objects in a basis change.
<synod> There are a lot of other ways to do it and a lot of reasons that wrapping is probably not the best solution
<synod> but it seems like it should be expressible via the type system... so I was wondering if it is
avsm has quit [Quit: Leaving.]
<thelema> not that I know of. You might get a more enlightened answer on the ocmal-list
<synod> thelema: ok. thank you :-)
TaXules has quit [*.net *.split]
Mr_Awesome has quit [*.net *.split]
TaXules has joined #ocaml
Mr_Awesome has joined #ocaml
ccasin has quit [Quit: Leaving]
threeve has quit [Quit: threeve]
derdon has quit [Quit: derdon]
naufraghi has quit [Quit: naufraghi]
EliasAmaral has joined #ocaml
EliasAmaral is now known as dark
sshc has quit [Ping timeout: 276 seconds]
tmaedaZ is now known as tmaeda
slash_ has quit [Quit: Lost terminal]
Amorphous has quit [Ping timeout: 240 seconds]
sshc has joined #ocaml
sshc has quit [Client Quit]
jao has joined #ocaml
sshc has joined #ocaml
[df] has joined #ocaml
Amorphous has joined #ocaml
tmaeda is now known as tmaedaZ