adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org and http://caml.inria.fr | http://ocaml.org/releases/4.02.0.html | Public channel logs at http://irclog.whitequark.org/ocaml
jave has quit [Ping timeout: 260 seconds]
tnguyen has joined #ocaml
oriba has quit [Quit: Verlassend]
jave has joined #ocaml
WraithM has joined #ocaml
nojb has quit [Quit: nojb]
sheijk has quit [Ping timeout: 246 seconds]
rwmjones has quit [Read error: Connection reset by peer]
rwmjones has joined #ocaml
WraithM has quit [Ping timeout: 240 seconds]
manud has joined #ocaml
nojb has joined #ocaml
tnguyen has quit [Ping timeout: 245 seconds]
milosn has quit [Ping timeout: 272 seconds]
badkins_ has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
tnguyen has joined #ocaml
q66 has quit [Quit: Leaving]
badkins has quit [Ping timeout: 272 seconds]
simulacrum has quit [Ping timeout: 245 seconds]
simulacrum has joined #ocaml
bytbox has quit [Ping timeout: 260 seconds]
avsm has quit [Quit: Leaving.]
bytbox has joined #ocaml
badkins_ is now known as badkins
tnguyen1 has joined #ocaml
badkins has quit []
marynate has joined #ocaml
tnguyen has quit [Ping timeout: 245 seconds]
nojb has quit [Quit: nojb]
macdice`` has joined #ocaml
cdidd has quit [Ping timeout: 250 seconds]
sheijk has joined #ocaml
macdice` has quit [Ping timeout: 245 seconds]
appd_ has joined #ocaml
rossberg__ has quit [Ping timeout: 260 seconds]
manizzle has quit [Ping timeout: 246 seconds]
sheijk has quit [Ping timeout: 260 seconds]
ivan\ has joined #ocaml
appd has quit [Ping timeout: 272 seconds]
bytbox has quit [Remote host closed the connection]
sheijk has joined #ocaml
milosn has joined #ocaml
cdidd has joined #ocaml
bytbox has joined #ocaml
tnguyen has joined #ocaml
tnguyen1 has quit [Ping timeout: 260 seconds]
huza has joined #ocaml
rossberg__ has joined #ocaml
bytbox has quit [Ping timeout: 272 seconds]
ontologiae has quit [Ping timeout: 260 seconds]
manud has quit [Quit: manud]
bytbox has joined #ocaml
manud has joined #ocaml
appd_ has quit [Remote host closed the connection]
taion809 has joined #ocaml
appd has joined #ocaml
teknozulu has joined #ocaml
cespinoza has joined #ocaml
ivan\ has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<teknozulu> Hey, I'm trying to implement a simple linked list, but I'm struggling to find out how to handle the concept of null (or absence of anything for "next") for my node type, http://pastebin.com/DdMxsNFN
appd_ has joined #ocaml
huza has quit [Ping timeout: 246 seconds]
<teknozulu> is the best way to handle it with an option?
<whitequark> I would use "type 'a node = Empty | Node of 'a * 'a node
<whitequark> err
bytbox has quit [Remote host closed the connection]
<whitequark> "type 'a node = Empty | Node of 'a ref * 'a node"
huza has joined #ocaml
<whitequark> oh, this is not what you're trying to do
waneck has quit [Ping timeout: 244 seconds]
appd has quit [Ping timeout: 272 seconds]
<whitequark> "type 'a node = { mutable next : 'a node option; value : 'a; }" will work.
<teknozulu> yup it does, thanks
appd_ has quit [Remote host closed the connection]
appd has joined #ocaml
huza has quit [Remote host closed the connection]
huza has joined #ocaml
waneck has joined #ocaml
tnguyen has quit [Quit: tnguyen]
huza has quit [Ping timeout: 272 seconds]
ivan\ has joined #ocaml
ygrek has joined #ocaml
teknozulu has quit [Ping timeout: 244 seconds]
huza has joined #ocaml
SuperNoeMan has joined #ocaml
<SuperNoeMan> I have an ocaml library that I need to access by various languages
<SuperNoeMan> the software platform that is accessing the library operates in a distributed fashion; I want the ocaml library to operate as a service
<SuperNoeMan> I don't want to really write each of the functions that it has one by one into the restful service...
<SuperNoeMan> how can I automatically transform ocaml functions to make them restful? WOuldn't there be something I could do with camlp4 that would allow me to parse the library naturally, and generate bindings or whatever to the ocaml restful package?
<SuperNoeMan> or rather... I mean, what would be the best way to expose any and every function of an ocaml library to another language?
<whitequark> no such way, except manual.
<SuperNoeMan> whitequark: I don't believe you
<whitequark> uh... sure? there's still no way to do it.
SethTisue has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
sheijk has quit [Quit: .]
pyon has quit [Quit: brb]
taion809 has quit [Remote host closed the connection]
yomimono has joined #ocaml
pyon has joined #ocaml
simulacrum has quit [Remote host closed the connection]
fold has quit [Ping timeout: 246 seconds]
larhat has quit [Quit: Leaving.]
huza has quit [Ping timeout: 244 seconds]
fold has joined #ocaml
manud has quit [Ping timeout: 250 seconds]
appd_ has joined #ocaml
boogie has joined #ocaml
appd has quit [Ping timeout: 245 seconds]
teknozulu has joined #ocaml
siddharthv_away is now known as siddharthv
SethTisue has quit [Quit: SethTisue]
Submarine has quit [Remote host closed the connection]
boogie has quit [Remote host closed the connection]
<def`> SuperNoeMan: I would write a set of combinators to capture all the static knowledge needed of the functions you want to expose
<def`> this will give you input sanitization, documentation, etc at the sametime
<def`> you can take a look at c-types which solve a related problems (exposing c library to ocaml)
ygrek has quit [Ping timeout: 250 seconds]
nojb has joined #ocaml
nojb has quit [Client Quit]
zpe has joined #ocaml
jao has quit [Ping timeout: 244 seconds]
MercurialAlchemi has joined #ocaml
appd_ has quit [Remote host closed the connection]
axiles has joined #ocaml
<teknozulu> ( http://pastebin.com/hy4yKhAL ) The passing of n.next on line 16 is causing "This expression has type node option but an expression was expected of type node". I tried to patch it up by adding the option you see on line 14, but it persists
<teknozulu> oh, I see the cause now (I think) but I'm not sure about a solution
<MercurialAlchemi> teknozulu: don't you mean "append element node"?
<teknozulu> since I'm matching n.next with Some node, now when I'm passing n.next I'm... passing Some node, rather than node option
<teknozulu> MercurialAlchemi: is there something I have misunderstood about parameter names being arbitrary?
<MercurialAlchemi> teknozulu: no, no, but your n.next is still a 'node option', assuming append element foo expects 'foo' to be a node, you need to pass the 'node' you pattern-matched
larhat has joined #ocaml
<MercurialAlchemi> teknozulu: (that is, the binding called 'node' you created with your 'Some node -> ...'
<teknozulu> ooooh
<teknozulu> i see
<teknozulu> thx
<MercurialAlchemi> teknozulu: np
<teknozulu> (I'm learning way too much from 4 broken lines of code, lol.) Now the problem is that I don't want to actually return anything, just mutate nodes, so I explicitly declared the return type as unit. this works for "n.next <- element", but not "append element node"
hhugo1 has joined #ocaml
<teknozulu> I'm guessing this is since I'm returning a function, rather than the result of the new append call
<teknozulu> how will I get ocaml to recognize that I'm calling a function of return type unit and it should simmer down?
<def`> just remove the 'option' argument ?
<teknozulu> Thanks, that did work. The error was that "append element node" has type 'a -> unit but an expression was expected of type unit... I don't see why removing the option changed the type from the above to just unit
ollehar has joined #ocaml
zpe has quit [Remote host closed the connection]
ygrek has joined #ocaml
<def`> 'option' (which has nothing to do with the type option as in 'node option')
<def`> was a useless argument to append, useless but still present making it a function expecting three parameters
<def`> as there was no other constraints on option, it received the type 'a, turning the result of your branch from
<def`> unit ("done") to 'a -> unit ("i am expecting the value of the option parameter, then done")
<teknozulu> ooooooh, yep I was treating it as if it was 'node option'
cago has joined #ocaml
oscar_toro has joined #ocaml
<teknozulu> thanks
yomimono has quit [Ping timeout: 260 seconds]
teknozulu has quit [Quit: enough procrastinating with homework by learning esoteric fp languages]
jonludlam has joined #ocaml
hhugo1 has quit [Quit: Leaving.]
psy_ has quit [Ping timeout: 272 seconds]
avsm has joined #ocaml
toolslive has joined #ocaml
jonludlam has quit [Quit: Coyote finally caught me]
tty57 has joined #ocaml
toolslive has quit [Ping timeout: 260 seconds]
psy has joined #ocaml
tty57 has quit [Quit: Textual IRC Client: www.textualapp.com]
toolslive has joined #ocaml
Submarine has joined #ocaml
<flux> cool, new macaque
<flux> "macaque now handles UNION, INTERSECT and EXCEPT"
zpe has joined #ocaml
<flux> also, "a new operator: IN:". any thoughts, is it "production ready"?-o perhaps not, because those new features seem pretty essential :)
<flux> (ie. the less essential but still important features could still be missing)
<jpdeplaix> flux: I'm using it since the beginning in cumulus
eikke has joined #ocaml
<jpdeplaix> I mean, yes, macaque is not really complete but at least it's usable
<flux> ..cumulus?
<flux> ah, "
<flux> A friendly and minimalist link sharing website
<flux> "
<flux> hmm, macaque uses pg'ocaml or why does cumulus require both?
<flux> prety nice site. misses only comments section to defeat reddit ;-)
<jpdeplaix> we have
<jpdeplaix> just click on « commenter »
<flux> heh, and it also requires sqlite3-ocaml
<flux> can't find such text?
<flux> ah, it's the speech buble
<jpdeplaix> no, just aside of the name of the author
<adrien> and will we get a proper user-cratic moderation? :P
<jpdeplaix> flux: in fact sqlite3 is not required anymore
<adrien> I'm only half-joking here
<jpdeplaix> we use dbm instead
<flux> jpdeplaix, why not postgresql?
<adrien> it's not impossible that reddit will collapse soonish because of such lacks
<jpdeplaix> flux: because ocsigen uses it for sessions
<adrien> s/lacks/<someword>/
<flux> adrien, I do think it's impossible. there are tons of subreddits, and probably many won't suffer from the deficiencies as much as you may think..
<flux> it will only die if something (much) better replaces it :)
<adrien> flux: the largest one have very visible moderation abuses
<flux> and it's difficult to start such a site and get the critical mass
<adrien> and the current "fear" is that reddit is going to be turned into cash cow soon
<jpdeplaix> adrien: what do you mean ?
avsm has quit [Quit: Leaving.]
<adrien> hidden
<jpdeplaix> well moderation is only handled manually in cumulus
<adrien> no explanation
<adrien> and no idea which mod or admin did what
<flux> adrien, is that really a post for 'programming', though?
<flux> I think many would disagree.
<jpdeplaix> mmh ok
<adrien> flux: many said that but overall it was a large approval and it could be considered programming imho because it was about work conditions
<adrien> and yesterday in /r/programming there was "This made me laugh.. A command line application that will automatically order you a sandwich from Jimmy John's."
<flux> but it was a link to github.
simulacrum has joined #ocaml
<jpdeplaix> adrien: I don't know. For cumulus, the only moderation possible is to go inside the database
<adrien> yeah but I don't think it's possible to consider that one appropriate while the other one will be bound to arbitrary decisions
<flux> both are borderline and on borderline the decision can swing both ways.
<adrien> jpdeplaix: I don't have a good approach but I think that if cumulus is to grow to more than a few thousands users, it is important to have better moderation processes than on reddit
<flux> it's not like this is the only post on the subject on reddit, I'm sure interested folks will find stuff to read about it.
<adrien> it's obviously not for right now but I think it's worth keeping it in mind
avsm has joined #ocaml
<flux> I'm not saying it couldn't be improved. the page you linked should have a statement "moderator removed the page for reason xxx".
<jpdeplaix> adrien: I think it won't happen :D
<adrien> flux: every couple days there is a completely unserious post that ranks very high on /r/programming and yet doesn't get deleted; here you get a post that criticizes reddit and it gets removed
<adrien> jpdeplaix: aim for the moon!
<adrien> :P
<flux> adrien, the thing is that the view of non-moderators is quite twisted
<adrien> flux: I'd say more actually: the reason would have been "not relevant" or something like that
<flux> we mostly get to see posts that are either unmoderated or small sample of posts that do get moderated
<adrien> it would be close to typical ToS which you're sure everyone goes against
<flux> we don't get to see the whole list of moderator-removed posts, do we?
<flux> who knows, there could be tons of similar posts that get removed.
<flux> personally I don't refresh reddit's new page very frequently.
<adrien> the kind of clause that's there only to be able to say "you infringed on that point" even if 99% of people infringe on it daily and don't get anything; it's all arbitray
<adrien> ry*
<adrien> flux: actually, on reddit we get to see many un-moderated posts
<adrien> the flow of content is way too large for mods so they can only react
<adrien> which means people have already seen the stuff
<adrien> I'm never browsing new; that one climbed very high and got ranked around kitty pictures
<adrien> an incredible feat :)
<flux> I wonder if it would have done that had it been about, say, ibm..
<flux> (but it may have; I think some google-posts may have ranked high)
<adrien> (this usually never happens because reddit's ranking is so biaised towards time that very large community which will be able to cast 100 votes quickly will always be over-represented in /r/all)
<adrien> well, anyway, the point I'd love to see addressed is some kind of user-cratic control of moderation or moderators
Simn has joined #ocaml
<flux> well, slashdot has both moderation and metamoderation
<adrien> public moderation history maybe, ability for the community to change mods (currently it's like on IRC where mods are the one who first created the community and then gave the same rights to their friends, except it is at a very large scale, so it fails)
<flux> well, those are not simple to implement
kakadu has joined #ocaml
<adrien> yup, definitely :)
<flux> for example a botnet could easily take over small subreddits if it were easy to change mods
<adrien> and do you take very old and inactive accounts into account?
<flux> vote with your karma ;)
<flux> (so: post kittens, get karma, take over subreddits)
<flux> I forgot: REpost kittens ;-)
<adrien> cast as many votes as you have karma, except you lose the corresponding amount of karma afterwards :P
<adrien> hahaha
<flux> hmm, I wonder how hard it would be to port Objective Caml to STM32
<flux> more precisely: Arm Cortex M4
<flux> or is it done already?
<whitequark> it's not
<whitequark> it is not very hard, except these cortexes usually have not a lot of RAM
eikke has quit [Ping timeout: 250 seconds]
<adrien> wasn't mrvn doing some bare metal arm?
<whitequark> yes. but I think it's not done yet
cago has quit [Ping timeout: 260 seconds]
eikke has joined #ocaml
<jpdeplaix> flux: I've updated the requirements
ysz has joined #ocaml
<flux> this board I have has 32 Mbit of SDRAM
<flux> and 1M of SRAM
<whitequark> that should be plenty
<flux> but maybe not very useful to have ocaml that works with those memories, as as you said, they are quite untypical
<whitequark> nah, there isn't really anything odd to them except small size
<flux> can ocamlopt produce the thumb arm instruction set?
<adrien> flux: that's luxury :P
<whitequark> yes
<adrien> (I meant, the RAM)
<whitequark> adrien: cortex-m does not execute arm code
<whitequark> oh
<adrien> yeah, weird timing :)
<flux> I wonder if O4MC would be useful in this kind of scenario, where you might want to handle an interrupt while garbagecollector is running
<whitequark> o4mc?
<flux> ocaml for multi core
<whitequark> no
cago has joined #ocaml
<whitequark> at least if the garbage collector requires any kind of cooperation between threads of execution
<whitequark> you're probably better off setting a flag and checking it on every backedge
<whitequark> well, every safepoint
Submarine has quit [Ping timeout: 272 seconds]
lordkryss has joined #ocaml
<kaustuv> [offtopic] After playing with Rust a bit recently, I am almost starting to wish for ownership in ML
<toolslive> [offtopic] after having played with Rust, I am almost starting to wish for more ML features in Rust ;)
nojb has joined #ocaml
manud has joined #ocaml
<kaustuv> Optional arguments are my biggest OCaml-y quality of life feature-wish for Rust
nojb has quit [Client Quit]
nojb has joined #ocaml
jonludlam has joined #ocaml
ontologiae has joined #ocaml
nojb has quit [Client Quit]
nojb has joined #ocaml
nojb has quit [Client Quit]
Submarine has joined #ocaml
cago has quit [Quit: cago]
cago has joined #ocaml
ontologiae has quit [Ping timeout: 245 seconds]
ysz has quit [Quit: This computer has gone to sleep]
badon has joined #ocaml
avsm has quit [Quit: Leaving.]
ysz has joined #ocaml
ysz has quit [Client Quit]
<toolslive> for me it's tail recursion...
<toolslive> (but that seems to be too hard to do)
<kaustuv> tail recursion requires a GC, so I am guessing it will "never happen".
<reynir> what
<def`> tail call* :'
eikke has quit [Ping timeout: 260 seconds]
<kaustuv> right, tail call eliminations
Hannibal_Smith has joined #ocaml
ysz has joined #ocaml
macdice`` has quit [Ping timeout: 245 seconds]
nojb has joined #ocaml
<def`> kaustuv: but I don't see why it requires a GC. The problem is that it is incompatible with stack allocation
<whitequark> ... actually, neither
<whitequark> Rust doesn't have guaranteed tail calls because of calling convention concerns
ysz has quit [Client Quit]
<whitequark> and in fact LLVM will use tail calls for functions with internal linkage / fastcc convention in Rust, C and C++ code alike
<whitequark> (as an optimization, that is, i.e. it's not guaranteed)
<jpdeplaix> works well with the C convention as well
<jpdeplaix> well, for what I've experimented at least
<def`> whitequark: it is
<def`> I don't care what the rust developers fucked up (yes, it is calling convention), but you either need a GC or prevent capture from stack variables
<whitequark> sure, and with regions, you can statically prevent the latter
<def`> and do you know if the situation is likely to change ? (guaranteed tail call, when making the calling convention explicit, eventually with a specific keyword)
<whitequark> no, there was a decision against it
Submarine has quit [Remote host closed the connection]
<whitequark> I believe the keyword is unreserved as well
ysz has joined #ocaml
rand000 has joined #ocaml
avsm has joined #ocaml
<ysz> whats the cost of ctypes foreign call? I'm only starting to learn this library
<ysz> i remember haskell's ``inline unsafe'' has no penalty at all
<ysz> is that possible with ocamls ffi?
_andre has joined #ocaml
<whitequark> ysz: ctypes uses libffi, however it is possible to use cstubs for code generation
<whitequark> in which case it is essentially zero-cost
manud has quit [Quit: manud]
<ysz> cool thx whitequark
<ysz> ill look into cstubs then
<whitequark> you can start with ctypes and move to cstubs later, when speed becomes a problem
nojb has quit [Quit: Leaving.]
rand000 has quit [Ping timeout: 246 seconds]
rand000 has joined #ocaml
<kaustuv> def`: you need GC because otherwise you cannot RETURN after a CALL. You will have to FREE the local things after the CALL.
avsm has quit [Quit: Leaving.]
toolslive has quit [Ping timeout: 260 seconds]
<kaustuv> interpret FREE as "decrement reference" if they are in RC boxes
avsm has joined #ocaml
avsm has quit [Client Quit]
badon_ has joined #ocaml
badon has quit [Ping timeout: 245 seconds]
tty57 has joined #ocaml
badon_ is now known as badon
<kaustuv> Actually one thing I am curious about with Rust is how fragmented their memory gets. One of the presumed benefits of a compacting collector is that memory locality improves over time for long lived objects.
ggole has joined #ocaml
simulacrum has quit [Quit: No Ping reply in 180 seconds.]
avsm has joined #ocaml
toolslive has joined #ocaml
simulacrum has joined #ocaml
igstan has joined #ocaml
ysz has quit [Quit: This computer has gone to sleep]
ysz has joined #ocaml
avsm has quit [Quit: Leaving.]
ygrek has quit [Ping timeout: 272 seconds]
Sim_n has joined #ocaml
hhugo has quit [Quit: hhugo]
Simn has quit [Ping timeout: 260 seconds]
igstan has quit [Quit: igstan]
<Hannibal_Smith> kaustuv, not give for grant that a objects at contiguous address correspond to some other concepts
dsheets has joined #ocaml
nojb has joined #ocaml
nojb has quit [Client Quit]
badon has quit [Ping timeout: 244 seconds]
eikke has joined #ocaml
ysz has quit [Quit: This computer has gone to sleep]
ysz has joined #ocaml
appd has joined #ocaml
siddharthv is now known as siddharthv_away
tane has joined #ocaml
<ebzzry> is it possible to wrap a function, with another function, similar to a quote mechanism?
<gasche> (fun () -> ...) can delay evaluation
<gasche> inspecting an expression's code, on the other hand, is not possible
<gasche> (but you can produce a datatype instead of code in the first place, and inspect the data)
<ebzzry> how can we do the latter?
<gasche> I need details on your use-case
<Drup> or you can use MetaOCaml.
<gasche> I don't think MetaOCaml allows code inspection
<Drup> sort of, it does
<Drup> you can get the parsetree
<Drup> and with ppx_metaquot, you can even use real syntax as pattern to inspect it
Sim_n is now known as Simn
<gasche> (... or camlp4)
<Drup> camlp4 manipulates pieces of (invalid) AST
<Drup> (and is crappy slow, and ..., and ...)
<Drup> MetaOCaml manipulates valid pieces of AST that are typechecked and even quantifies if the piece of AST is closed over it's environment.
<Drup> (not even talking about the code emission part)
<Drup> yeah, camlp4 is totally equivalent to MetaOCaml
<ebzzry> hmm, so how should we write a basic quote function?
ygrek has joined #ocaml
<gasche> ebzzry: what is your use-case?
<whitequark> Drup: I wonder how metaocaml will change after 4.02
<Drup> whitequark: oh god, don't add anything on my TODO list please x)
<ebzzry> gasche: let foo x = x + 1
<Drup> (or, more precisely, dont' remind me of things that are on my TODO list)
<ebzzry> gasche: quote foo
<Drup> ebzzry: is it just for fun or do you have a real use case ?
<ebzzry> Drup: fun, and experiments
<ebzzry> the result of 'quote foo', would be an object that I can 'apply' later.
<Drup> vanilla OCaml is not an appropriate language for such manipulations :)
<Drup> (also, I don't see the point of quoting a function)
<ebzzry> Drup: is it really not possible with vanilla ocaml?
<Drup> not in the general case, that's why gasche is asking for your precise use case
<ebzzry> I'm playing with a stack language, and I want a quote mechanism.
<ebzzry> I'd like to have: 'foo quote', the result of which will be 'push'd to the stack.
ygrek has quit [Ping timeout: 258 seconds]
BitPuffin has joined #ocaml
<gasche> you don't need a quote mechanism in the host language (OCaml) to implement a quote mechanism in the object language
<gasche> just represent "foo" as building a code expression in your object language, and quote as a particular expression-builder
<gasche> then have an evaluation function for you (object) code expressions where "quote" will just take its code argument at push it on the data stack
<gasche> (also I
<gasche> ... nothing)
<ebzzry> how can we quote +?
bytbox has joined #ocaml
badkins has joined #ocaml
<flux> if you mean how to get the + function, you can use ( + )
AltGr has left #ocaml [#ocaml]
<ebzzry> flux: oh
<ggole> This isn't quotation though
tty57 has quit [Ping timeout: 245 seconds]
<ggole> It's just how you name +.
ocp has joined #ocaml
vfoley- has joined #ocaml
shinnya has joined #ocaml
<vfoley-> Is it possible with menhir to branch on which production to "call"? My use case is the switch statement in Golang: if the expression of the switch is of the form "<expr>.(type)" I have a type switch statement, otherwise I have an expression switch statement. What is syntactically allowed in the case branches is different for the two of them, so I'd like to be able to express "if is_type_switch then parse_type_cases else
<vfoley-> parse_expr_cases".
<whitequark> just add two production rules
<vfoley-> they conflict
<whitequark> yeah, you need to reformulate your grammar so they don't
<vfoley-> I've been trying, without much success (though to be fair, I'm not an expert at parser generators); I was hoping to parse a more general construct and do the correct dispatching in the code.
<whitequark> that's not possible if you want the branch syntax to be different
<whitequark> I'm fairly sure that go itself is parsed with an LR(1) parser
<vfoley-> It is; they have a bison version and also a recursive-descent one (this latter actually uses the dispatching mechanism I was hoping to use)
<whitequark> so, clone the bison version.
<ggole> Can you syntactically tell if the thing is <expr>.(type) or not?
<ggole> ^ Yeah, that sounds easier
<whitequark> ggole: it's just literally x.(type) where x is any expression
<whitequark> vfoley-: I looked at the bison parser and they have the .(type) form as just another kind of expression
<whitequark> and the cases are parsed identically
<Drup> and the clean up in the AST
<Drup> yeah, typical.
<Drup> they*
<ebzzry> ggole: what is the proper way to do it?
<whitequark> wow, go.y is almost as shitty as ruby/parse.y
<Drup> whitequark: is there a direct relation between quality of the parser and quality of the language ? :3
<vfoley-> whitequark: which is why it's kind of hard to decipher ;)
<whitequark> Drup: *silently points at camlp4*
<ggole> Have a production for something like SWITCH expr DOT TYPE_THINGY TYPE_SWITCH _CLAUSES and another for the other case, I suppose.
<Drup> whitequark: It's not an official parser!
<Drup> (you're right >_>)
<vfoley-> They also have this expr_or_type production that involves a lot of weird shuffling of productions.
troyd has joined #ocaml
<troyd> hi all!
<troyd> I'm using obuild and I have my libs managed by opam
Simn has quit [Ping timeout: 260 seconds]
<troyd> now how can I make obuild use ocamlfind to search for libraries during compiling
sepp2k has joined #ocaml
<troyd> like instead of just plain ocaml.opt compiling use ocamlfind ocaml.opt
Sim_n has joined #ocaml
<vfoley-> What I find a bit hard with Go is that I need to accept syntactic sentences that are not actually in the description of their grammar and then do some processing to check whether it's correct or not.
<adrien> troyd: last I heard about it, it didn't support ocamlfind
<Drup> vfoley-: also known as "oops, I didn't check my gramar was actually LL(1)"
<whitequark> Drup: LALR(1)
<whitequark> I mean, it's bison.
<Drup> ah, right, you said there was a LL parser
<Drup> menhir is slightly bigger than LALR, but basically, it's the same
<vfoley-> go/parser/parser.go is written in a recursive descent style.
<vfoley-> But it's not the parser that the compiler actually uses.
toolslive has quit [Ping timeout: 260 seconds]
avsm has joined #ocaml
<dmbaturin> vfoley-: What does the compiler actually use then?
<vfoley-> dmbaturin: parser written in bison available in cmd/gc/go.y
<dmbaturin> What do they use go/parser/parser.go for then? :)
<whitequark> go-fmt I think
bytbox has quit [Ping timeout: 246 seconds]
<vfoley-> dmbaturin: if somebody needs to write a Go program that parses Go programs.
simulacrum has quit [Remote host closed the connection]
yomimono has joined #ocaml
<dmbaturin> vfoley-: On the topic, I think left factoring will work here.
<dmbaturin> As in foo_or_bar ::= foo bar, foo ::= foo_or_bar baz, bar ::= foo_or_bar quux.
<Drup> vfoley-: why maintain two parsers ?
<flux> camlp4, campl5, ocaml 8-)
<gasche> (merlin, and to some extent ocp-indent)
<Drup> flux: yes, that's the exact question: ocaml history prove it's a terrible idea
<vfoley-> Drup: you'd have to ask them :)
oscar_toro has quit [Ping timeout: 246 seconds]
<vfoley-> my guess: hysterical raisins. They started the project, whipped a parser in bison cause that was convenient and once they had a working language, they wanted a lib to parse Go programs.
darkf has quit [Quit: Leaving]
<vfoley-> And since Go is still written in C, it can't use the hand-written parser.
<whitequark> bootstrapping raisins, but, yeah
<dmbaturin> So Go still isn't self-hosted?
<flux> wouldn't it be a nice idea, though, to implement bison for go?
<flux> could even be more or less ported from bison
<flux> actually there is
<flux> why don't they use it?
<flux> it's even integrated ("go tool yacc..")
toolslive has joined #ocaml
<flux> it's too much of a direct port from C and thus a bit more painful to use than required?-)
<whitequark> I'm not sure what is the value of self-hostedness for go
<whitequark> it makes bootstrap harder, that's for sure
<whitequark> and the upside is ?..
<flux> whitequark, you get programming language points
<flux> you do know all serious language are written in themselves!
<vfoley-> They are planning to self-host
<vfoley-> By having an automatic conversion of C code to Go code
ysz has quit [Quit: This computer has gone to sleep]
<dmbaturin> vfoley-: Also, why are you parsing Go? What are you up to?
* whitequark takes out a flamethrower
<vfoley-> dmbaturin: perparing the project for a compilers class next winter
<Drup> "By having an automatic conversion of C code to Go code"
<dmbaturin> vfoley-: Ah, sounds good.
<vfoley-> we're going to have students implement a subset of Go
<dmbaturin> In ocaml?
<Drup> Go is so bad than they can automatically translate C to it, and it will still look like idiomatic Go :>
<vfoley-> But I'm trying to get as much of the language done as possible to know which parts are tricky
<whitequark> ... so they will see how horrible it is? good plan
<vfoley-> dmbaturin: they can choose their language. Prof will show how to use Bison and a similar tool in Java since all students know those languages, but they can pick OCaml, Python, etc.
<Drup> vfoley-: they can choose the language to implement, or the host language ?
<vfoley-> the host language
<vfoley-> It'll be Go to LLVM (perhaps JS) written in whatever-they-like
<dmbaturin> Ada compiler in COBOL, the one that is developed in the hell for programmers. ;)
<Drup> why Go, instead of an imaginary C-- language ?
<Drup> vfoley-: also, which student level and how long do they have ? ^^'
bytbox has joined #ocaml
<dmbaturin> Or an imaginary SomethingML? :)
bytbox has quit [Remote host closed the connection]
<ggole> How's GC support in LLVM these days?
<vfoley-> Drup: prof decided it was time to update the class (had been using the same material since 1998), and Go seems like a decent choice: it's not too complex, well documented, and is gaining in popularity so the students can't complain that we show useless material ;)
<Drup> right
<vfoley-> Drup: it's a mix of 3rd year undergrads and grad students. They have about 15 weeks.
<Drup> ok, that's long enough
<vfoley-> Yeah, and we're dropping a lot of stuff from the language. channels, goroutines and all the concurrency jazz is not going to be implemented.
<Drup> (I just don't see what Go brings in these case compared to C/C--, expect being new&hype)
<Drup> oh, so yes, really just C :D
<ggole> C with closures and GC
<vfoley-> C is tricky to parse
<vfoley-> though I'm finding that Go is not without its own quirks ;)
<whitequark> Drup: well, you don't have the preprocessor
<dmbaturin> Wirth's creations should be easy to parse. :)
<whitequark> ... for now, at least, as they're debating including one in go, which is, lol
<acieroid> Drup: a relatively nice stdlib as well (with its default, but it's still better than C's one though)
<Drup> acieroid: I don't think student are supposed to implement the stdlib
<whitequark> vfoley-: I think one of the main sources of trouble in C is that bare identifiers can be both types and variable names
<Drup> so it's out of scope
<whitequark> which stays in go
<acieroid> Drup: indeed, I didn't follow the discussion.
<Drup> whitequark: I'm gonna laught so hard when they add a preprocessor in Go and someone does Go++, with preprocessor-based templating
<acieroid> but for students you can show them examples that actually *do* stuff
<vfoley-> whitequark: that's one of them indeed. Dangling else problem is another one for students.
<Drup> that would make me happy for at least a week
<whitequark> Drup: ...
<whitequark> vfoley-: well, both of these are fairly trivially resolved
<Drup> whitequark: actually, someone almost did that already
<whitequark> with the lexer hack and by forcing a certain resolution to a shift/reduce conflict
<acieroid> Drup: that was already done to add generics :D (look for gonerics)
<ggole> Yay, parametric polymorphism without any real language or compiler support.
<Drup> acieroid: yes, I know :D
<whitequark> oh god.
avsm has quit [Quit: Leaving.]
<vfoley-> whitequark: gotta take in considerations that they have other classes and a limited amount of time to do the project. Removing these kinds of problems is a good thing I think.
<whitequark> "How does this work?!
<whitequark> Through the magic of CGI and shell scripting!"
avsm has joined #ocaml
<whitequark> granted it does put itself as a joke, if not very prominently
<Drup> whitequark: no but really, it makes me happy
<Drup> stupidity refined to it's finest
avsm has quit [Client Quit]
tty57 has joined #ocaml
<whitequark> Drup: it's not stupid, in fact it criticizes the go generate approach at the end
<whitequark> I actually think it's excellent satire of the ad-hoc approach they're trying to take
<Drup> whitequark: no, I mean. This one is a joke, but it's a joke based on some sort of reality : people need a way to do some sort of genericity, and the go way is bound to repeat the "error" of C++
<whitequark> nah, C++ is more structured than that
<companion_cube> it's so easy to bash go
<companion_cube> Drup: even java did it... that's compelling evidence generics are useful
<Drup> companion_cube: actually, in Java, they did it horribly wrong, and phil wadler fixed it. :>
cespinoza has quit [Quit: Saliendo]
<companion_cube> really?
<Drup> yeah, you can find some references online
<ggole> They did lots of things wrong in Java that got fixed later.
<Drup> yep
<ggole> Memory model, much of the stdlib
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
<whitequark> Drup: I heard that before (phil wadler fixing it), but I don't get it
tty57 is now known as jgjl
<ggole> Wadler (and Odersky?) were behind Generic Java, which was the fix
<ggole> Before that it was casts.
<whitequark> you mean, the collections just had Objects inside?
<Drup> yes
<Drup> iirc
<whitequark> and you had to cast them manually?
<ggole> Yep.
<Drup> (I was going to do a more complicated explanation, but basically, yes)
<companion_cube> well yes, they added generics
jgjl has quit [Quit: Textual IRC Client: www.textualapp.com]
ollehar has quit [Ping timeout: 245 seconds]
<companion_cube> was there another plot twist?
<ggole> And if you got it wrong, runtime error!
jgjl has joined #ocaml
BitPuffin has quit [Ping timeout: 240 seconds]
<whitequark> it's still the same on the inside though
<ggole> (This partially survives in the form of array covariance checks, actually.)
<whitequark> I was about to say
<whitequark> Java is secretly untyped
<Drup> secretly ? :D
<ggole> Sort of, there are primitives
<whitequark> (which is why JVM is so good at running Ruby, Clojure, Scheme, ...)
toolslive has quit [Ping timeout: 260 seconds]
<ggole> And the bytecode is verified to be typesafe in terms of accesses to primitives vs objects.
<whitequark> yeah, primitives are an exception
jgjl has quit [Client Quit]
jgjl has joined #ocaml
pyon has quit [Quit: brb emacs fucked up]
pyon has joined #ocaml
jgjl has quit [Client Quit]
jgjl has joined #ocaml
Haudegen has quit [Remote host closed the connection]
Haudegen has joined #ocaml
\q has quit [Ping timeout: 246 seconds]
Haudegen is now known as Guest63353
jerith has quit [Ping timeout: 246 seconds]
jerith has joined #ocaml
simulacrum has joined #ocaml
\q has joined #ocaml
<Unhammer> why does my code work it shouldn't work
<Drup> what the code ? :D
toolslive has joined #ocaml
<dmbaturin> Unhammer: It may have something to do with your understanding of the task or the language. :)
hhugo has joined #ocaml
<Unhammer> heh yeah, it's just such a weird experience
<troyd> this is strange, according to obuild's source code it uses ocamlfind printconf conf to get path to findlib.conf
<troyd> now findlib.conf contains the path to llvm package that I need during compiling
<troyd> unless I set it using ocamlopt.opt -I ~/.opam/system/lib/llvm to compiler it doesn't compiles
<troyd> if I set ocamlopt.opt -l ~/.opam/system/lib it can't find llvm.cxma
bytbox has joined #ocaml
<troyd> what should I do to resolve this issue
<troyd> ?
<whitequark> use ocamlfind properly?
<whitequark> ocamlfind opt -package llvm
Sim_n is now known as Simn
Hannibal_Smith has quit [Read error: No route to host]
<reynir> I once intentionally broke my code and found it still working
<reynir> Apparently I was allocated the same memory on each run on the GPU. It took me forever to figure out.
yomimono has quit [Ping timeout: 272 seconds]
kaustuv has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
azure_balls has joined #ocaml
<azure_balls> Can anyone illuminate me on Monads? I've seen a few blog posts but still can't quite wrap my head around it
<toolslive> try to get a grip on 1 monad.
<smondet> azure_balls: this one was quite good: http://blog.enfranchisedmind.com/2007/08/a-monad-tutorial-for-ocaml/
ygrek has joined #ocaml
<MercurialAlchemi> azure_balls: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html this one is pretty good (though it's Haskell syntax)
<azure_balls> Thanks, reading now
<companion_cube> I'd say to grasp specific monads like Option,List and Lwt (without pa_lwt)
shinnya has quit [Ping timeout: 260 seconds]
vanila has joined #ocaml
<vanila> Hi
<vanila> How does the ocaml compiler work out which closures can be stack allocated?
cago has left #ocaml [#ocaml]
eikke has quit [Ping timeout: 260 seconds]
<companion_cube> I don't think it does
<vanila> oh this doesn't make it slow?
<ggole> Not hugely.
<vanila> oh cool!
ollehar has quit [Quit: ollehar]
<ggole> It might be beneficial to stack allocate, but I wouldn't expect the difference to be large.
<mrvn> vanila: how would you figure that out?
<ggole> Escape analysis.
<mrvn> vanila: also note that the compiler scatter gathers allocations. So it just does one big one and fills it with all the values instead of doing them one by one.
<mrvn> ggole: if it doesn't escape the closure should probably be inlined and not allocated at all.
zpe has quit [Remote host closed the connection]
<ggole> Downward escaping closures can still be stack allocated, but not inlined.
<ggole> (And inlining large functions that are called multiple times is a poor decision whether they escape or not.)
rand000 has quit [Quit: leaving]
<mrvn> ggole: if the function is large then the allocation for the closure won't gain you anything either.
<vanila> mrvn, I have been reading about how to do this for a few days, its' really hard :(
<mrvn> vanila: yeah. I have a gut feeling that the cases where it would gain you something are so small/trivial that inlineing would be even more benefitial.
Submarine has quit [Quit: Leaving]
<toolslive> why would stack be faster than heap?
<mrvn> toolslive: no GC time needed to free it
<ggole> I disgree: large functions aren't necessarily slow
<ggole> Consider a match with many small cases
<ggole> Stack allocated closures might also be cheaper to construct (no copying)
<toolslive> well, not freeing and just abandoning is faster than readjusting the stack
<vanila> I have tried to use CPS to make a compiler, but that creates one new lambda for every single procedure call
<vanila> so I think that i need to do this optimization or not use CPS
<mrvn> ggole: but each case would be twice as fast inlined :)
<toolslive> yes. you have to clean up the administrative lambdas...
bezirg has joined #ocaml
<ggole> Inlining is overrated.
<mrvn> toolslive: you can't just abandon a heap allocated closure. The GC has to track it and determine if its still alive
<toolslive> on many CPUs 'the stack' is a rather arbitrary thing.
<vanila> toolslive, I'm not sure what administrative lambdas are, any pointers on that?
<azure_balls> So, I don't think I get the entire idea of Monads, but maybe their use in error handling could help me understand more generally. Using the example from Chapter 7 of Real World OCaml: "let compute_bounds ~cmp list =
<azure_balls> let sorted = List.sort ~cmp list in
<azure_balls> Option.bind (List.last sorted) (fun last ->
<azure_balls> Option.bind (List.hd sorted) (fun first ->
<azure_balls> Some (first,last)))
<azure_balls> ;;" -- I understand the general idea of "short circuit on error to None", what sorted is doing, etc., but can anyone explain the mechanics of the logic expressed here?
<toolslive> gc does not have to 'track' it
<mrvn> toolslive: s/track it/check its color/
<vanila> azure_balls, if bind sees a None, it just stops insttead of passing the result into the next function, so thats' how it short circuits
<toolslive> but it does need time later to clean it up via a descend from the root.
<ggole> Minor GCs don't touch dead objects at all.
<azure_balls> right, I get that, vanilla
<mrvn> toolslive: it does need time to skip it when compacting.
<ggole> The cost is that the minor GC happens sooner/more often than it otherwise would.
<toolslive> now the discussion becomes something like "is it more efficient to keep your desk clean all the time, or to clean it once each month" ?
<ggole> (There's also a heavier cost for anything outliving the minor heap, of course.)
<azure_balls> vanilla, aha, I see, it was right there in front of me :)
<mrvn> toolslive: with stack you don't touch the closure at all. The stack pointer simply gets incremented (which it does anyway).
<azure_balls> (List.hd sorted) is the 'first' parameter to the anonymous function defined as the second parameter of the first 'bind'
zpe has joined #ocaml
<toolslive> GC doesn't kill performance. it's allocating that does.
<mrvn> toolslive: hah. allocating is basically free in ocaml.
<toolslive> that's why everybody is using strings (sorry, Bytes.t these days) for IO and recycling them iso throwing them away and reallocating them.
<mrvn> toolslive: a) they are stupid, b) it the freeing that costs time.
<ggole> vanila: http://www.brics.dk/RS/04/39/BRICS-RS-04-39.pdf might be helpful
<mrvn> or rather the GC runs.
<azure_balls> So, when I see code that uses the infix form of bind, with no parameter, so ">>= fun () ->", it's really just a way of doing procedural/imperative code without explicit error checking--it just bails out of the procedure any time the result of one of these bound functions is None
<Drup> azure_balls: yes
<toolslive> @azure_balls. maybe you should try to think of the ; as an infix operator.
<toolslive> and then replace it with a bind infix operator.
<toolslive> and then think what you can do if you could override it.
<azure_balls> I think I get it now
<azure_balls> that's quite clever, actually
<mrvn> toolslive: do you know that IO with strings does everything in 16k chunks into a temp buffer and copies it to/from the string?
<toolslive> in Lwt_unix: val write : file_descr -> string -> int -> int -> int Lwt.t
<toolslive> that's the IO I'm talking about. I don't know where you get the copy etc etc.
<mrvn> toolslive: strings can be moved by the GC so you can't access them while releasing the runtime lock. So the stdlib at least does IO in a temp buffer without the runtime lock and copies the chunks with the lock.
<toolslive> and it does help a lot to keep the same string value for different calls
<mrvn> doesn't Lwt_unix just call Unix.write underneath?
<mrvn> toolslive: sure it helps. Using bigarray would help even more.
<smondet> mrvn: lwt_unix is supposed to make non-blockung calls, it puts filedescriptors in a Unix.select or uses libevent
<mrvn> smondet: does that mean it first selects and then does the read/write with the runtime lock held because it knows it won't block? That wouldn't work for files.
<smondet> then, AFAI understood, "non-blocking" on linux is more like a hint than a proper implementation …
<toolslive> no.it doesn't work for files
<mrvn> smondet: yes. I believe waiting for a harddisk to return data is not considered blocking.
<toolslive> if you ask a fd for a file if it's ready for write it says "yes"
<toolslive> (linux that is)
<mrvn> toolslive: yes. But does a write return early when there isn't enough cache free or does it block till the disk catches up?
appd_ has joined #ocaml
<toolslive> actually we derailed. the same could be said for tuples. not creating tuples every iteration in a loop is better than creating/destructing/creating......
<toolslive> so not making garbage is faster.
<toolslive> that was the discussion
<mrvn> .oO(I think we all agree)
appd has quit [Ping timeout: 245 seconds]
larhat has quit [Read error: Connection reset by peer]
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
larhat has joined #ocaml
<whitequark> mrvn: the write would block
troyd has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
oscar_toro has joined #ocaml
slash^ has joined #ocaml
psy has quit [Ping timeout: 260 seconds]
ollehar has joined #ocaml
<ollehar> is there a forum made in ocaml/ocsigen?
psy has joined #ocaml
<Drup> not afaik, and I don't see the point in recreating one
<Drup> there are some very well done ones already
<ollehar> OK, in scripting languages?
<Drup> well, obviously, in scripting languages
badkins has quit [Remote host closed the connection]
<whitequark> "scripting languages" are not an useful classification, but sure, http://www.discourse.org/ in Ruby
<ollehar> hm
<Drup> this one is a nice example
appd has joined #ocaml
<Drup> it's painfully slow, though
<whitequark> is it?
<ggole> "Scripting languages" seems to be nothing more than an implementation without a compilation step.
<ollehar> slowness is why I wanted ocaml
<ollehar> friendly for the environment, too :)
<whitequark> really, most of a modern website executes on the client, and slowness stems from there as well
<Drup> whitequark: yeah, and it's doing client-server magic all the time, which doesn't help if your connection is not very good/instable
<whitequark> well, yes, but that wouldn't be fixed by ocaml.
<Drup> oh, and the back button is partially broken
<Drup> whitequark: it would be fixed by eliom :>
<whitequark> I'm not so sure.
<whitequark> eliom would do the same kind of magic.
<Drup> not really
<ollehar> how about a minimal backend in C and angularjs on client?
appd_ has quit [Ping timeout: 258 seconds]
<Drup> if you are masochist, that's probably a good idea, yeah
<whitequark> if you want to endanger your users, even.
<whitequark> (because you can't write good C; no one can)
<azure_balls> OK, guys, newbie question: I get the error: "Error: This expression has type M1.E.netif -> unit Lwt.t
<azure_balls> but an expression was expected of type 'a Lwt.t" -- how can I force it to have some sort of generic type like it expects?
<Drup> azure_balls: ahah
<whitequark> azure_balls: you forgot to pass an argument to that function
<whitequark> of type M1.E.netif.
<Drup> azure_balls: rule 1: the typechecker is always right; don't even think of "forcing him to do something", fix your code instead x)
<azure_balls> lol
<azure_balls> well, yes, I know that, I should have rephrased ;)
<azure_balls> well, that was when I enclosed the statement in ignore
<Drup> Don't use ignore with Lwt
<azure_balls> without the ignore, I get "Error: This expression has type unit N.io = unit Lwt.t
<azure_balls> but an expression was expected of type unit" -- but I really do not think I'm missing an argument
<Drup> azure_balls: use Lwt.ignore_result
<azure_balls> aha, OK, thanks
<Drup> that's a different error.
<azure_balls> just a quick note for sanity checking
<azure_balls> The relevant statement is: "N.listen net0 (
<azure_balls> );", and the type of N.write is "E.netif -> E.buffer -> unit t"
<azure_balls> N.write net1
<Drup> and N.listen ?
<azure_balls> "V val listen : E.netif -> (E.buffer -> unit t) -> unit t"
<azure_balls> (sorry, hit <CR> too soon)
<ollehar> Drup: whitequark: there's good programs to check to C code with, like splint and scan-build (clang)
<azure_balls> do I need some sort of anonymous parameter?
<Drup> azure_balls: it look partially right
<whitequark> ollehar: there's good hospitals to treat your head wound after you shoot yourself with a gun
<Drup> azure_balls: so, the issue is that the sequencing operator ";" accept something of type 'a but warn if it's not unit
<Drup> and you shouldn't use it if something is not of type unit.
<azure_balls> But why should this not be unit? The type definition says it's unit...
<Drup> azure_balls: "unit Lwt.t"
<Drup> Different.
<azure_balls> aha
<Drup> It's a thread that returns something of type unit
<Drup> not a ()
<azure_balls> Damn those developers who screwed a newbie by opening Lwt without explaining the implications!
<azure_balls> hmmm
<Drup> yeah, I personally never open Lwt
<azure_balls> So what I really want to do is have a function that spawns two listen threads
<azure_balls> and has a return type of unit
<Drup> azure_balls: look at Lwt.async
<azure_balls> or Lwt.unit
<azure_balls> hmmm ok
<Drup> if you really want something than runs in the background
<azure_balls> Well, about that.. this is supposed to be in a Mirage unikernel
<azure_balls> Which IIRC *does* handle threads
<azure_balls> well, it must
<azure_balls> but I have no idea if Async is supported
<whitequark> Mirage has no threads.
<Drup> and Async is not supported, because Async only works on unix
<Drup> (or only linux ?)
<azure_balls> whitequark: well, it's a single-threaded runtime, but from what I gather it essentially multiplexes Lwt threads
<Drup> azure_balls: yeah, that's sort of the point of Lwt threads
<Drup> If I understand what you mean "multiplexes"
<whitequark> azure_balls: yeah, Lwt works on it, but Lwt isn't threads
<azure_balls> But even if I dumb down my code to only spawn one listener thread I still have a type error: "N.listen net0 (
<azure_balls> N.write net1
<azure_balls> but an expression was expected of type 'a Lwt.t"
<azure_balls> )" (note no semicolon) gives "Error: This expression has type M1.E.netif -> unit Lwt.t
<Drup> (well, Lwt abusively call 'a Lwt.t a thread)
<toolslive> maybe be should start using the name "fiber" for what Lwt gives you (and rename the library ;))
<azure_balls> sure, but I don't really care about the distinction between true symmetric processing and separate execution contexts for this example, at least not yet ;)
<Drup> azure_balls: that's inconsistent with the type you gave earlier, can you pastebin the whole thing ?
<whitequark> Lwt "threads" are not preemptible
boogie has joined #ocaml
<azure_balls> Sure
<azure_balls> ^ that's "my" version
<azure_balls> for reference...
<azure_balls> is the verified working mirage-skeleton I based the above off of
<Drup> oh god that's some ugly code x)
<azure_balls> (yes, I don't do any TCP/IP stuff, but that's not the point)
<azure_balls> heh
<toolslive> I think racket has done it right.... you have threads, futures and places....
<azure_balls> well, I have very little idea what I'm doing (yet), and any criticism of the original should be directed to #mirage :P
SethTisue has joined #ocaml
jwatzman|work has joined #ocaml
<Drup> azure_balls: can you pastebin the exact (and complete) error message when you compile this ?
<azure_balls> Sure
<azure_balls> Oh
<azure_balls> my very many apologies
<Drup> Ok, as I expected
<Drup> the error is on another file. :D
<azure_balls> disregard this error for now... I forgot to change the interface in the Mirage-generated file
<azure_balls> :)
jonludlam has quit [Quit: Coyote finally caught me]
<azure_balls> heh
<azure_balls> interestingly enough... it compiles
<azure_balls> OK, so now my problem is really getting the typechecker to approve creating two of these listen calls. As noted before, ';' doesn't cut it as it expects type 'unit' but N.listen returns 'unit Lwt.t'
<Drup> (note that the fact ";" doesn't accept anything else than unit in an option of the compiler, not the default)
<Drup> (but it's a good option when you are doing lwt things)
<azure_balls> right
<azure_balls> well, passing this to Lwt.ignore_result seems to do the trick
<azure_balls> it compiles at least
<Drup> azure_balls: what do you want to return, once you have swapend the two tasks ?
<azure_balls> let's see if it actually does what is intended (0.1% chance :P)
<Drup> spawned*
<azure_balls> Nothing, really
<Drup> do you want to block until the task is finished ?
<azure_balls> I just want to have these two tasks called-back on network interface receive, and transmit to the other
<azure_balls> Yes, definitely
<azure_balls> But I don't think I need to do anything special to do that, right? The original (http://pastebin.com/09jTCztL) does not do anything special, though I guess the lack of semicolon/ignore_result makes a difference
<Drup> you have two tasks, do you want to block until one of them is finished, or the two ?
<azure_balls> Nonono, sorry, I want to block until both tasks finish (which is never)
<Drup> if you don't want to block, then http://ocsigen.org/lwt/2.4.3/api/Lwt#VALasync
<azure_balls> hmmm OK
<azure_balls> so maybe I should do something like Lwt.join([N.listen net0 (); N.listen net1 ()])
<Drup> Indeed
<azure_balls> OK, let me test what I have first, then I'll try that
<azure_balls> thanks for all your help
eugene_klm has joined #ocaml
BitPuffin has joined #ocaml
<azure_balls> hmmm... not so much. needs more fiddling. I have to attent to some other business for now, but thanks again to everyone who helped, especially Drup :)
<azure_balls> ciao
zpe has quit [Remote host closed the connection]
ocp has quit [Ping timeout: 240 seconds]
psy has quit [Disconnected by services]
psy_ has joined #ocaml
boogie has quit [Quit: Leaving...]
BitPuffin has quit [Ping timeout: 245 seconds]
rossberg__ has quit [Ping timeout: 272 seconds]
badkins has joined #ocaml
ysz has joined #ocaml
eikke has joined #ocaml
seanmcl has joined #ocaml
q66 has joined #ocaml
ysz has quit [Quit: This computer has gone to sleep]
ysz has joined #ocaml
marynate has quit [Quit: Leaving]
kakadu has quit [Quit: Page closed]
dsheets has quit [Ping timeout: 245 seconds]
malo has joined #ocaml
shinnya has joined #ocaml
ygrek has quit [Ping timeout: 255 seconds]
ygrek has joined #ocaml
zpe has joined #ocaml
tac_ has joined #ocaml
hhugo has quit [Quit: hhugo]
zpe has quit [Ping timeout: 260 seconds]
ygrek has quit [Ping timeout: 272 seconds]
shinnya has quit [Ping timeout: 244 seconds]
ysz has quit [Quit: This computer has gone to sleep]
oscar_toro has quit [Ping timeout: 272 seconds]
larhat has quit [Quit: Leaving.]
ontologiae has joined #ocaml
artagnon has left #ocaml [#ocaml]
WraithM has joined #ocaml
ollehar has quit [Ping timeout: 245 seconds]
kakadu has joined #ocaml
manizzle has joined #ocaml
holomorph has joined #ocaml
manizzle has quit [Remote host closed the connection]
manizzle has joined #ocaml
morphles has joined #ocaml
appd_ has joined #ocaml
appd has quit [Ping timeout: 255 seconds]
hhugo has joined #ocaml
nojb has joined #ocaml
dch has joined #ocaml
<dch> it seems opam’s shell script does weird things, taking over my perl, and also fiddling with MANPATH. Is this necessary, and can I ask it not to do this by default?
nojb has quit [Read error: Connection reset by peer]
nojb has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
SethTisue has quit [Ping timeout: 244 seconds]
appd_ has quit [Remote host closed the connection]
Submarine has joined #ocaml
cthuluh has quit [Ping timeout: 260 seconds]
holomorph has left #ocaml [#ocaml]
slash^ has quit [Read error: Connection reset by peer]
badkins has quit [Remote host closed the connection]
cthuluh has joined #ocaml
hhugo has quit [Quit: Leaving.]
<hnrgrgr> dch: it should not "taking over your perl", it should just extend '@INC'. The same for MANPATH, it should be extending the list of search directories.
<dch> hnrgrgr: I see what it’s doing now, there are two inits happening, one that opam added, and another via a prezto zsh extension, I have disabled the first and will look at the second.
<dch> will ocaml work without changing PERL5LIB and MANPATH?
<hnrgrgr> Yes, it would. But you won't be able to access OCaml man pages. And some (rare) opam packages also install some perl li
toolslive has quit [Quit: Leaving]
<dch> hnrgrgr: this is on FreeBSD BTW. The perl5 library isn’t an issue as you point out, the MANPATH one is … odd. It shouldn’t break anything but it does
<dch> MANPATH=/home/dch/.opam/system/man:
<dch> breaks all manpages on FreeBSD.
<dch> weird.
<dch> ok, not an ocaml problem, I need to find a way to stop the zsh module being loaded, or a workaround for the manpage thing.
<dch> hnrgrgr: thanks for your help!
badkins has joined #ocaml
larhat has joined #ocaml
<hnrgrgr> dch: your welcome. For manpath, according to manpath(1), it seems that the correct behaviour on FreeBSB is not to set MANPATH. The correct MANPATH will be infered from your PATH.
Hannibal_Smith has joined #ocaml
Sim_n has joined #ocaml
jonludlam has joined #ocaml
Simn has quit [Ping timeout: 260 seconds]
ian3 has joined #ocaml
ian3_ has joined #ocaml
appd has joined #ocaml
ian3 has quit [Ping timeout: 255 seconds]
ian3 has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
ian3__ has joined #ocaml
ian3_ has quit [Ping timeout: 255 seconds]
Sim_n is now known as Simn
ian3 has quit [Ping timeout: 260 seconds]
ian3__ is now known as ian3
ollehar has joined #ocaml
sepp2k has quit [Quit: Konversation terminated!]
appd has quit [Quit: Leaving...]
cago has joined #ocaml
MercurialAlchemi has quit [Remote host closed the connection]
ysz has joined #ocaml
MercurialAlchemi has joined #ocaml
morphles has quit [Ping timeout: 272 seconds]
ontologiae has quit [Ping timeout: 240 seconds]
cago has quit [Quit: cago]
sheijk has joined #ocaml
nojb has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
nojb has joined #ocaml
ggole has quit []
WraithM has quit [Ping timeout: 245 seconds]
ysz has quit [Quit: This computer has gone to sleep]
manud has joined #ocaml
larhat has quit [Quit: Leaving.]
_andre has quit [Quit: leaving]
WraithM has joined #ocaml
manud has quit [Quit: manud]
Arsenik has joined #ocaml
smondet has quit [Quit: leaving]
smondet has joined #ocaml
testcocoon has quit [Quit: Coyote finally caught me]
ian3_ has joined #ocaml
ian3__ has joined #ocaml
testcocoon has joined #ocaml
ian3 has quit [Ping timeout: 260 seconds]
ian3__ is now known as ian3
ian3_ has quit [Ping timeout: 272 seconds]
axiles has quit [Remote host closed the connection]
eikke has quit [Ping timeout: 245 seconds]
demonimin_ has quit [Ping timeout: 260 seconds]
badkins has quit [Remote host closed the connection]
eikke has joined #ocaml
eikke has quit [Ping timeout: 245 seconds]
eikke has joined #ocaml
ollehar has quit [Ping timeout: 258 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
seanmcl has joined #ocaml
Arsenik has quit [Remote host closed the connection]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
rfk has joined #ocaml
tane has quit [Quit: Verlassend]
shinnya has joined #ocaml
jonludlam has quit [Quit: Coyote finally caught me]
MercurialAlchemi has quit [Ping timeout: 272 seconds]
kakadu has quit [Quit: Konversation terminated!]
nlucaroni has quit [Quit: leaving]
shinnya has quit [Ping timeout: 260 seconds]
nojb has quit [Ping timeout: 255 seconds]
<Denommus> which GUI toolkit to use with OCaml? Gtk?
<azure_balls> Python
<azure_balls> Oops, that's not a toolkit...
shinnya has joined #ocaml
<Drup> Denommus: lablgtk ?
<Denommus> Drup: ok
jao has quit [Remote host closed the connection]
nop0x07bc has joined #ocaml
eugene_klm has quit [Ping timeout: 255 seconds]
<Denommus> uh, this example is giving me a segfault: https://ocaml.org/learn/tutorials/introduction_to_gtk.html
* Drup blame adrien.
azure_balls has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<dmbaturin> Drup: adrien is the lablgtk maintainer?
<Drup> yeah
<Drup> there is a tutoriel on the official lablgtk website, it's supposed to be uptodate
ygrek has joined #ocaml
<Denommus> Drup: I'll check
shinnya has quit [Ping timeout: 245 seconds]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
<Denommus> maybe it's a problem with my Gtk version?
<Denommus> that would be weird, though, Gtk2Hs works just fine
<Drup> that's the official website.
<Drup> the readme is the updated thing
* Drup blames adrien more.
ygrek has quit [Ping timeout: 255 seconds]
<Drup> actually, I remember him linking some other tutorial he did, but it's not linked here
<Denommus> Drup: uh
<Denommus> Drup: I think the problem is that I'm trying to compile it with oasis
<Denommus> Drup: if I run the example with the lablgtk2 executable, it works
ian3_ has joined #ocaml
<dmbaturin> That tutorial segfaults for me too.
badon has joined #ocaml
* dmbaturin joins blaming adrien
<Denommus> dmbaturin: Drup: using lablgtk2.auto-init instead of lablgtk2 as a dependency in _oasis works
<Drup> yeah, except you shouldn't use auto-init
manizzle has quit [Ping timeout: 255 seconds]
<dmbaturin> And it's not a reason for the tutorial to not work. :)
<Drup> start by "let locale = GtkMain.Main.init ()"
<Drup> and you shouldn't need auto-init
ian3 has quit [Ping timeout: 272 seconds]
ian3_ is now known as ian3
<Drup> Denommus: see the paragraph "How to compile and link " in the readme
<Denommus> Drup: yup, that works
<dmbaturin> Does lablgtk work on OS X, by the way?
<Denommus> now I just need to figure out how to use it with React :-D
<Drup> I suppose
<Drup> Denommus: if you speak french, adrien did a presentation about it on some previous OUPS
<Denommus> Drup: I don't
<Drup> (it = lablgtk + React)
<dmbaturin> Maybe there's a "French for ocaml programmers" tutotial somewhere? :)
<Drup> sure
<Drup> read the compiler
<Drup> there are enough comments in french in it, I'm sure you'll get it, at some point :D
<Denommus> I wish I spoken French, it's a beautiful language. But I only speak Portuguese
<Drup> it's beautiful only because you don't speak it. :D
<dmbaturin> Well, there's a lot of interesting stuff written in french.
nop0x07bc has quit [Quit: WeeChat 0.4.3]
<Drup> (seriously, Portuguese is quite close, so picking up french if you are fluent in portuguese shouldn't be too hard)
<Denommus> Drup: Brazilian Portuguese is my native language, and as far as I have seen of French, it's nowhere near it XD
<Denommus> Drup: the pronounciation is just too different. Maybe to someone from Portugal it would be closer
<Denommus> Drup: (but then, I don't understand European Portuguese)
<Drup> ah, right
<Drup> I was thinking european protuguese
<dmbaturin> The works XX century french mathematicians and philosophers alone probably justify learning french.
<Drup> Didn't know the two were so different
<Denommus> well, gramatically they're basically the same, and there are only some different words
<Denommus> but the accent is different enough for most Brazilian folks that listen to it find it difficult
<Denommus> our language had too much African and native brazilian influence
Hannibal_Smith has quit [Quit: Sto andando via]
<dmbaturin> I like french poets too, especially Baudelaire and Aloysius Bertrand, but I only read them translated.
<dmbaturin> (And I hope I spelled them correct, which is unlikely)
NoNNaN has joined #ocaml
Simn has quit [Quit: Leaving]
<dmbaturin> Anyway, guess I should try lablgtk on OS X and windows. If it works on all platforms alike, I'd get to writing some GUI stuff I planned long ago, but never started because I didn't want to use different languages for different platforms (and use languages that are going to turn me to drinking).
boogie has joined #ocaml
<Drup> dmbaturin: be aware that gtk look quite horrible on windows
teknozulu has joined #ocaml
wiml has joined #ocaml
<dmbaturin> Drup: Well, not Tk level horrible. :)
<wiml> n00b style question: I have a loop where the exit condition is in the middle, i.e. in C I'd write it as "for(;;){ ... stuff ... if (...) break; ... stuff ... }". Ocaml resources on the net mostly suggest using an exception to exit the loop. The other way I can see if to use a mutable ref to store either a termination flag or the intermediate variables in the loop body. What would be most readable and idiomatic to other ocaml programmers?
madroach has quit [Ping timeout: 250 seconds]
<dmbaturin> wiml: What is the loop doing?
<nicoo> dmbaturin: EFL look rather nice on Windows
<dmbaturin> nicoo: EFL?
<nicoo> dmbaturin: adrien should have some screenshots around
<nicoo> dmbaturin: Enlightment Foundation Libraries, or something like that
<nicoo> Yup, that's it
<dmbaturin> Oh, enlightement. This is the toolkit E17 desktop environment uses?
madroach has joined #ocaml
<nicoo> dmbaturin: That look not-native, but they look nice (which is one step up from GTK and Tk)
<nicoo> Yup, it is the graphical toolkit in Enlightment
<Drup> wiml: I would probably .. not use a loop to begin with.
<wiml> dmbaturin: Computing a sequence of values, then stuffing each one into the appropriate place in a data structure.
<dmbaturin> I used to use it (the DE) for a while, wasn't aware the toolkig it crossplatform.
<nicoo> And adrien is working on making ocaml-efl more reliable on Windows (he ran into weird threading issues)
<Drup> wiml: can you show the code ?
<Denommus> dmbaturin: if my plan goes right, most of my code will be reactive signals and behaviors, and it won't be very difficult to use more than one GUI toolkit
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
ian3_ has joined #ocaml
ian3 has quit [Ping timeout: 260 seconds]
ian3_ is now known as ian3
NoNNaN has quit [Remote host closed the connection]
<wiml> Drup: Wel... for discussion's sake, let's say Im' reading a series of records from a file or socket, building a list of them, and stopping when complicated_function of the values I've read returns false.
<wiml> Right now I just have while complicated_function do read thing etc done but that puts the operations in a really unintuitive order in the source.
<Drup> let rec foobar () = let next = input_line file in put_in_datastructure next ; let b = complicated_function next in if b then foobar () else ()
<Drup> no need to involve exceptions for that :)
<Drup> (you can even use a functional data structure then, and pass it along :p)
yotam has quit [Quit: Connection closed for inactivity]
<wiml> Yeah, exceptions seem like a screwy tool for this job, but they're the suggestion I kept finding on the web for this kind of loop.
<wiml> I guess I'll rewrite it in tail recursive style and see if it's any more readable. The data structure is actually pretty amenable to a functional update like that, so that's a plus I guess.
<Drup> well, that's the easy answer, which produce imperative codes
<Drup> It's perfectly fine, it's just not what I would do
<wiml> Hey, I'm pretty pragmatic :) if mutable refs and imperative style is reasonable here I'll do it. Exceptions seemed kind of overkill though.
<Drup> exceptions are fine, they are quite lightweight in ocaml anyway
darkf has joined #ocaml
vanila has quit [Quit: Leaving]