sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
smimou has quit ["bli"]
Submarine has quit ["Leaving"]
danly_ has joined #ocaml
danly has quit [Read error: 110 (Connection timed out)]
malc_ has quit ["leaving"]
mnemonic has quit ["leaving"]
Smergo has quit [calvino.freenode.net irc.freenode.net]
oracle1 has quit [calvino.freenode.net irc.freenode.net]
jdev has quit [calvino.freenode.net irc.freenode.net]
Smergo has joined #ocaml
jdev has joined #ocaml
oracle1 has joined #ocaml
oracle1 has quit [calvino.freenode.net irc.freenode.net]
jdev has quit [calvino.freenode.net irc.freenode.net]
Smergo has quit [calvino.freenode.net irc.freenode.net]
Smergo has joined #ocaml
jdev has joined #ocaml
oracle1 has joined #ocaml
mbishop has joined #ocaml
Submarine has joined #ocaml
diffbavis has quit [Read error: 113 (No route to host)]
romanoffi has left #ocaml []
Smerdyakov has quit ["Leaving"]
diffbavis has joined #ocaml
Submarine has quit ["Leaving"]
<flux-> hcarty, you can't, and I think I receal
<flux-> I recall a message from Xavier on some mailing list that its implementation would be non-trivial..
jacobian has quit [Remote closed the connection]
jlouis_ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
diffbavis has quit [Read error: 104 (Connection reset by peer)]
mnemonic has joined #ocaml
Submarine has joined #ocaml
diffbavis has joined #ocaml
smimou has joined #ocaml
diffbavis has quit [Read error: 104 (Connection reset by peer)]
diffbavis has joined #ocaml
mnemonic has quit ["leaving"]
alcojol has joined #ocaml
descender has joined #ocaml
Riesz has quit ["Leaving.."]
slipstream has quit [Read error: 104 (Connection reset by peer)]
swater has joined #ocaml
nonpop has joined #ocaml
nonpop has left #ocaml []
alcojol has quit ["KVIrc 3.2.5 Anomalies http://www.kvirc.net/"]
diffbavis has quit [Read error: 104 (Connection reset by peer)]
Smerdyakov has joined #ocaml
smimou has quit ["bli"]
_JusSx_ has joined #ocaml
swater_ has joined #ocaml
swater has quit [Read error: 104 (Connection reset by peer)]
swater_ is now known as swater
pango has quit [Remote closed the connection]
swater has quit ["Quat"]
iron33 has joined #ocaml
swater has joined #ocaml
iron33 has left #ocaml []
pango has joined #ocaml
ikaros has quit ["Leaving"]
ikaros has joined #ocaml
ikaros has quit ["KVIrc 3.2.4 Anomalies http://www.kvirc.net/"]
ikaros has joined #ocaml
benny_ has joined #ocaml
_JusSx_ has quit [Read error: 131 (Connection reset by peer)]
slipstream has joined #ocaml
levi_home has quit [Read error: 104 (Connection reset by peer)]
Submarine has quit [Remote closed the connection]
benny has quit [Read error: 110 (Connection timed out)]
levi_home has joined #ocaml
diffbavis has joined #ocaml
_JusSx_ has joined #ocaml
<hcarty> flux-: Thanks - I think I found the post. That's unfortunate.
swater has quit ["Quat"]
bluestorm_ has joined #ocaml
threeve has joined #ocaml
swater has joined #ocaml
smimou has joined #ocaml
fluctus has joined #ocaml
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
pants1 has joined #ocaml
pmdboi has joined #ocaml
<pmdboi> hey all. is there any way to parametrize a functor on just an integer or string, rather than having to wrap it in a struct?
<pmdboi> ideally it would be something like "module Foo (n : int) = struct (* stuff here depending on N.n*) end"
<pmdboi> i recognize that "module Foo (N : sig val n : int end) = struct (* stuff depending on N.n *) end" is possible
mbishop has quit ["Leaving"]
<pmdboi> (and that should have been "depending on n", not "depending on N.n", in the first one, sorry)
<pmdboi> but it seems cumbersome.
<pango> functors are functions in module space, so they take modules as parameter, not "struct"
<pango> well, I guess you meant the struct keyword in OCaml
<pmdboi> right, sorry
<pango> still, it takes a module, and a type is not a module
<pmdboi> i wasn't quite trying to pass in a type, but rather an actual value
<pango> I wonder what's you're trying to achieve...
<pango> s/'s//
<pmdboi> like, the ocaml tutorial mentions the possibility of a functor that takes an int as an argument and uses that to declare a type of arrays that only have that int as length
<pmdboi> and the most straightforward way appears to be something like
<pmdboi> functor FixedSizeArray (N : sig val n : int end) = struct
<pmdboi> type 'a t = 'a array
<pmdboi> let make x = Array.make N.n x
<pmdboi> (* more stuff *)
<pmdboi> end;;
<pmdboi> and you'd instantiate it with
<pmdboi> module ThreeArray = FixedSizeArray(struct val n = 3 end);;
<pmdboi> er... let, not val, there
<pmdboi> sorry
<pango> it's definitely not straightforward in OCaml, because the type system doesn't distinguish arrays of different sizes
<pmdboi> ok
<pmdboi> i mean, the code above will work
<pmdboi> i'm just wondering if there's a less verbose way of going about it.
<pango> the way it's done, IIRC, is to encode the int into a type, then use that as "phantom type" with your array...
<pmdboi> right, i've seen that; that's not what i'm going for
<pmdboi> just wondering if, instead of saying "functor FixedSizeArray (N : sig val n : int end)" i could do something simpler like "functor FixedSizeArray (n : int)"
<pmdboi> (which obviously doesn't work)
<pmdboi> and likewise invoke it with
<pmdboi> "module ThreeArray = FixedSizeArray(3)"
<pmdboi> (which equally obviously won't work)
descender has quit [Remote closed the connection]
<pango> the problem is that OCaml type system is not nominative, so other arrays may be compatible with the arrays created by your module... And you'll have achieved nothing
<pmdboi> the problem i'm asking about, though, doesn't really have anything to do with arrays; i just picked that as an example. to be more specific, i'm writing a genetic algorithm runner program
<pmdboi> and the essential part is a functor which takes a module, which itself constitutes the problem specification
<pmdboi> the thing is that the problem specification might be parametrized on some "scalar" value; for example, the canonical genetic algorithm requires a specified target string and then evolves a randomly generated pool of strings toward it
<pmdboi> so i've got the main module "module Runner (P : Problem) = struct ... end"
<pmdboi> and a module type "module type Problem = sig
<pmdboi> type t
<pmdboi> val random : () -> t
<pmdboi> val mate : t -> t -> t
<pmdboi> val fitness : t -> float
<pmdboi> end"
<pmdboi> and the problem speficiations are instances of Problem
<pmdboi> so the string fitness problem, in particular, looks something like
<pmdboi> module StringProblem : Problem = struct
<pmdboi> type t = string
<pmdboi> ... end
<pmdboi> but as it is, i have to hard-code what string it evolves toward, which is no good
<pmdboi> that's why i was asking about syntax of parametrization of modules.
<pmdboi> anyway, sorry if i've wasted your time
<pango> np
<pmdboi> i already have a working version of this written in python
<pmdboi> but it's too slow
<pmdboi> hence the ocaml :D
<pango> I'm not sure what's the best answer to your problem... I haven't played with functors any recently
<pmdboi> k, it's all good
<pmdboi> and it's not like there isn't a workaround
<pmdboi> so no biggie
<pmdboi> (also, argh, just spotted another error above. clearly i've been spending too much time around haskell)
<pango> the last time I could have used a functor I didn't, because performance price would have been too high (implement some integer functions in a generic way, to use it with the different available integer types; mainly int and int64)
<pango> polymorphism would have required standard ints to be boxed, which was totally out of question
<pmdboi> really?
<pmdboi> crazy
<pango> and ocamldefun hasn't been updated in ages...
<pmdboi> right, i was going to ask about that
<pmdboi> didn't know it was crufty
<pmdboi> anyway, i think i'm just going to have a spec type (for problem specification) in the module with it
<pmdboi> so it becomes something like
<pmdboi> module type Problem = sig
<pmdboi> type t
<pmdboi> type spec
<pmdboi> val random : spec -> t
<pmdboi> val mate : spec -> t -> t -> t
<pmdboi> val fitness : spec -> t -> float
<pmdboi> end
<pmdboi> and that'll allow for quite a bit more dynamic variability as well
<pmdboi> i can just stick the target string in the spec
<pmdboi> (for example)
<Smerdyakov> pango, use MLton instead; no performance cost from functors. ;)
<pmdboi> (but it's ml...)
<pmdboi> hehe, one of my old profs worked on mlton
<pango> Smerdyakov: sorry for waking you up ;)
<Smerdyakov> pmdboi, why do you want OCaml?
<pmdboi> on the off chance that objects come in handy
<pmdboi> (which is a really off chance, it seems... they're too restrictive for my taste most of the time)
<pmdboi> also, i'm more familiar with the syntax *shrug*
<Smerdyakov> SML has many benefits over OCaml. You've weighed them and determined that this "off chance" is more important?
<pmdboi> not really
<pmdboi> i'm sure it's wonderful
bebui has quit [Read error: 104 (Connection reset by peer)]
bebui_ has joined #ocaml
iron33 has joined #ocaml
iron33 has left #ocaml []
threeve has quit []
ikaros has quit ["Leaving"]
ikaros has joined #ocaml
bluestorm_ has joined #ocaml
swater has quit ["Quat"]
<hcarty> Smerdyakov: If you're around - Does mlton have something along the lines of OCaml's Bigarrays? A large part of what I'm using OCaml for benefits from them, so without that I'd be reluctant to give mlton a shot.
<hcarty> If mlton does have something like that though, then the supposed speed increase when using tools like functors would be very attractive
<Smerdyakov> What's the difference between Bigarray and array?
<Smerdyakov> (Especially, what matters for you?)
<hcarty> Bigarray can be mapped directly to memory allocated for a C/Fortran array
<hcarty> So it's useful when wrapping libraries, among other things
<Smerdyakov> Oh, so can any array with MLton.
<Smerdyakov> Just need to put the size at the start.
<hcarty> I'll have to take a look at that then - I'm reading large binary data sets of various type (16/32/64 bit ints, 32 and 64 bit floats)
<hcarty> So having that direct mapping takes a lot of headache out of the process
<Smerdyakov> MLton uses all native C types, except for arrays (including strings), which just need size at start.
<hcarty> Smerdyakov: Thanks, I'll take a closer look then.
fluctus has quit [Remote closed the connection]
smimou has quit ["bli"]
_JusSx_ has quit [Client Quit]