<tautologico>
how high is the probability that it will just be left to bitrot in the future? if ppx catches on I don't think there'll be a lot of incentives for maintaining it
<whitequark>
Drup: llvm, apparently
<whitequark>
jpdeplaix: that is possible
<Drup>
whitequark: the transition was abrupt, to say the least :D
<whitequark>
it will be easy to patch
<Drup>
tautologico: It's going to stay in it's sate of only-maintenance for while I think
<Drup>
so, no bitroting, but no innovation either
<Drup>
(as today)
<whitequark>
there are quite a few big codebases using camlp4 extensively
<whitequark>
e.g. js
<Drup>
I would have said jst, in fact.
<Drup>
(jsoo is not going to be much of an issue)
<whitequark>
jst, yes
<Drup>
(oh, it was a typo for jst, no jsoo, my bad)
<flux>
I wonder how long-lived will ppx turn out to be, ocaml language extension stories have not been very :P
<whitequark>
ppx is in trunk
<flux>
and I doubt for example coq is ever going to transfer from camlp4 to ppx..
<flux>
I understand it's actually using it for creating a new language?
<Drup>
well, it's easier to improve on ppx than on camlp4
<tautologico>
coq uses camlp5 actually
<Drup>
writing a ppx is *much* easier than writing a camlp4 extension
<flux>
but ppx is not as powerful
<flux>
the whole camlp4/5-thing was bad as well :(
<tautologico>
yeah
<Drup>
flux: well, a cuter is sometimes more useful than a shotgun.
<whitequark>
hopefully camlp4 will die and camlp5 will remain only used by coq and the like
<tautologico>
for full metaprogramming there's MetaOCaml
<Drup>
flux: and don't forget about the revised syntax :D
<Drup>
such a fabulous ideae
<Drup>
idea*
<tautologico>
it's a mess
<flux>
I guess nobody uses that nowadays
<Drup>
nobody ever used it, except to write camlp4 extensions
<flux>
and you can't really port it to ppx in a useful fashion can you?-o
<whitequark>
no
<whitequark>
thankfully
<tautologico>
someone should get the good parts and create a new OCaml, like X. Leroy did with "Heavy Caml" -> Caml light
<whitequark>
Heavy Caml?
<tautologico>
Caml "Heavy", the old CAML
<Drup>
tautologico: bad idea
<Drup>
tautologico: that's exactly what the guy behind the revised syntax had in mind, and it's a bad idea, because there are only two outcome to this kind of switch in a language already used
<Drup>
1) nobody switch, that's the good case
<Drup>
2) half the community switch, that's the very bad case
<Drup>
<insert reference to python 3 here/>
<tautologico>
F# managed to build a community, though probably because it's mainly comprised of Windows programmers
<Drup>
do you know a lot of people in the F# community that are not frustrated C# programmers ?
<Drup>
(except jon harrop but ....)
<Drup>
basically, F# doesn't predate on ocaml programmers. also, I'm not sure how big it is.
<tautologico>
yeah, that's what I was saying
<tautologico>
Windows and OCaml don't mix well, so windows programmers wanting a ML will mostly use F#
<whitequark>
fascinating, I'm reading on caml light
<whitequark>
it seems ocamldebug hasn't changed since caml light.
<whitequark>
at all
<Drup>
indeed =')
<whitequark>
... or stdlib, for that matter
<whitequark>
nearly
<tautologico>
yes
<tautologico>
that's something people complained about quite a lot... hence extlib, then batteries, core, etc
omqal has joined #ocaml
<tautologico>
for quite a while INRIA's position on OCaml was "we're a research institution and OCaml is not research anymore, it's established technology, so we can't afford to spend too many resources on it"... which is understandable.
<whitequark>
oh THAT is where Str comes
hhugo has quit [Quit: Leaving.]
<ruzu>
ocaml was so exciting, then it fell off a cliff it seems like :p
<Drup>
tautologico: I think inria made a huge mistake on this
<tautologico>
yes, there was a time when Haskell hadn't yet got much traction and there was a lot of interest in OCaml... but OCaml was evolving glacially and INRIA couldn't really respond to the community's demands (that's not their role anyway)
<tautologico>
Drup: I agree... although I understand their position, I think it was a lost opportunity
<tautologico>
research is not only about creating new stuff, after all... impact is important
<Drup>
that start to understand that, but they tend to do it through startups and stuff, which are equaly bad if you ask me
<ruzu>
what about opam prevents it from working on windows?
<Drup>
ruzu: nothing, it's just not done yet
<tautologico>
according to the TIOBE index (I know, not a great indicator, but...) from last year to this year F# went up from #37 to #13... OCaml is in the 51-100 range (they say the difference between #51 and #100 is small so they just list the languages)
<tautologico>
curiously, "ML" is #26 on the index :)
<Drup>
proof that it's probably bullshit =°
<tautologico>
and I don't believe OCaml is less used than D (#50), Modula-2 (#48) and Prolog (#46)
<whitequark>
it's search engine popularity index
<whitequark>
not usage index
<Drup>
it doesn't prove something, however
<Drup>
not enough buzz on ocaml =/
<Drup>
it does*
penglingbo has joined #ocaml
<tautologico>
I also don't think F# is more used than Ruby (#14)
<tautologico>
yes
<tautologico>
I follow some F# people on twitter and they create a lot of buzz about user groups, F# meetups, etc
<tautologico>
whitequark: I know it's not about usage, but it's meant to be an indicator of that
<tautologico>
from their site: "The TIOBE Programming Community index is an indicator of the popularity of programming languages."
omqal has quit [Quit: omqal]
<tautologico>
there are 3x more github repos with OCaml as language than F#
<tautologico>
but I guess Windows people still use that codeplex thing for open source software? I don't know
<Drup>
urk, that horror
<Drup>
tautologico: well, lot's of ocaml stuff are still on the inria forge too :p
<ruzu>
i'm semi-windows, mostly due to work :3 if ocaml was a bit more beefy i could probably sneak it into the workplace
<ruzu>
might be able to anyways
<tautologico>
I'd like if OCaml had a better story on windows
<ruzu>
hard to pry people from push-button-c# stuff if the other option's tooling is cranky
<tautologico>
I've tried to push OCaml on students before and may do it again but not all of them use Unix/OS X
oriba has quit [Quit: oriba]
eikke__ has joined #ocaml
zpe has joined #ocaml
<flux>
I can easily imagine how starting OCaml on Windows in is painful; if you are coming from Unix/Linux and you know OCaml, then you only have the environment to fight with, not Everything
<flux>
and I think most OCaml-on-Windows-users are in the second category..
<Drup>
(I started programming with ocaml, on windows :D)
<flux>
you've since learned better?-)
<Drup>
which part ? :p
<flux>
still on windows?
<Drup>
nope ;)
<tautologico>
I used to program on Windows too, I just didn't know better
<ruzu>
some people get paid to do it :P
<tautologico>
it's a terrible OS for programming, unless you are paid money to do it
<tautologico>
sure
<tautologico>
well, it's still terrible for programming, but if your livelihood depends on it then you don't have a choice :)
<ruzu>
i see they're using*nix build stuff like autoconf in opam
zpe has quit [Ping timeout: 240 seconds]
<ruzu>
someone should make a portable camlconf :3
<tautologico>
I think opam itself compiles on cygwin, but some important packages don't
<ruzu>
hah, i just opened a cygwin term to try
<tautologico>
even if you make opam completely portable lots of packages are not
<Drup>
actually, a good amount of packages are portable
<tautologico>
because most package authors live on unix, they use unix tools
<ruzu>
does opam do any of the building logic or just run make?
<Drup>
almost everything using oasis is
<tautologico>
yes
<tautologico>
but not everything uses oasis
<Drup>
ruzu: a build script is given with the package
<tautologico>
F# has this problem in reverse, it doesn't work so well on unix, but the F# people and the Mono people are working actively to improve this... they're also trying to convince library authors to build for cross-platform compatibility
<ruzu>
$ ./configure
<ruzu>
./configure: line 16: $'\r': command not found
<Leonidas>
but kinda no idea how to solve it in ocaml
dawidtoton1 has joined #ocaml
<mrvn>
you would need camlp4 for that
<dawidtoton1>
I need a list of (exists 'a. (foo -> 'a) -> (
<dawidtoton1>
I need a list of (exists 'a. (foo -> 'a) -> ('a list -> bar)) - how do I get this in ocaml?
<mrvn>
replace () with an optional GADT argument so that it internally counts the "o" and returns itself
<mrvn>
dawidtoton1: that makes no sense
izaak has joined #ocaml
<mrvn>
you can make such a list but you can't use it other than counting its length.
<dawidtoton1>
What about List.map (fun (f1, f2) -> f2 [f1 bar1; f2 bar2]) items ?
<dawidtoton1>
Do I get my quantifier wrong?
<Leonidas>
mrvn: yes, I think there is no other way, since it requires constructor calls :-/
<Leonidas>
g (O ()) (O ()) (Finish "al") is the best I could come up with
<dawidtoton1>
I'm sorry I mistyped the pair: what I want is (exists 'a. (foo -> 'a) * ('a list -> bar))
<Leonidas>
mrvn: oh, ok, I haven't thought of that. interesting.
<mrvn>
dawidtoton1: then 'a == bar in your abvove code
<mrvn>
Leonidas: using cps?
<dawidtoton1>
I hoped to get there with a record wrapper, but it seems that I can have only (forall 'a. (foo -> 'a) * ('a list -> bar)), which is not useful, I think
contempt has quit [Ping timeout: 250 seconds]
<mrvn>
dawidtoton1: since the result of f2 is part of the list the 'a == bar
<Leonidas>
mrvn: so far it doesn't work completely, so I was asking here if there was a really simple solution I may have missed :)
izaak has quit [Ping timeout: 240 seconds]
<mrvn>
SO there exist an 'a, namely bar and only bar
<mrvn>
Leonidas: what doesn't work? Should work fine with cps style
<dawidtoton1>
I see, I made quite few mistakes, thanks
contempt has joined #ocaml
<dawidtoton1>
So I need a list of ((foo -> 'a) * ('a list -> bar)) but each element has different 'a, and I need to compose ('a list) pieces of data in a function which doesn't know 'a - is this possible?
<Armael>
hmm, i'm looking at ocaml-top
<dawidtoton1>
So the [f1 bar1; f1 bar2] list shuold be ('a list) made of different pieces of bar, but for each pair (f1, f2) these 'a could be different things
<Armael>
is there a way to achieve similar feature as the ~/.ocamlinit with it?
<Armael>
for example to automatically have #require "topfind"
<Armael>
#use "topfind" *
<Armael>
(and thus be able to #require things)
George_ has joined #ocaml
BitPuffin has quit [Ping timeout: 255 seconds]
<dawidtoton1>
For example I had "type fol = {a : 'a. (unit -> 'a) * ('a list -> unit)}" and hoped to assign (fun () -> 1), (fun [1] -> ()) to it, but the quantifier seems wrong
contempt has quit [Remote host closed the connection]
contempt has joined #ocaml
BitPuffin has joined #ocaml
BitPuffin has quit [Read error: Connection reset by peer]
<mrvn>
dawidtoton1: so given a foo list you want to map that to 'a list and then bar?
<mrvn>
You can make a list of tuples of such functions by nesting 2 records with existentials. But much simpler would be to combine the f1 and f2 to give (foo list -> bar) and make a list of those functions.
miko has joined #ocaml
<ggole_>
Leonidas: you can do it nicely by changing the syntax a bit, or horribly with Obj.magic
pango has quit [Ping timeout: 264 seconds]
<miko>
I don't know much about Ocaml; I however want to build a programm written in it. There are serveral instances where it depends on zlib, and this causes a error message. I get "Unbound module Zlib", how do i fix this?
<dawidtoton1>
Yes, but at the point (foo -> 'a) are constructed, the function doesn't know how many elements the list will have, it is much later some foo are produced and combined fo 'a list
ggole_ is now known as ggole
<miko>
The libz development package (for c) is installed
<Leonidas>
ggole: maybe I should do that, but that would probably eat the rest of the day (nerdsniping) and I have exams :(
<Leonidas>
miko: did you install ocamlzip?
<dawidtoton1>
miko: then you need OCaml bindings for zlib installed
<ggole>
I put a solution up on the reddit thread if you're interested
<Leonidas>
ggole: Awesome. You could contribute it directly to the repo, for all to see :-)
<miko>
am install libz?
pminten has joined #ocaml
<miko>
opam install libz?
<Leonidas>
miko: opam install camlzip
<Leonidas>
or install it from your distributions package manager, it is pretty commonly packaged :)
eikke__ has quit [Ping timeout: 260 seconds]
<Leonidas>
ggole: Reading your solution. WAT :-)
<ggole>
Yeah, don't do that.
<ggole>
I can't see any other way to match the solution char for char, though.
<Leonidas>
"This kills the type"
eikke__ has joined #ocaml
<Leonidas>
I wonder if this would be possible with ppx?
<ggole>
Passing arguments of the wrong type would indeed be more fun than desired.
<miko>
Ok, libz is installed by OPAM, that seems to have been successfull, the library however is still not found.
<Leonidas>
I have to admit that I like the Haskell solution quite a bit :)
<miko>
*camlzip
<Leonidas>
miko: did you load it?
<dawidtoton1>
miko: I would look for a file like zlib.mli first on your system, like e.g. /usr/lib/ocaml/zip/zlib.mli
<Leonidas>
miko: un utop: #require "zip";; and then open Zlib works.
<Leonidas>
(I just wish utop was a little less ugly looking)
<mrvn>
Leonidas: you don't even need camlp4 with Obj.magic
<mrvn>
(truely evil misuse of Obj.magic)
<ggole>
That's pretty close to my evil solution.
<Leonidas>
yep
<Leonidas>
TIL: the Obj.repr of unit is int.
<ggole>
All nullary constructors, really.
<mrvn>
Leonidas: () is encoded as 0
<ggole>
Check out the RWO chapter on representations sometime, it makes for very interesting reading.
<ggole>
(Not today, if you have exams.)
<mrvn>
Leonidas: I could have checked for is_block and string_tag instead
<Leonidas>
ggole: I told my library to order a paper copy of RWO last week, they are on it :)
eikke__ has quit [Ping timeout: 272 seconds]
<Leonidas>
supporting book authors and publishers with tax money :)
* ggole
thumbs up
<ggole>
It's online though, so you could just read it there.
<jerith>
I have a problem I'm struggling with enough that I'm pretty sure I'm doing something wrong.
<Leonidas>
I know, I also added some comments. But for reading front to back, I kinda like paper more.
<mrvn>
ggole: obviosuly one reads it there too
<dawidtoton1>
So could anybody tell me what quantifier sits in "{a : 'a. (unit -> 'a) * ('a list -> unit)}" ? I'm confused now.
<jerith>
The background is that I'm writing an AMQP client, which will involve generaitng a bunch of code from an XML spec.
<Leonidas>
found a (very minor) typo yesterday, turns out it seems to be in the print version as well.
<jerith>
The generated code needs to include a type (record full of field values) and wire-format marshalling functions.
<jerith>
I'm using a description module (which defines the type and field information) and a functor that builds a module containing the marshalling code.
<jerith>
That's working for me so far, except I can't find a way to expose the type from the module.
<ggole>
dawidtoton1: universal quantification, eg, 'a . <typeexpr> is basically forall a . <typeexpr>
<jerith>
I have a polymorphic variant type (defined after all the generated modules) that includes an entry for each module.
<dawidtoton1>
mrvn: could you possibly give me a hint what would be the second record wrapper for "type fol = {a : 'a. (foo -> 'a) * ('a list -> bar)}" you mentioned?
<jerith>
I can't find a way to have each module return its own subset of that, though.
<ggole>
jerith: so you have a module A "return" `A, B return `B, etc?
dsheets has quit [Ping timeout: 255 seconds]
fraggle_laptop has quit [Remote host closed the connection]
<ggole>
And at the end, type module_tag = [`A | `B | ...]?
q66 has joined #ocaml
<jerith>
ggole: [`A of A.t | `B of B.t | ...], but otherwise yes.
izaak has joined #ocaml
<ggole>
That should work
<jerith>
A.build_thing returns `A A.t or whatever.
<ggole>
For a module A producing `A of int, give it a return type of [`A of int]
eikke__ has joined #ocaml
<ggole>
And if you like can "glue" all the module types together to make the resulting variant: type module_tag = [A.t | B.t | ...]
<ggole>
Er, if you name the variant types, that is.
yacks has joined #ocaml
shinnya has joined #ocaml
araujo has quit [Quit: Leaving]
araujo has joined #ocaml
izaak has quit [Ping timeout: 256 seconds]
eikke__ has quit [Ping timeout: 260 seconds]
<jerith>
ggole: I can't seem to expose that polymorphic variant type through the module interfaces.
<miko>
Ok, i installed utop (and with it plenty of other packages that i already installed via the os package manager). #require "zip";; seems to work in utop, the build still fails with "Unbound module Zlib".
<jerith>
miko: How are you building?
<miko>
I want to build Patoline, it as it's own make file.
<mrvn>
In general shouldn't "ref" be usable as ptr?
<whitequark>
no
pango has joined #ocaml
<whitequark>
it can be moved
angerman has quit [Remote host closed the connection]
<mrvn>
sure. but didn't you solve that problem for strings?
izaak has quit [Ping timeout: 250 seconds]
angerman has joined #ocaml
<whitequark>
no
<whitequark>
they still can be moved
pango has quit [Remote host closed the connection]
<whitequark>
it's just that for strings, the added unsafety and complexity is overweighted by the benefit
<mrvn>
From the pull request you pasted yesterday it sounded like now ctypes saves the ocaml value in an array and then only takes the address once it is on the C side and the GC can't get invoked anymore.
<whitequark>
no, that's how the usual "string" works, not "ocaml_string"
Algebr has quit [Read error: Connection reset by peer]
pminten has quit [Quit: Leaving]
slash^ has joined #ocaml
angerman has quit [Ping timeout: 240 seconds]
morphles has quit [Ping timeout: 245 seconds]
topher has joined #ocaml
topher has left #ocaml [#ocaml]
angerman has joined #ocaml
eikke__ has quit [Ping timeout: 240 seconds]
* jerith
gives up on the functor-based approach and starts figuring out how best to do the directly-generated modules.
angerman has quit [Remote host closed the connection]
angerman has joined #ocaml
izaak has joined #ocaml
<jerith>
Actually...
huza has quit [Quit: WeeChat 0.3.8]
* jerith
tries again, this time using the functor to build a module to include rather than a replacement.
George_ has quit [Ping timeout: 246 seconds]
<jerith>
Actually, that's not going to help me.
manizzle has quit [Ping timeout: 260 seconds]
<jerith>
I think I've figured out where I'm going wrong, but not how to go right.
<jerith>
In the code that's calling the functions in my module, I don't know (or care, ideally) which module I have.
<jerith>
So I have no way to get at type information specific to individual modules.
<whitequark>
... I just discovered this in hash.c
<whitequark>
case Forward_tag: /* PR#6361: we can have a loop here, so limit the number of Forward_tag links being followed */
<whitequark>
does this mean that depending on heap state, polymorphic hash can return different values? O_o
<jerith>
whitequark: I implemented hashing over mutable data structures in Topaz.
<jerith>
(Topaz being a Ruby implementation.)
<whitequark>
yes, I know! it's neat
<jerith>
It's probably the most terrifying code I've ever written.
<jerith>
It never got merged because nobody could understand it. :-/
<whitequark>
huh
<jerith>
(That was about the time the project started losing momentum for various reasons, which is probably a contributing factor.)
<whitequark>
ohh, no, Forward_tag and Lazy_tag are for lazy
<whitequark>
jerith: why did it lose momentum?
<whitequark>
it seemed promising
<jerith>
whitequark: I think the maintainers were busy with other things, mostly.
<jerith>
It seems to be picking up a little now.
<jerith>
There are commit messages in the IRC channel, at least.
dsheets has joined #ocaml
<jerith>
I was only working on it because it seemed interesting. I don't really have any need for Ruby.
thomasga has joined #ocaml
<jerith>
Back to my AMQP code, I think I'm going to have to generate a big wrapper function that knows about all the different modules for each thing I want to do with the data. :-/
izaak has quit [Ping timeout: 250 seconds]
angerman has quit [Ping timeout: 272 seconds]
angerman has joined #ocaml
* jerith
tries that.
ygrek has quit [Ping timeout: 245 seconds]
thomasga has quit [Quit: Leaving.]
Guest81403 has joined #ocaml
<jerith>
Or maybe I want a locally abstract type, now that I've remembered that they exist.
Guest81403 is now known as lostman_
tane has quit [Quit: Verlassend]
slash^ has left #ocaml [#ocaml]
thomasga has joined #ocaml
leowzukw has joined #ocaml
leowzukw has quit [Quit: leaving]
thomasga has quit [Quit: Leaving.]
leowzukw has joined #ocaml
izaak has joined #ocaml
caseyjames has joined #ocaml
<caseyjames>
hi. I'm struggling to get consistent OCaml coloring in gnu emacs. I can run Mx global-fontlock enable which will colorize most of the code but as I scroll things go back to black and white. Here is the init https://gist.github.com/caseybasichis/64ccf8eec991e5ff1cf5
angerman has quit [Ping timeout: 256 seconds]
angerman has joined #ocaml
<mrvn>
whitequark: How do I pass an intnat to a function and how do I say the function returns a Bigarray.Array1.t?
<ggole>
I don't think recent emacsen need anything at all to get font-lock working fairly well.
<Drup>
just loading tuareg correctly
eikke__ has quit [Ping timeout: 256 seconds]
<caseyjames>
Drup: I get this error: File mode specification error: (file-error "Cannot open load file" "no such file or directory" "tuareg") Making completion list...
<caseyjames>
also does anyone here use Merlin?
<Drup>
caseyjames: you probably have a path issue
<Drup>
you're on mac ?
<caseyjames>
Yes
<caseyjames>
Taureg mode was working with the other script, it just that the coloring was acting erractically
<Drup>
that's ... weird.
<Drup>
I don't know a thing about mac, and I think it's a path or instalation issue so, sorry :(
<caseyjames>
toggling global-fontlock twice on a file seems to get the whole thing colorized
<caseyjames>
thanks anyway
<caseyjames>
do you know anything about Merline?
<caseyjames>
Merlin rather
<Drup>
sure
<Drup>
there are instructions on their wiki
<ggole>
caseyjames: start an emacs -Q and load (just) tuareg and see if the problem persists
<caseyjames>
I know, I'm trying to figure out how I specify a root directory for the project. How do I load a specific .merlin
<ggole>
merlin will search for it.
<jerith>
caseyjames: I think it just walks up the path until it finds one.
<ggole>
By walking up the... yea
<ggole>
caseyjames: on an unrelated note, your auto-mode-alist entries should probably end with \\' (or at least $)
<mrvn>
Urgs, what is this? Fatal error: exception Static.Unsupported("Unsupported return type")
<mrvn>
Raised at file "string.ml", line 172, characters 25-34
<mrvn>
Called from file "string.ml", line 195, characters 13-32
<caseyjames>
-Q switches into Taureg but doesn't fix the color issue
<Drup>
caseyjames: what is your emacs version ?
<caseyjames>
24.4.5
<mrvn>
Seems like I can't have a function returning a bigarray.
<George_>
I am trying to define an exeption in this way: exception e = mymodule.e' where "exception e'" is defined in mymodule
<George_>
it looks that it is not possible, is there any way to do that?
<whitequark>
it is not
<whitequark>
what do you want to achieve?
maattdd has joined #ocaml
<George_>
I have a functor with a module mymodule constructed from its parameter
<George_>
I want to catch the exception that my module throws
<George_>
mymodule
thomasga has quit [Quit: Leaving.]
<George_>
any suggestion?
<whitequark>
try .. with Mymodule.E' -> ... ?
<George_>
let me make it more clear
troydm has quit [Ping timeout: 250 seconds]
<George_>
assume that I have a functor "func", which accepts module "f" as its parameter, and builds "mymodule" using "f". That is, there is a definition "module mymodule = ...(f)" inside func
<George_>
mymodule throws exception e'
dsheets has joined #ocaml
<George_>
now, I create a module "m = func f", and I would like to catch the exception e'
tautologico has joined #ocaml
<whitequark>
you'll either have to expose mymodule in the signature of func, or re-raise it inside the implementation of func
<gargaml>
hi
<George_>
let me see if the first suggestion works
<gargaml>
does anyone know if it is possible to force the installation of a package with opam ?
<Drup>
"opam install foo" ?
manizzle has joined #ocaml
hellome has joined #ocaml
<gargaml>
yeah but for instance camlp5 is not ready for 4.02 trunk
<whitequark>
then it will not install
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
<gargaml>
and no way I can force it ?
<whitequark>
it will not compile.
<gargaml>
ok
<George_>
how can I expose my module in the signature?
<Drup>
George_: module F : ...
<George_>
I may be doing it wrong
hellome has quit [Remote host closed the connection]
<Drup>
gargaml: if you really want to, dl the source of camlp5 and pin it, opam should accept it
<Drup>
but I'm pretty sure camlp5 will not compile on 4.02
hellome has joined #ocaml
<gargaml>
Drup: ok, thanks
WraithM has quit [Ping timeout: 255 seconds]
<Drup>
George_: there are two usual solution in this kind of situation, "module Func (F : S) = struct include F .... end
<Drup>
or "module Func (F : S) = struct module F = F .... end"
<ggole>
Or declare the exception outside the module (if types allow it)
maattdd has quit [Ping timeout: 245 seconds]
WraithM has joined #ocaml
englishm has quit [Remote host closed the connection]
<mrvn>
In ocaml I have a "void ptr" returned from some function and in a C stub I need the address that points to. What's the best way to get that? I don't seem to grok the memory representation of a void ptr.
<orbitz>
is it taht you have a C API that just hands void*'s around and you want to hold on to it?
<orbitz>
does ctypes support this?
_0xAX has quit [Remote host closed the connection]
<George_>
Thanks Drup, is what you wrote the module declaration in the signature?
<George_>
I have the definition of the module, but would like to expose it into signature
sad0ur has joined #ocaml
<George_>
so, I can refer to the exception
<mrvn>
orbitz: I have a C API that gives me a void* and size to a block of data and I want to put that into a Bigarray
WraithM has quit [Ping timeout: 250 seconds]
maattdd has joined #ocaml
<mrvn>
George_: compile the module with ocamlc -i and paste the output into module.mli
<Drup>
George_: for the second choice, "module Func (F : S) : sig module F : S .... end with module F = F
<Drup>
mrvn: no.
<orbitz>
mrvn: do you know the type of the block of data?
<Drup>
George_: for the first choice "module Func (F : S) : sig exception bla = Truc .... end"
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
<mrvn>
orbitz: could be anything. I'm going for an uint8 arrays currently.
<Drup>
be aware that with the seconde choice, the exceptions F.e and Func(F).e will be distinct
<Drup>
(I think)
<orbitz>
then onceptually you can just cast teh void* to a uint8_t*
<tautologico>
if he just wants to expose an exception, why use a functor?
<George_>
so, the first is a better choice for me, since I would like them to be the same
<companion_cube>
whitequark: kudos if you make a small parser generator with it, that handles non-blocking input :)
<whitequark>
maybe
<mrvn>
Drup: void ptr is a "'a cptr = {reftype : 'a typ; raw_ptr : Ctypes_raw.voidp; ... } and Ctypes_raw.voidp is an Int32 or Int64 containing the actual address.
<Drup>
"it seems to be efficient in practice; and that it should eventually be efficient in theory too" <3
jeroud has joined #ocaml
<mrvn>
would have been nicer with Nativeint.
<whitequark>
so much performance masturbation in here
<mrvn>
ZMQ version 4.1.0
<mrvn>
send 'Hello'
<mrvn>
recv 'Hello'
<mrvn>
jippey.
<orbitz>
are you making your own zmq bindings?
<jerith>
mrvn: \o/
<companion_cube>
whitequark: well performance does matter for a parser :)
<whitequark>
companion_cube: talking about mrvn's zmq thing
morphles has joined #ocaml
<Drup>
to avoid a copy :p
<companion_cube>
:D
<whitequark>
well, not copying message data *is* the key to zmq performance, it matters significantly
<whitequark>
the rest is what I said above
<whitequark>
the primary objective for *any* binding is readability, because it's tricky non-memory-safe code
<whitequark>
granted, ocaml-zmq doesn't score high on that too
<orbitz>
does ocaml-zmq do a lot of copying?
<whitequark>
it copies message daya
<whitequark>
data*
<mrvn>
orbitz: not if you tell it not to
<orbitz>
mrvn: are you modifying ocaml-zmq or find it lacking somehow?
<mrvn>
orbitz: I'm rewriting it
<Drup>
err
<orbitz>
is the API poor or is there some deeper flaw?
<mrvn>
orbitz: I'm writing a thin binding with Ctypes and full bindings on top of that.
<whitequark>
orbitz: the insides of ocaml-zmq are gnarly
<whitequark>
rewriting it is not a bad idea
<mrvn>
orbitz: seemed like a good example to learn Ctypes.
<orbitz>
mrvn: sounds reasonable
<Drup>
"gnarly" didn't know that word
<mrvn>
I can now send and receive messages over a socket:
<mrvn>
Totals grouped by language (dominant language first):
<mrvn>
ml: 5839 (99.29%)
<mrvn>
ansic: 42 (0.71%)
<mrvn>
Not sure if that counts as success
<orbitz>
what's the C code doing?
<whitequark>
mrvn: HOW MUCH ml lines?!
<whitequark>
six thousand?
<mrvn>
orbitz: create a bigarray for a void* + size.
<whitequark>
the whole ocaml compiler is smaller than that
<mrvn>
Original ocaml-zmq is only ml: 6057 (90.92%) ansic: 605 (9.08%)
<whitequark>
are you counting oasis in?
<mrvn>
args, yes
oscar_ has joined #ocaml
<mrvn>
it counds the myocamlbuild.ml and the _build dir too
<Drup>
huh, how large is the compiler ?
<mrvn>
Let me redo that in src/: ml: 437 (95.41%) ansic: 21 (4.59%) vs. original: ansic: 605 (61.48%) ml: 379 (38.52%)
<orbitz>
those numbers sound nicer
maattdd has quit [Ping timeout: 255 seconds]
<whitequark>
okay no, the compiler is bigger
<orbitz>
My Raft implementation is almost ready for some testing
<Drup>
until you try to map/iter/fold over negative instances
<whitequark>
and reading sexplib source causes heartburn to me
<whitequark>
Drup: wtf is a negative instance?
<Drup>
type 'a foo = 'a -> int
<whitequark>
...
<whitequark>
I error out on functional values
<Drup>
:D
<whitequark>
who would want *that*?
<Drup>
I've seen valid use cases.
<whitequark>
-ENOTHASKELL
<Drup>
ahah xD
<mrvn>
whitequark: FYI my design should allow receiving messages, getting a bigarray of that data part, using zmq_msg_gets on the message, dropping the message from scope, running the GC and the bigarray should remain valid.
<Drup>
I said valid, not simple :3
<whitequark>
well, you're welcome to contribute support for that
<whitequark>
mrvn: I figured
<whitequark>
it'll play very well with my new sodium design
<whitequark>
which is based around Bigstrings
<orbitz>
what's sodium?
<whitequark>
(Bigstring is a nicer name for a Bigarray.Array1 of char
<whitequark>
nacl bindings
<orbitz>
ah of course
<mrvn>
whitequark: the zero-copy approach has one problem though. You can make a bigarray, create a msg for it, send it over inproc://, recv the msg, make a bigarray out of it and then modifying the original bigarray changes the other too.
<Drup>
urk
<Drup>
that's ugly
<mrvn>
It's zero-copy.
<whitequark>
mrvn: that's very bad
<whitequark>
because when one of them is freed, the other is freed too, I think
<orbitz>
so is the idea you just have a big pool of these Bigstring's taht the zmq bindins allocate on startup
<whitequark>
the storage
<whitequark>
orbitz: no
<whitequark>
you make a bigstring around zmq's internal buffer
<whitequark>
and pass it around
<orbitz>
ok
madroach has joined #ocaml
<Drup>
I think zero-copy would be terrible for lmdb anyway since : "Values returned from the database are valid only until a subsequent update operation, or the end of the transaction. Do not modify or free them, they commonly point into the database itself."
<mrvn>
whitequark: No. that part needs to work.
* Drup
is not interested anymore
<whitequark>
mrvn: huh?
<whitequark>
oh, on the other hand, zmq_msg_t are refcounted and own the buffer
<whitequark>
so it will probably be fine
<mrvn>
whitequark: sending a message takes over ownership of the buffer so the bigarray does not free it when it gets out of scope.
<orbitz>
sounds like you need some linear types!
<oscar_>
If any of you have a minute or two, can you offer some clarification on the following from 'OCaml from the Very Beginning': 'Clearly append (h :: t) b is equal to h :: append t b.' To me, the former will recurse infinitely, which is very different from the latter. For full context: http://pastebin.com/yM49rHyf
<mrvn>
whitequark: you are half right. When the receving bigarray and msg and sending msg go out of scope the sending bigarray breaks I think. Need to check and fix that.
<companion_cube>
Drup: by what?
<mrvn>
I need to increment the refcount in the sending message for the bigarray and drop it in Gc.finalise
<whitequark>
mrvn: check whether zmq increases the refcount itself
shinnya has joined #ocaml
<Drup>
companion_cube: the zero-copy approach to get the value from a struct containg pointer to data + size
<tautologico>
oscar_ why do you think append (h :: t) b will recurse infinitely?
<ygrek>
flux, just git pushed the fix for ocurl bug exposed by webcamviewer, thanks for reporting
<mrvn>
whitequark: It calls the ffn callback when it is done with the data.
<tautologico>
it's the same as append a b where a = (h :: t)
<Drup>
whitequark: actually, maybe I could expose an interface with that, instead of the ctypes stuff
<flux>
ygrek, great!
<companion_cube>
Drup: for lmdb you mean?
<Drup>
yes
<companion_cube>
aww
<oscar_>
Yeah, that's why I'd think it'd recurse infinitely. I am sending the same input into the function as it received initially.
<ygrek>
flux, please check %)
<orbitz>
oscar_: why do you think that?
<ygrek>
btw, is that your working place on the webcam?
<oscar_>
If I call append a b, split a into h :: t and call append (h :: t) b, it is the same as append a b, isn't it?
<tautologico>
oscar_ I see what you mean
<orbitz>
oscar_: that isn't waht the thing you pasted says though
<tautologico>
oscar_ the thing is to think of equational reasoning
<flux>
ygrek, no, it's a computer club at the local university
<tautologico>
oscar_ equationally, append (h :: t) b = h :: apend t b
<orbitz>
oscar_: what you pasted says h :: (append t b) = append (h::t) b
<flux>
ygrek, I suppose the new version is not yet available via opam?
<tautologico>
oscar_ the book is not saying that you should call append (h :: t) b when passed append (h :: t) b
<ygrek>
nope, will give it some testing before that
<Drup>
companion_cube: why "aww" ? :D
<ygrek>
pin for the rescue %)
<tautologico>
oscar_ so because append (h :: t) b = h :: append t b, this is what the second arm of the match should do
<Drup>
there are 4 lines of ruby in js_of_ocaml's sources
<Drup>
wtf
<Drup>
(and 41 lines of lisp)
gargaml has quit [Quit: WeeChat 0.4.3]
<flux>
ygrek, bad makefile, make -j didn't work :)
<companion_cube>
Drup: it sounds useful
<companion_cube>
but well, you can provide a one-copy API
<Drup>
companion_cube: that's what I have currently
<flux>
hmm, did I find a bug in ocamlbuild?-o ocamlbuild -clean takes ages for a little project (infact so long I think it's in infinite loop)
<flux>
aaah, no
<ygrek>
flux, please report :)
<flux>
it checks of course the files in the current directory hierarchy
<flux>
I happen to have 5 million of them
<flux>
in 'output' directory
<ygrek>
and btw webcamviewer doesn't have a Makefile at all!
<flux>
I suppose I could add one
<Anarchos>
ygrek in NetHack, they just say : "hey, our machines are so fast, just do gcc *.c -o nethack , get rid of makefile !"
<oscar_>
tautologico/orbitz: So it's saying to think of sort of the "destination" when thinking about the problem?
<tautologico>
oscar_ kinda... do you agree that append (h :: t) b = h :: append t b ?
<flux>
so I added <output>: -traverse to _tags and it still traverses output
<flux>
I suppose it only prunes the files afterwards, quite annoying..
<oscar_>
Yeah, according to the way the function is written.
<ygrek>
Anarchos, seems I never gonna have machine that fast!
<tautologico>
oscar_ not really about how it's written but how it should be written
<tautologico>
oscar_ so, this equation append (h :: t) b = h :: append t b says what the function append must do when a = (h :: t)
<tautologico>
oscar_ you're writing a function over a list so you must be able to say what's the result for an empty list, and for a cons of h and t
<tautologico>
the empty list case is easy because append [] b = b (another equation)
<tautologico>
and the h :: t case comes from the above equation
<oscar_>
OK, I think I first just misunderstood this in thinking he meant the code could be swapped, then way overthought it.
<tautologico>
oscar_ this part of the book is about looking at functional code in two ways: 1) as the specification of an algorithm (a sequence of steps); 2) as establishing equations between program expressions
oriba_ has quit [Quit: oriba_]
<flux>
ygrek, works! without modifications to webcamviewer. also you got your Makefile to WebcaViewer ;)
<oscar_>
OK, I got it now. Guess I'll read up a bit on equational reasoning.
maattdd has joined #ocaml
<oscar_>
Thanks, tautologico/orbitz.
<tautologico>
oscar_ most books on functional programming have something about this idea of transforming program expressions algebraically, but it's only valid for pure functional code
<oscar_>
Yeah, I'm seeing a lot of Haskell results looking around on it, so that makes sense.
<mrvn>
let fn _ _ = match free_fn with | None -> () | Some fn -> fn data in ... Does that keep data alive as long as fn lives when free_fn is None or could the compiler optimize that?
Algebr has joined #ocaml
<Algebr>
Why does exit return a type variable rather than ()?
<mrvn>
Algebr: because: if done then exit 0 else "foo"
<tautologico>
same reason failwith does
<tautologico>
or fail in Haskell
Sim_n has joined #ocaml
<tautologico>
I mean error in Haskell
<Algebr>
that's kind of a hack.
<Drup>
not really
<tautologico>
no. these functions never return, so what's their return type?
mcclurmc_ has joined #ocaml
<Algebr>
why isn't it just ()
<Algebr>
is it an action?
<Drup>
Algebr: see the example mrvn posted
<tautologico>
thinking the other way: how can exit/failwith break the assumption that it returns a value of type 'a for any 'a ?
ygrek has quit [Ping timeout: 240 seconds]
<Algebr>
yes, and it side steps the type system, but I guess since no one gets their value, it doens't matter?
<flux>
algebr, but is it really sidestepping?
<tautologico>
let hd l = match l with [] -> failwith "hd: Empty list" | h :: _ -> h
<tautologico>
Algebr: yes it does
thomasga has joined #ocaml
<tautologico>
otherwise you can't write this List.hd function
no0y` has joined #ocaml
<flux>
algebr, also, why it would rather be () than, say, number 5?
<flux>
() is a value just as well 5 is
<tautologico>
yes
<tautologico>
it never returns, so it can potentially be anything... () is no more valid than anything else
isomorph1smes has joined #ocaml
<tautologico>
but being a type variable makes it much more flexible to use in real functions
chris2_ has joined #ocaml
<tautologico>
and it doesn't break type soundness in any way
<Drup>
also, you want exit to return a type with no inhabitant
<Algebr>
then is there any point to exit? Does any OS actually care about exit values?
orbitz_ has joined #ocaml
whitequa1k has joined #ocaml
<Drup>
Algebr: of course OS cares about exit values O_o
acieroid` has joined #ocaml
<flux>
what a function returns and what the operating system returns as the return code of the process are two different things :)
Youri_ has joined #ocaml
<tautologico>
exit is from process to OS... the process doesn't see what exit returns, it sends the exit value to the OS
milosn_ has joined #ocaml
kerneis_ has joined #ocaml
numeo_ has joined #ocaml
lostman__ has joined #ocaml
<flux>
you could of course have it like there's a single function, like C's main, and its return value would be the process return value
<flux>
OCaml doesn't have such a single entry function
hnrgrgr_ has joined #ocaml
vbmithr_ has joined #ocaml
chris2 has quit [Disconnected by services]
chris2_ is now known as chris2
pjdelport_ has joined #ocaml
al-maisan_ has joined #ocaml
girrig_ has joined #ocaml
lostman_ has quit [*.net *.split]
mcclurmc has quit [*.net *.split]
Simn has quit [*.net *.split]
whitequark has quit [*.net *.split]
fraggle_ has quit [*.net *.split]
Youri has quit [*.net *.split]
pjdelport has quit [*.net *.split]
no0y has quit [*.net *.split]
girrig has quit [*.net *.split]
al-maisan has quit [*.net *.split]
hnrgrgr has quit [*.net *.split]
acieroid has quit [*.net *.split]
milosn has quit [*.net *.split]
vbmithr has quit [*.net *.split]
kerneis has quit [*.net *.split]
isomorphismes has quit [*.net *.split]
numeo has quit [*.net *.split]
orbitz has quit [*.net *.split]
algoriddle has quit [*.net *.split]
lostman__ is now known as lostman_
algoriddle has joined #ocaml
pjdelport_ is now known as pjdelport
fraggle_ has joined #ocaml
morphles has quit [Ping timeout: 255 seconds]
izaak has joined #ocaml
<mrvn>
but even C has exit(). it just gets implicitly called when main returns.
oriba has joined #ocaml
tautologico has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fold has quit [Ping timeout: 272 seconds]
maattdd has quit [Ping timeout: 255 seconds]
dsheets has quit [Ping timeout: 245 seconds]
<Drup>
companion_cube: just read the article about derivative, didn't know about it, it's interesting
numeo_ is now known as numeo
tautologico has joined #ocaml
tobiasBora has joined #ocaml
izaak has quit [Ping timeout: 260 seconds]
axiles has quit [Remote host closed the connection]
tautologico has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
izaak has joined #ocaml
zpe has quit [Remote host closed the connection]
tautologico has joined #ocaml
al-maisan_ is now known as al-maisan
hhugo1 has joined #ocaml
hhugo has quit [Read error: Connection reset by peer]
orbitz_ has quit [Quit: Reconnecting]
orbitz has joined #ocaml
WraithM has joined #ocaml
maattdd has joined #ocaml
<Algebr>
for the lexbuf in "let lexbuf = Lexing.from_channel stdin in <myRule> lexbuf, do I always have to name lexbuf, lexbuf? I read that all the rules in my .mll have a handle on lexbuf, but does the naming matter?
<companion_cube>
you mean setting the file name?
<Algebr>
I mean setting the name of the handle of what Lexing.from_channel returns, do I always have to name it lexbuf?
<whitequa1k>
no
<whitequa1k>
you pass it to Lexer.token
<whitequa1k>
or however is your lexing function named
<companion_cube>
right, it can even be an anonymous function
<Algebr>
I read that all rules in ocamllex have a handle on an implicit variable named lexbuf
<companion_cube>
awwww, don't put a main() in a lexer :s
<jerith>
Which XML parser do I want to use?
<companion_cube>
yes, they do
<Algebr>
its just a small example
<whitequa1k>
jerith: Xmlm
<companion_cube>
whitequa1k: your nick is fuzzed
<Algebr>
yes, they do -> That's to each rule in a .mll has a handle on an implicit variable named lexbuf?
whitequa1k is now known as whitequark
<companion_cube>
yes
<companion_cube>
within the rules, not within the leading/trailing {}
<companion_cube>
(where you put the main())
<Algebr>
Ah, so the main entry rule gets passed what Lexing.from_channel returns, but the name doesn't matter as the rules all refer to it as lexbuf, regardless of what it was originally named
<companion_cube>
once you'e in the "rule" it's always named lexbuf, yes
<Drup>
Leonidas: I have g()()(F"al")
<Drup>
(by abusing the fact that () is a constructor and overloading it)
tobiasBora has quit [Quit: Konversation terminated!]
<Leonidas>
Drup: Neat. I was fiddling a bit with ppx but then it was taking too much time
<jerith>
whitequark: Thanks.
sheijk has joined #ocaml
<Drup>
Leonidas: it's going to be hard to do much better without string overloading
<Leonidas>
whitequark: I was trying to replace () by o (a function application) and "at" (a string) by at (another function application)
<Leonidas>
yes, super silly exercise :-)
WraithM has quit [Ping timeout: 245 seconds]
maattdd has quit [Ping timeout: 245 seconds]
<sheijk>
anyone here running ocaml on arm? how stable is this stuff on a regular debian (when not using mirage), do things like c bindings, ctypes, gdb debugging, etc. work well?
<Leonidas>
earlier today ggole and mrvn posted solutions with Obj.magic, so I was wondering for something more type safe :-)
<Leonidas>
sheijk: I haven't seen any problems on raspberry pi, but admittedly, haven't used it all that much
<Drup>
Leonidas: do you have a pastebin with the Obj.magic solution ?
<sheijk>
Leonidas: did you use c bindings and gdb?
<sheijk>
but actually raspberry pi is a good point, i have one sitting here so i can just try it myself now that you mention it :)
<whitequark>
raspberry pi has a silly old arm though