lapinou changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | http://www.ocaml.org | OCaml 4.01.0 announce at http://bit.ly/1851A3R | Public logs at http://tunes.org/~nef/logs/ocaml/
Simn has quit [Quit: Leaving]
talzeus has quit [Read error: Connection reset by peer]
<smondet> clan: you mean as variable name? yes, `let cstruct = 42` works
zpe has joined #ocaml
zpe has quit [Ping timeout: 244 seconds]
bicgena has quit [Quit: Connection closed for inactivity]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
tobiasBora has quit [Quit: Konversation terminated!]
Muzer has quit [Ping timeout: 252 seconds]
root_empire has quit [Read error: Connection reset by peer]
Snark has quit [Ping timeout: 241 seconds]
michael_lee has joined #ocaml
s4muel is now known as shalicke
talzeus has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
<smondet> clan: ah you need the syntax extension
<smondet> something that should look like: -package cstruct.syntax -syntax camlp4o
<smondet> on the command line
tlockney is now known as tlockney_away
<clan> i entered: ocamlc -package cstruct.syntax -syntax camlp4o flowanalysis.ml
lostcuaz has joined #ocaml
<clan> oh i got it: ocamlfind ocamlc -package cstruct.syntax -syntax camlp4o -linkpkg flowanalysis.ml
<clan> thx!
struktured has quit [Ping timeout: 240 seconds]
Snark has joined #ocaml
Guest___ has quit [Quit: Computer has gone to sleep.]
Guest___ has joined #ocaml
Muzer has joined #ocaml
Guest___ has quit [Client Quit]
izaak has joined #ocaml
<izaak> What is the standard versioning scheme for ocaml libraries? Semantic versioning like Haskell?
yacks has joined #ocaml
struktured has joined #ocaml
Guest___ has joined #ocaml
Guest___ has quit [Client Quit]
zpe has joined #ocaml
ygrek has joined #ocaml
tlockney_away is now known as tlockney
claudiuc has quit [Remote host closed the connection]
manizzle has quit [Ping timeout: 240 seconds]
<izaak> also does anyone know how to use oasis with camlp4o? ocamldep is crashing on my files that require syntax extensions
_5kg has quit [Ping timeout: 264 seconds]
<smondet> izaak: you need to add the right _tags file
kmicinski has joined #ocaml
<kmicinski> I just saw this notation
<kmicinski> type (-'a, -'b) event_listener
<kmicinski> I haven't seen the -'a before
<kmicinski> is that standard, perhaps it's in preprocessing sugar, I couldn't find it in the manual
<smondet> the - (or +) are variance annotations
<kmicinski> okay, that's all I needed to know
<kmicinski> thanks!
<smondet> izaak: look at this one: https://github.com/pveber/lwt/blob/master/_tags the -syntax_camlp4o is what you need (I think)
kmicinski has quit [Quit: Lost terminal]
_5kg has joined #ocaml
csakatoku has quit [Remote host closed the connection]
r0b4 has quit [Ping timeout: 240 seconds]
<izaak> smondet: thanks, somehow I got it to work, I think by just adding camlp4o to my BuildTools
izaak has quit [Quit: leaving]
siddharthv_away is now known as siddharthv
introom2 has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
arturgadelshin has joined #ocaml
zpe has quit [Ping timeout: 252 seconds]
csakatoku has joined #ocaml
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
manizzle has joined #ocaml
Guest_ has joined #ocaml
Guest_ has quit [Quit: Computer has gone to sleep.]
Guest_ has joined #ocaml
axiles has joined #ocaml
ygrek has quit [Ping timeout: 252 seconds]
Guest_ has quit [Quit: Computer has gone to sleep.]
Guest_ has joined #ocaml
zpe has joined #ocaml
ddosia has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
manizzle has quit [Quit: Leaving]
manizzle has joined #ocaml
arturgadelshin has quit [Read error: Connection reset by peer]
arturgadelshin has joined #ocaml
manizzle has quit [Ping timeout: 240 seconds]
arturgadelshin has quit [Ping timeout: 264 seconds]
manizzle has joined #ocaml
ski has joined #ocaml
tlockney is now known as tlockney_away
manizzle has quit [Ping timeout: 240 seconds]
ulfdoz has joined #ocaml
Dongyancai has quit [Ping timeout: 240 seconds]
ddosia1 has joined #ocaml
Dongyancai has joined #ocaml
ddosia has quit [Ping timeout: 240 seconds]
manizzle has joined #ocaml
ggole has joined #ocaml
ikaros has joined #ocaml
ygrek has joined #ocaml
ulfdoz has quit [Ping timeout: 244 seconds]
arturgadelshin has joined #ocaml
yacks has quit [Quit: Leaving]
arturgadelshin1 has joined #ocaml
arturgadelshin has quit [Ping timeout: 252 seconds]
csakatoku has quit [Remote host closed the connection]
arturgadelshin1 is now known as arturgadelshin
Guest_ has quit [Quit: Computer has gone to sleep.]
yacks has joined #ocaml
yacks has quit [Max SendQ exceeded]
yacks has joined #ocaml
ddosia1 has quit [Ping timeout: 240 seconds]
ddosia has joined #ocaml
csakatoku has joined #ocaml
Guest_ has joined #ocaml
ddosia has quit [Client Quit]
arturgadelshin has quit [Ping timeout: 240 seconds]
angerman has joined #ocaml
nikki93 has quit [Remote host closed the connection]
clan has quit [Quit: clan]
introom2 has quit [Ping timeout: 265 seconds]
csakatoku has quit [Remote host closed the connection]
nikki93 has joined #ocaml
nikki93 has quit [Ping timeout: 265 seconds]
mika2 has joined #ocaml
Kakadu has joined #ocaml
clan_ has joined #ocaml
AltGr has joined #ocaml
csakatoku has joined #ocaml
<ggole> Hmm
<ggole> I think I've figured out a way to do (almost entirely) write barrier free tail-consing
<ggole> But it requires support from the compiler and GC :/
Guest_ has quit [Quit: Computer has gone to sleep.]
Guest_ has joined #ocaml
arturgadelshin has joined #ocaml
Guest_ has quit [Client Quit]
Guest_ has joined #ocaml
arturgadelshin1 has joined #ocaml
arturgadelshin has quit [Ping timeout: 240 seconds]
jonludlam has joined #ocaml
Simn has joined #ocaml
arturgadelshin1 is now known as arturgadelshin
csakatoku has quit [Remote host closed the connection]
avsm has joined #ocaml
ollehar has joined #ocaml
avsm has quit [Read error: Operation timed out]
avsm has joined #ocaml
csakatoku has joined #ocaml
ggole has quit [Ping timeout: 252 seconds]
ggole has joined #ocaml
yacks has quit [Ping timeout: 264 seconds]
sw1nn has joined #ocaml
jao has quit [Ping timeout: 241 seconds]
csakatoku has quit []
Snark has quit [Quit: leaving]
yacks has joined #ocaml
rand000 has joined #ocaml
_5kg has quit [Ping timeout: 240 seconds]
Guest_ has quit [Quit: Computer has gone to sleep.]
avsm has quit [Quit: Leaving.]
demonimin has quit [Ping timeout: 240 seconds]
introom2 has joined #ocaml
demonimin has joined #ocaml
Thooms has joined #ocaml
Guest___ has joined #ocaml
Guest___ has quit [Client Quit]
_5kg has joined #ocaml
siddharthv is now known as siddharthv_away
_5kg has quit [Ping timeout: 264 seconds]
yacks has quit [Quit: Leaving]
manizzle has quit [Ping timeout: 240 seconds]
ygrek has quit [Ping timeout: 244 seconds]
avsm has joined #ocaml
wolfnn has joined #ocaml
manizzle has joined #ocaml
ggole has quit [Ping timeout: 252 seconds]
talzeus has quit [Remote host closed the connection]
Guest___ has joined #ocaml
ggole has joined #ocaml
rand000 has quit [Ping timeout: 265 seconds]
_5kg has joined #ocaml
avsm has quit [Quit: Leaving.]
r0b4 has joined #ocaml
avsm has joined #ocaml
yacks has joined #ocaml
shinnya has joined #ocaml
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
talzeus has joined #ocaml
talzeus__ has joined #ocaml
talzeus has quit [Ping timeout: 240 seconds]
mort___ has joined #ocaml
Vinnipeg has joined #ocaml
skchrko has joined #ocaml
darkf has quit [Quit: Leaving]
avsm1 has joined #ocaml
avsm has quit [Ping timeout: 265 seconds]
Guest___ has quit [Quit: Computer has gone to sleep.]
arturgadelshin has quit [Ping timeout: 264 seconds]
Snark has joined #ocaml
Vinnipeg has quit [Quit: Leaving.]
ddosia has joined #ocaml
ygrek has joined #ocaml
metasyntax has quit [Quit: Leaving]
mort___ has quit [Ping timeout: 252 seconds]
introom2 has quit [Ping timeout: 252 seconds]
struktured has quit [Ping timeout: 240 seconds]
angerman has quit [Quit: Gone]
<ski> ggole : "tail-consing" being TCMC ?
avsm1 has quit [Quit: Leaving.]
<ggole> ski: well, any method for holding the last cons of a list and updating it (such as manual rewrites)
<ski> i'm not sure what a "manual rewrite" is
<ski> you're talking about cases which delay the initialization of the tail of a cons, yes ?
<ggole> Rewriting a function so that it becomes tail-recursive by, say, updating the argument of a constructor with Obj.magic
<ggole> Core, for instance, has such a hack.
<ski> sounds like that's a way to implement TCMC (in a specific case)
<ggole> Indeed.
<ggole> But mere library authors can't achieve that.
<ggole> One of the objections to implementing something like TCMC is that there can be a performance hit for short lists, due to the expensive write barrier.
<ski> btw, iirc LeoNerd has done some thinking about implementing TCMC, in a Scheme context, though (including the related but not exactly the same optimization of turning `x + recur (...)' into an accumulator))
<ggole> TCMC has a long history in some contexts, mostly Prolog.
<ski> aye (where it's called LCMC)
<ggole> Warren was the first to think of it, if I recall correctly.
<ski> also Scheme (where it's not exactly mandated, but is one of the common ways to implement the "proper tail recursion" feature in the standard)
<ski> iiuc, LCMC/TCMC was independently discovered in LP and FP
<ggole> Right. Well, the idea is to (mostly) elide the write barrier for the field updates introduced by TCMC.
<ski> ok, sounds interesting
<ggole> This can be done safely in this case because the updated object is guaranteed to be in the young generation unless there is a GC in the interim
<ggole> The trick that makes it work is to mark the object (ie, tag the frame table somehow) to indicate to the GC that the object should be placed in the remembered set after GCing is done.
<ggole> If you do that, the write barrier becomes superfluous and can be removed.
<ski> the "remembered set" being ?
<ggole> The set of old objects that point into the young heap.
<ggole> The purpose of the write barrier is to maintain this set accurately.
<ski> ok, where you place mutable stuff then ?
<ggole> More or less, yeah.
<ggole> (You don't have to do this for immediate values.)
<ski> i suppose if you enter lots of conses, only once in a while the GC would kick in, so for most of these, we'd avoid the write barrier
<ggole> Yep.
demonimin has quit [Ping timeout: 240 seconds]
<ggole> This only works for objects that are being freshly allocated, mind you.
<ski> can you create cyclic values with this ?
<ski> with or without the extra `val rec' constructor stuff ?
* ski nods
shinnya has quit [Ping timeout: 244 seconds]
<ggole> Um, you can do that by mutating (mutable) objects.
<ggole> But conses should not ever cycle.
mika2 has quit [Quit: Leaving.]
<ski> yes of course, but i mean without indirecting through mutable stuff
<ggole> No, I don't think so.
<ski> `val rec ones = 1 :: ones' is the `val rec' stuff
<ski> so i suppose i was asking whether doing this TCMC for a function would allow `val rec ones = [1] @ ones' or something like that
<ggole> Well, you can do that already
<ggole> But it isn't related to this optimisation
metasyntax has joined #ocaml
<ggole> (Unless I'm missing something.)
<ski> mhm, ok
introom2 has joined #ocaml
nikki93 has joined #ocaml
<ski> so `val rec foo = bar [1] foo' can already work for user-defined functions `bar' ? or just for some special ones like `(@)' ?
<ggole> let rec has some pretty stiff restrictions which I don't remember very clearly.
<ggole> You can, e.g. let rec ones = 1::ones
<ggole> With constructors, records, tuples etc but not function calls.
<ski> (sorry, yes of course i mean `let rec', not `val rec')
<ski> ggole : yes, so i was surprised hearing `let rec ones = (@) ([1],ones)' would work ..
<companion_cube> o/
<ggole> I don't think it does
<ski> <ggole> Well, you can do that already
<ski> confused me :)
<ggole> Ah, I specifically meant let rec ones = 1::ones :)
<ggole> Sorry.
<ski> aye, i specifically meant the "calling (more or less) arbitrary function on cyclic path" one ;)
nikki93 has quit [Ping timeout: 240 seconds]
avsm has joined #ocaml
mgodshall has joined #ocaml
demonimin has joined #ocaml
<hcarty> .away
avsm has quit [Quit: Leaving.]
<hcarty> avsm: Is there a plan yet on the platform side regarding standard libraries?
<companion_cube> arf
<companion_cube> o/ hcarty
<hcarty> companion_cube: Hello!
<companion_cube> hey, you might be interested, I have a branch in which batteries doesn't depend on unix
ocp has joined #ocaml
nikki93 has joined #ocaml
nikki93 has quit [Remote host closed the connection]
<hcarty> companion_cube: Very cool. That should (hopefully) come somewhat naturally once Batteries is split up more, correct?
lostcuaz has joined #ocaml
<hcarty> Once the IO bits are split that is.
lostcuaz has quit [Read error: Connection reset by peer]
<companion_cube> well, IO doesn't actually depend on unix, it's only BatUnix and BatPervasives
lostcuaz has joined #ocaml
<companion_cube> so I moved them into their own sub-libraries
<companion_cube> (I dislike pervasives anyway)
<hcarty> Ah, I didn't realize that. That's nice.
avsm has joined #ocaml
ddosia has quit [Ping timeout: 240 seconds]
amirmc has joined #ocaml
introom2 has quit [Ping timeout: 252 seconds]
S11001001 has joined #ocaml
S11001001 has quit [Changing host]
S11001001 has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
ocp has quit [Ping timeout: 245 seconds]
yacks has quit [Quit: Leaving]
sw1nn has quit [Remote host closed the connection]
Guest36713 has joined #ocaml
nikki93 has joined #ocaml
mgodshall has quit [Ping timeout: 240 seconds]
nikki93 has quit [Remote host closed the connection]
amirmc has quit [Quit: Leaving.]
Kakadu has quit [Quit: Page closed]
Anarchos has joined #ocaml
amirmc has joined #ocaml
rz has quit [Quit: Ex-Chat]
mgodshall has joined #ocaml
Anarchos has quit [Ping timeout: 244 seconds]
angerman has joined #ocaml
demonimin has quit [Ping timeout: 240 seconds]
demonimin has joined #ocaml
ontologiae has joined #ocaml
nikki93 has joined #ocaml
Dongyancai has quit [Ping timeout: 240 seconds]
nikki93 has quit [Remote host closed the connection]
Dongyancai has joined #ocaml
Anarchos has joined #ocaml
Guest36713 has quit [Ping timeout: 265 seconds]
Guest36713 has joined #ocaml
amirmc has quit [Quit: Leaving.]
Guest36713 is now known as sw1nn
Kakadu has joined #ocaml
arjunguha has joined #ocaml
jwatzman|work has joined #ocaml
divyanshu has joined #ocaml
avsm has quit [Quit: Leaving.]
<dsheets> given a functor type, is there a way to apply it to a sig and get back the result sig?
arjunguha has quit [Ping timeout: 265 seconds]
jao has quit [Ping timeout: 264 seconds]
rz has joined #ocaml
amirmc has joined #ocaml
cuicui_ has joined #ocaml
<ygrek> dsheets, there is no obvious way, (there are no functors over signatures), but I think you know that, so we are looking for some tricks?
arjunguha has joined #ocaml
<dsheets> ygrek, i have some workarounds but it seems weird that you can "type ('l,'r) either = L of 'l | R of 'r" and then (int,string) either
<dsheets> but not "module type FUNC = functor (A : AMOD) -> sig type t = A.t * A.t end" and then FUNC(AMOD) to get the generative sig
<ygrek> I bet there was some discussion about it in the last year either in mantis or list..
<ygrek> but can't find
<ygrek> why it is not available..
Druup has joined #ocaml
arjunguha has quit [Ping timeout: 240 seconds]
jonludlam has quit [Remote host closed the connection]
<dsheets> maybe something with constraints? or sharing? or type replacement?....
Drup has quit [*.net *.split]
cuicui has quit [*.net *.split]
brendan has quit [*.net *.split]
arjunguha has joined #ocaml
arjunguha has quit [Client Quit]
brendan has joined #ocaml
<ygrek> btw you can have the signature you want but only inside the functor, not what you want?
Druup is now known as Drup
michael_lee has quit [Read error: Connection reset by peer]
AltGr has left #ocaml []
pango has quit [Ping timeout: 240 seconds]
pango has joined #ocaml
sw1nn has quit [Ping timeout: 240 seconds]
arjunguha has joined #ocaml
arjunguha has quit [Client Quit]
q66 has joined #ocaml
nikki93 has joined #ocaml
<ygrek> dsheets, ^^
skchrko has quit [Ping timeout: 265 seconds]
<dsheets> ygrek, cool, thansk
skchrko has joined #ocaml
clan_ has quit [Quit: clan_]
arjunguha has joined #ocaml
<flux> so I have this library I'm going to rewrite from scratch
<flux> there is a common base, called Cnc, and then there are modules that implement connectivity and some commands for it, say "TinyG" or "Merlin"
<flux> so the base would come with some commands (val travel : x : float -> y : float -> unit request) and a way to issue such commands (val wait : t -> 'a command -> 'a and val async : t -> 'a command -> ('a -> unit))
arjunguha has quit [Client Quit]
<flux> how would I design this all happen in OCaml?
<flux> the actual functionality provided by the base Cnc module would be exchanging lines over a serial port and waiting for acknowledgements
<Anarchos> flux what do you mean by «design» ?
<flux> I mean the best set of interfaces to provide to make this happen in a type safe manner, you know, designing software :)
<Anarchos> flux just try to write the mli files first :)
<flux> ..
<Drup> =')
<flux> actually I mostly have the .mli file already, with its implementation, but the implementation is impenetrable mess :)
<Anarchos> i don't know of good designing method, apart putting things related in the same file
<flux> well, I'm probably going to have TinyG as a module and then I can instantiate Cnc with it
<Drup> flux: so, you have Cnc, which is basically the implementation of a protocole
<flux> drup, at some very high level yes
<Drup> and some specific data, defined in TinyG and Merlin, that would use this protocole ?
manizzle has quit [Ping timeout: 244 seconds]
<flux> TinyG and Merlin can provide a lower level implementation of the protocol
<Drup> (oh, ok
<flux> so for example TinyG and Merlin both have a different way of sending G-code to the device
<Drup> I would say the obvious solution is some functorized solution
<flux> but they are both line-based. I suppose I could think it even more generally, but let's not overgeneralize this for no benefit.. :)
<flux> I suppose I'll just start doing the .mli files and see how far I can get
<Drup> I lack the details to be more precised, but clearly, a common interface for TinyG and Merlin + functor for Cnc seems a good start
<Drup> flux: can you show the mlis, or is it closed ?
<flux> (though that has the tinyg stuff integrated)
arjunguha has joined #ocaml
<Drup> It seems stateful
<flux> (oh, I said 'Merlin' all the time for obvious reasons, it's actually 'Marlin' ;-))
<flux> very much so yes
<Drup> is it because of the device you are takling to, or because of the library ?
<flux> the other end is an actual device with motors etc
<rks`> (thank god, because I have an highlight on merlin, and it was getting annoying :')
<Drup> so the statefulness is mandatory, ok
<Drup> I'm not sure to see the point of result since it's equivalent to option, but well.
<flux> it's not
<flux> you can't really do anything with a request
<flux> oh, you mean 'result'
<Drup> yes
<flux> well it used to have only one constructor
<flux> it could have maybe more in future
<flux> ..or maybe I'll get rid of the second constructor as well :)
<Drup> is the async part important ?
<flux> in any case I like to give a symbolic name for what happened, ie. the request was purged from the queue
<flux> yes, I would say it's important
<flux> why do you ask?
rand000 has joined #ocaml
<Drup> then you could replace the not very nice continuation based async by using one of the async library
<flux> I'm not sure if it would help anything in the implementation side
<flux> async is actually how the library works, the 'wait' function is just a wrapper to it
<Drup> not implementation side, but user side :p
<flux> so 'wait' uses Event to pass an asynchronous message that allows the function to return with a value
Anarchos has quit [Ping timeout: 241 seconds]
<flux> I've considered using Async - or Lwt - as the Cnc module currently uses a separate thread
<flux> (Thread.t)
milosn has quit [Read error: No route to host]
milosn has joined #ocaml
arjunguh_ has joined #ocaml
comacat has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
amirmc has quit [Quit: Leaving.]
arjunguha has quit [Ping timeout: 265 seconds]
jonludlam has joined #ocaml
arjunguh_ has quit [Ping timeout: 264 seconds]
Anarchos has joined #ocaml
manizzle has joined #ocaml
Arsenik has joined #ocaml
<ski> dsheets : i don't think those two are really comparable
ygrek has quit [Ping timeout: 261 seconds]
manizzle has quit [Ping timeout: 264 seconds]
<ski> in one case, you have a type (function), having a (function) kind, which is applied to a type tuple, yielding a new type
arjunguha has joined #ocaml
arjunguha has quit [Client Quit]
<ski> in the other case, you have a (module) function, having a (module) (function) type, and you don't apply it on a (module) argument (which would give you back a module of some module type), but instead you want to decompose the (module) type of the module
<ski> the latter corresponds better to starting with `L 42' of type `(int,string) either', and wanting to decompose this type into `int' and `string'
johnelse is now known as johnelse_away
ontologiae has quit [Ping timeout: 264 seconds]
manizzle has joined #ocaml
cdidd has quit [Ping timeout: 265 seconds]
arturgadelshin has joined #ocaml
cdidd has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
arj has joined #ocaml
rand000 has quit [Quit: leaving]
philtor has joined #ocaml
arturgadelshin has quit [Ping timeout: 244 seconds]
arj has quit [Quit: Leaving.]
philtor has quit [Ping timeout: 245 seconds]
Arsenik has quit [Remote host closed the connection]
ggole has quit []
clan has joined #ocaml
tobiasBora has joined #ocaml
claudiuc has joined #ocaml
angerman has quit [Quit: Gone]
rgrinberg has quit [Ping timeout: 252 seconds]
gustav has quit [Ping timeout: 252 seconds]
gustav has joined #ocaml
rgrinberg has joined #ocaml
tobiasBora_ has joined #ocaml
clan has quit [Quit: clan]
clan has joined #ocaml
tobiasBora has quit [Ping timeout: 264 seconds]
tnguyen_ has quit [Quit: Leaving]
tnguyen has quit [Remote host closed the connection]
ocp has joined #ocaml
malo has joined #ocaml
ocp has quit [Quit: Leaving.]
jonludlam has quit [Remote host closed the connection]
rz has quit [Quit: Ex-Chat]
tobiasBora_ is now known as tobiasBora
Kakadu has quit [Quit: Konversation terminated!]
glothriel has joined #ocaml
nikki93 has quit [Remote host closed the connection]
nikki93 has joined #ocaml
tlockney_away is now known as tlockney
clan has quit [Quit: clan]
clan has joined #ocaml
nikki93 has quit [Remote host closed the connection]
axiles has quit [Remote host closed the connection]
clan has quit [Quit: clan]
clan has joined #ocaml
clan has quit [Quit: clan]
<j0sh> i'm having trouble comparing out-of-bounds exceptions with oUnit and assert_raises
<j0sh> expected: Invalid_argument("index out of bounds")
<j0sh> but got: Invalid_argument("index out of bounds")
<j0sh> they look the same as far as i can tell, not sure how the comparison is being done, but i'm pretty sure it's structural, not physical
mgodshall has quit [Quit: mgodshall]
<j0sh> could the Invalid_argument that's raised from String (native code) be different from an ocaml-defined Invalid_argument ?
<adrien> typically that's the moment where you show your code :P
<adrien> (and I go to bed =/ )
<smondet> j0sh: usually excetions will come with their module name, but if you open/shadow things, then yes you may have two different exceptions called the same
clan has joined #ocaml
nikki93 has joined #ocaml
<j0sh> adrien: let me reduce the code a bit, was wondering if there was a quick solution
<j0sh> smondet: how do i know if the exception is shadowed?
<smondet> j0sh: Printexc.to_string will give the full module path in any case
nikki93 has quit [Remote host closed the connection]
<j0sh> is the code and exact output
<companion_cube> try a.(1); false with e -> e = (Invalid_argument "out of bounds");; ← with a a one-element array, this fails
<companion_cube> so I guess equality on exceptions sucks
<j0sh> hm what's the point of assert_raises then
<companion_cube> no idea :/
<companion_cube> I'm surprised too by this behavior
<j0sh> it works in other cases, my suspicion is Invalid_argument may be built-in into native code, at least when raised by String
<j0sh> so the structural equality doesn't hold but somehow it gets mapped correctly when doing pattern matching... idk
<Anarchos> companion_cube why not an option type in this try...catch ?
<def-lkb> Invalid_argument "index out of bounds"
<def-lkb> Easier explanation: not the same string.
<companion_cube> -_-
* companion_cube facepalms
<j0sh> def-lkb: if you look at my output, the strings seem the same
<def-lkb> companion_cube: un cycle complet sera une série de 100
<companion_cube> ok, so it actually works
* companion_cube feels better
tobiasBora has quit [Quit: Konversation terminated!]
<j0sh> it works for me when i manually do the matching too... bug in ounit, i guess
<def-lkb> hmm, that's weird
<def-lkb> I have the expected result here
<def-lkb> (ocaml 4.01.0, the test pass with bytecode & native)
<j0sh> my bytecode version passes, native version fails
<j0sh> 4.01.0
<def-lkb> 64 bit?
<def-lkb> this is worth some investigation, could you take a look at or share generated code?
<j0sh> 32, but with PAE
<j0sh> def-lkb: sure, let me upload a binary
<j0sh> meanwhile here is a simpler case that fails
<j0sh> also happy to take a look at the disassembly but not sure where to start
glothriel has quit [Ping timeout: 244 seconds]
<def-lkb> run ocamlopt -c -S test2.ml
<def-lkb> and share test2.s
jao has quit [Ping timeout: 265 seconds]
<def-lkb> ok, test2 ml fails on my computer… I'm getting lost :)
<dsheets> ski, if i understand correctly, you're saying a functor is more like "type 'a t = 'a -> 'a other"? it seems that there should be some sort of type constructor at the module signature level...
Thooms has quit [Remote host closed the connection]
Thooms has joined #ocaml
<j0sh> def-lkb: test2.s has been posted into the gist
<ski> dsheets : no, i'm saying a functor is more like `not', having type `bool -> bool'
<ski> (ignoring module vs. ordinary expression&declaration language distinctions)
<def-lkb> j0sh: your previous explanation with built-in native code and equality seems reasonable.
<dsheets> ski, except functors can carry type equalities
zpe has joined #ocaml
<ski> dsheets : where `bool -> bool' is more or less `(bool,bool) (->)'
<def-lkb> but why it worked with test.ml and not test2.ml on my setup… I don't get
<ski> dsheets : yes
<dsheets> ski, so, i accept the functor arrow being equivalent to a function arrow in the module signature/type levels
<ski> dsheets : still, your query is similar to having a value of type `(int,string) either', and wanting to extract the type `string' from this
<dsheets> ski, i just wish there was an equivalent to parametric types for module signatures
<j0sh> yay, my first ocaml compiler bug? :)
<dsheets> ski, no, i want the result of "module type 'a FOO = sig type t = A of 'a | B of 'a end"
<dsheets> but i wish 'a to be another module signature in this case...
<ski> anyway, at least strictly speaking "given a functor type, is there a way to apply it to a sig and get back the result sig" doesn't make sense, since you don't apply functor types to stuff (just like you don't apply ordinary function types to stuff). you can apply *functor*s to stuff (and apply functions to stufF)
<dsheets> sure, fine, you're correct... i don't need module level functions
<dsheets> i need module type level functions
<dsheets> aka type constructors
<dsheets> but at present functor types are the closest thing we have it seems
<ski> your "module type FUNC = functor (A : AMOD) -> sig type t = A.t * A.t end","FUNC(AMOD)" example didn't sound like you wanted to parameterize module types at all
<dsheets> FUNC(AMOD) would be the least type of the module resulting from an application of a functor with type FUNC to a module of type AMOD
<ski> hm
<dsheets> functors don't have intermediate side effects from their application afaik
<ski> i suppose the dependency complicates stuff here
<dsheets> but we could have another construct, no problem
<ski> (though i still think `FUNC(AMOD)' itself makes no sense)
rand000 has joined #ocaml
<ski> you want to do something similar to : given `<t0> -> <t1>' and `<t2>', unify `<t0>' and `<t2>', and if successful, return `<t1>'
<dsheets> not even the arrow
<dsheets> parameterized module signatures
<dsheets> how that is expressed syntactically is separate
<ski> except since `<t1>' can depend (as in dependent types) on `<t0>', this is more complicated
<ski> hm
clan has quit [Quit: clan]
<ski> oh, i think i see
<dsheets> this is part of the reason i started trying with functors because they express type sharing between lhs and rhs of arrows
<dsheets> there is a type binding
<dsheets> if you have a functor type, you may apply a module type and receive a module type. if you have a functor, you may apply a module and receive a module
<dsheets> erm, other way around
<dsheets> a bit tipsy... apply functor objects to values at the same level
rz has joined #ocaml
<ski> i wonder whether it would make sense to parameterize signatures over anything else than types ..
<def-lkb> j0sh: likely… Maybe it has been fixed in trunk.
<ski> (and i still don't agree with "if you have a functor type, you may apply a module type and receive a module type" ;)
<dsheets> ski, hmm why can't you parameterize signatures by signatures? if you can parameterize by types, you can parameterize by package types
<dsheets> ski, presently yes, but i don't see why a functor type doesn't directly and completely describe a signature -> signature map?
<ski> dsheets : well, signatures can contain other things than (abstract) type specifications. i'm not sure whether it makes sense to parameterize a signature over such
<dsheets> ski, yes, but only type defns can be used on the rhs of a functor?
<dsheets> the values are projected away
<def-lkb> j0sh: I tracked the bug a bit. With native backend, Invalid_argument exception raised by string access is allocated outside the ocaml heap. comparison fails in this case (byterun/compare.c:149 in ocaml 4.01.0)
<ski> hm, let's compare a functor type `functor (A : AMOD) -> sig ..A.. end' with a dependent function type `(x : A) -> ..x..', which could be written as `Pi A (fun (x : A) -> ..x..)'
<dsheets> *rhs of a functor signature
<ski> also, `sig type t ..t.. end' is compared with a dependent product type `(x : A) * ..x..', which could be written as `Sigma A (fun (x : A) -> ..x..)'
<ski> in both cases, `..x..' with free variable `x', here abstracted as `fun (x : A) -> ..x..', is the parameterized signature you want to express
<j0sh> def-lkb: ah. is the Invalid_argument "index out of bounds" exception exposed anywhere for strings, so we can physically compare them?
<ski> .. and the type of this abstraction here i think is `A -> Sig', with `Sig' being the type/kind/whatever of signatures
<dsheets> ski, what is A? a signature?
<def-lkb> j0sh: what do you mean by exposed for strings?
<ski> a signature is not a record, though. a signature contains a row associating names to types (here actually types for the value parts of the signature, and kinds for the (abstract) type parts of the signature)
<j0sh> i mean can we fetch a pointer to it somehow, like String.bounds_exn or something
<def-lkb> j0sh: … just make an invalid access, keep the exception :)
<ski> dsheets : `A' is the type/kind/whatever over `x' which is whatever we're parameterizing over. e.g. possibly `x' is a single type `t', and then `A' is its kind
<j0sh> def-lkb: ah yes that's one way, i guess :)
<def-lkb> it's late here, I need to sleep. gn
<ski> dsheets : so, to be able to abstract over multiple types simultaneously, one would have something like `Type * (Type -> Type) -> Sig' or `{type t : Type,type u : Type -> Type} -> Sig' (bundling the types together in a (type-level) tuple or record)
<dsheets> ski, ok, this all sounds fine. sometimes the types in the signature are not abstract, though, and then their kinds are quite specific but overall, yes. i don't see how any of this stops parameterized module signatures
<ski> dsheets : now, just as a tuple/record of types is very different from a type of tuples/records (iow tuple/record type), likewise i believe in this case parameterizing over a *signature* (akin to the latter) would also be different from the former (which i believe you really want)
shalicke has quit [Quit: ZNC - http://znc.in]
<dsheets> Well, i also don't see an issue with type aliases through record fields...
<dsheets> type r = { a : int; b : float } ;; type q = r.a ;;
<ski> what is the kind of `r' ?
<dsheets> perhaps not quite that syntax but something similar. If you have types parameters, type 'a r = { a : 'a; b : float } ;; type 'a q = 'a r.a
<ski> presumably it is `Type'/`*'/`Star', since `r' is inhabitable ((in principle) capable of having values of type `r')
lostcuaz has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dsheets> ski, yes, i would think *
<ski> but then, how should the kind system know that `r.a' is a valid type expression, if it only knows that `r' has kind `Type' ?
<dsheets> perhaps you are cheeky and say it is ( * ) * ( * )
<dsheets> or { a : * ; b : * }
<ski> (e.g. `r' might be a component of an argument module passed to a functor .. or it might be a type argument passed to a type constructor)
<ski> i don't think so
<ski> the record type `r', and a *record* of types `{ a = int; b = float }' (with kind say `{ a : Type; b : Type }') simply are different things
<ski> for the latter, you could possibly say `r.a', which would have kind `Type' then
<dsheets> i do not see why a record type does not automatically generate a record of types...
<dsheets> surely every record type has a corresponding record of types
<dsheets> perhaps even a lattice of them
<dsheets> (according to record patterns)
<ski> a record type (and also a variant type) is generated by a row of types
<dsheets> i mean, we clearly have an operator at the module level which generates its signature (module type of)
<dsheets> it has some issues but the basic premise seems sound
lostcuaz has joined #ocaml
<ski> so `{ a : int; b : float }' could be syntactic sugar for `{| a : int; b : float |} rec' and `[ a : int | b : float ]' could be syntactic sugar for `{| a : int; b : float |} var'
<ski> so both `rec' and `var' would then have kind `Row -> Type'
<dsheets> is `var' a sum?
lostcuaz has quit [Client Quit]
<ski> there's possibly some similarity between `Row' and kinds like `{ a : Type; b : Type }', hmm ..
<ski> dsheets : `var' would be a type constructor, constructing a variant type from a given row type
<dsheets> ok, i suspected from the | but wasn't sure abt notation
<ski> i suppose one difference is that all the types inside a row must have kind `Type', while the types inside a type(-level) tuple/record can have differing kinds
<ski> (maybe one could generalize (parameterize ?) `Row' to allow all types inside having some common shared kind, instead of only `Type')
<ski> (dsheets : anyway, most of the above notation is imaginary, anyway)
<dsheets> so if rows must be homogeneous and type-level products can be heterogeneous, then surely there is an injection
wolfnn has quit [Ping timeout: 240 seconds]
<ski> well, depends on how much is statically known about the field names present in a row
<ski> the kind of a type record tells you what field names are present
<dsheets> i don't think ocaml has non-static rows? all types are known at compile-time...
<ski> there's several different ways of handling rows, and i'm not familiar with them
<dsheets> ehhh except maybe with polymorphic variants and objects
<dsheets> then you can separately compile types with open rows
<ski> one way is assume `{||}' and `{| x : tau | r |}' are rows, given `x' a field name, `tau' a type, and `r' a row. then a constraint `r \ x' expresses that `r' doesn't have a field named `x', which is a precondition for using the second kind of row construction
<dsheets> right, this only comes up with poly vars and objects i think
* ski nods
<dsheets> and modules do have structural subtypes (i think it's the right term/??)
<dsheets> but if you ascribe a signature, you cannot go back, only inclusion can be used
<dsheets> so in this way, the type is closed but can be embedded into another
S11001001 has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<dsheets> my original issue is having a common protocol with different wire formats: i wish to make a variant with constructors over two modules with similar structure but differing layout and accessors
<ski> yes, so i don't really think it makes sense to try to use `r.a' when `r' is a record type
<dsheets> why not? r can be raised to a type product which can be projected
<ski> if you know `r rec' is the record type, then possibly `r.a' could make sense
<dsheets> ah, yes, r is not abstract
mort___ has joined #ocaml
<ski> (in this case `r' is the row itself, not the record type based on it. so this would then suggest a row is like a record of types)
Thooms has quit [Quit: WeeChat 0.3.8]
<dsheets> if the row is closed, it seems precisely like a record of types
<dsheets> just as a module specification seems like a record of types
clan has joined #ocaml
<ski> i suppose the latter could possibly be said to contain a module row
<dsheets> a module row, a value record, and a set of equalities
<dsheets> for ocaml, we hold the set of value equalities null
malo has quit [Quit: Leaving]
<ski> value record ?
Simn has quit [Ping timeout: 245 seconds]
* ski is starting to get sleepy
<dsheets> some set of values with given types
Simn has joined #ocaml
<dsheets> yes, my drunkenness is making this abstraction difficult
zpe has quit [Remote host closed the connection]
<ski> when are such specified in a signature ?
<dsheets> module type S = sig type t val q : t end;;
zpe has joined #ocaml
<ski> (perhaps in a dep. types signature, specifying that some concrete value must be equal to some expression)
<ski> that's associating a type `t' with `q', not a value
<ski> (a module of that type would associate `q' with a value of that type)
<dsheets> `q' is a specified value of type `t'
<dsheets> i suppose this is your module row
<dsheets> in which case, a module spec is: a type record, a module row, and a set of equalities (no value equalities)
<dsheets> but this type record is precisely what we would recover from a "type of" operator over a row
zpe has quit [Ping timeout: 264 seconds]
<dsheets> which should be projectable
mort___ has quit [Quit: Leaving.]
clan has quit [Quit: clan]
<ski> for a module `M' with signature `S', `M.q' would be a value of type `M.t', yes
<ski> in the actual signature `S', `q' isn't associated with a value
<ski> mhm
* ski still wonders who would check `S' has a value-type component with name `q' in `S.q'
<dsheets> who would check? the type checker? someone who wants a single place to write a concrete type that matches?
* dsheets falls asleep
lostcuaz has joined #ocaml
<ski> what if `S' is a parameter ?
<ski> we'd want to be able to check `S.q', without needing to know the actual signature `S' will be bound to, in an application of the abstraction that abstracted away `S'
<ski> which to me suggests that `S' then would need to record `q' in its kind, as opposed to the kind simply being `Sig' (to be compared with `Type', for non-module stuff)
darkf has joined #ocaml
<ski> perhaps there's some error in this reasoning .. but i don't see it atm
madroach has quit [Ping timeout: 252 seconds]
madroach has joined #ocaml
rand000 has quit [Quit: leaving]
ivan\ has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
ivan\ has joined #ocaml
ollehar has quit [Quit: ollehar]
boogie has joined #ocaml
zpe has joined #ocaml