<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?
<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
* 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.
<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?)
<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