ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.1 announcement at http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
ollehar has quit [Read error: Connection reset by peer]
kdef has quit [Quit: Leaving]
ollehar has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
badon has joined #ocaml
AltGr has joined #ocaml
javamonn has joined #ocaml
keen_______ has quit [Read error: Connection reset by peer]
javamonn has quit [Remote host closed the connection]
Algebr has quit [Read error: Connection reset by peer]
keen_______ has joined #ocaml
ousado has quit [Ping timeout: 244 seconds]
wraithm has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
wraithm has quit [Quit: leaving]
javamonn has joined #ocaml
ygrek has quit [Ping timeout: 265 seconds]
ousado has joined #ocaml
ousado has quit [Changing host]
ousado has joined #ocaml
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
claudiuc has quit [Ping timeout: 245 seconds]
rwmjones has quit [Read error: Connection reset by peer]
rwmjones has joined #ocaml
Nijikokun_ has joined #ocaml
Nijikokun has quit [Ping timeout: 244 seconds]
Nijikokun_ has quit [Ping timeout: 245 seconds]
Nijikokun has joined #ocaml
jamesllondon has quit [Read error: Connection reset by peer]
jamesllondon has joined #ocaml
<destrius_> i'm noticing what seems to me to be unusual behaviour in List.slice: List.slice [1;2;3] 0 0 --> [1;2;3]
<destrius_> is there a reason why that returns the full list instead of an empty list?
swgillespie has joined #ocaml
c74d3 is now known as c74d
<yminsky> List.slice is a confusing function.
<yminsky> Probably we should remove it from the API.
<yminsky> It's meant to be python-style slicing. So by doing List.slice[1;2;3] 0 (-1) you'll get [1;2]. And List.slice [1;2;3] (-2) 0 will give you [2;3].
<yminsky> But I agree it's confusing.
<yminsky> take, drop and sub are clearer.
javamonn has quit [Read error: Connection reset by peer]
javamonn has joined #ocaml
small-wolf has joined #ocaml
dubosec has joined #ocaml
<dubosec> this might be too complicated of a question, but I am trying to create a command line version of a simple craps game in ocaml, and I know that read_line lets the user input a string (bytes, actually). Is there some way to take the bytes that the user inputs--such as "roll"--to trigger another function?
<dubosec> ideally, the user typing "roll" will trigger the random number generator
Nijikokun has quit [Ping timeout: 245 seconds]
<apache2> pattern matching?
<dubosec> I mean, I imagine I could do something like "let roll_state = read_line ();;
<dubosec> but that only creates a value for roll_state; it doesn't make anything happen
<dubosec> can a conditional check the value of a variable, like roll_state, or am I going about it the wrong way?
sigjuice has joined #ocaml
<Drup> as apache2 said, pattern matching.
<apache2> match read_line () with "roll\n" -> bla () | "othercommand\n" -> foo ()
<apache2> for example
<dubosec> ah, I understand
<dubosec> thanks guys, I appreciate it
<apache2> np
darkf has joined #ocaml
<dmbaturin> dubosec: There are also guarded patterns. match foo with <pattern> when <condition> -> ...
<dubosec> there is more of an etiquette question, but is it okay to ask for help with writing programs here, or is this more for asking generic ocaml questions?
<dmbaturin> If etiquette questions could have boolean answers, the world would be a very different place.
<dubosec> ha, true. Well, are you okay with questions about writing specific programs/
<dmbaturin> My opinion is that asking for help with writing programs is fine as long as you don't ask to write the program for you.
MrScout has quit [Ping timeout: 245 seconds]
<Drup> dubosec: personally, I prefer not to answer other people's course assignments ;)
<dubosec> that makes since. I'm not in school, so no worries about course assignments from me :)
<dubosec> seeing it written out now, the pattern matching makes a lot of sense
<dmbaturin> In every ambiguous situation use pattern matching.
<dmbaturin> Actually, it's very pervasive. Even a let binding is always a pattern matching.
fraggle-boate_ has joined #ocaml
MrScout has joined #ocaml
tg has quit [Ping timeout: 272 seconds]
<destrius_> yminsky: ah ok, seems like .sub will do what i need. thanks!
fraggle-boate has quit [Ping timeout: 264 seconds]
<destrius_> yminsky: anyway i think it can be useful to emulate python's slicing, but the function doesn't really do so faithfully at the moment which adds to the confusion
tg has joined #ocaml
<yminsky> Indeed.
<apache2> dubosec: you can also use "if ... else ... then" in ocaml, but pattern matching is usually easier to read/maintain, and ocaml pattern matching uses a subset of ocaml that can be optimized by the compiler
MrScout has quit [Remote host closed the connection]
small-wolf has quit [Ping timeout: 240 seconds]
n3ss3s has joined #ocaml
idegen has quit [Quit: Leaving.]
dubosec has quit [Quit: Leaving]
<n3ss3s> Successfully rubberducked. Thanks #ocaml
osa1 has quit [Ping timeout: 245 seconds]
<n3ss3s> (problem solved before pressing enter :p)
contempt has quit [Ping timeout: 252 seconds]
contempt has joined #ocaml
<struktured> noice
javamonn has quit [Remote host closed the connection]
badkins has quit []
<dmbaturin> n3ss3s: Cardboard camls should be better than rubber ducks. http://cdn.shopify.com/s/files/1/0112/8702/products/qhqfdi6dv2arep1_800T1_1024x1024.jpg?5922
MrScout has joined #ocaml
struktured has quit [Ping timeout: 245 seconds]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
struktured has joined #ocaml
MrScout has quit [Read error: Connection reset by peer]
MrScout has joined #ocaml
A1977494 has joined #ocaml
A1977494 has left #ocaml [#ocaml]
MrScout has quit [Ping timeout: 245 seconds]
MrScout_ has joined #ocaml
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
mengu has joined #ocaml
mengu has joined #ocaml
mengu has quit [Changing host]
<n3ss3s> oh gawd
<n3ss3s> I just discovered the whole printf/type safety/format6 spaghetti
mengu has quit [Ping timeout: 264 seconds]
MrScout_ has quit [Ping timeout: 245 seconds]
ygrek has joined #ocaml
<n3ss3s> Ugh. I want to use sprintf to replace things in a URL, which contains some %'s. sprintf is picking up some of the hexcodes (%3A for example) as "Bad conversion %A". What would you suggest as the most sane way to go about this?
badon has quit [Ping timeout: 252 seconds]
<n3ss3s> Should I just split the URL at the points where I want to insert stuff, and concatenate?
badon has joined #ocaml
MercurialAlchemi has joined #ocaml
<flux> n3ss3s, replace each % in the string literal with %%
<n3ss3s> will the result of sprintf still have single %'s?
<flux> yes
<n3ss3s> sweet. let me try
<n3ss3s> yup. thanks
<n3ss3s> flux: So it worked in utop, but ocamlopt gives a very unsavory error
<n3ss3s> the error being http://pastebin.com/Jqap28B0
mengu has joined #ocaml
n3ss3s has quit [Ping timeout: 255 seconds]
ygrek has quit [Ping timeout: 252 seconds]
jamesllondon has quit [Ping timeout: 250 seconds]
Simn has joined #ocaml
psy_ has quit [Ping timeout: 250 seconds]
dsheets has quit [Ping timeout: 265 seconds]
struktured has quit [Ping timeout: 272 seconds]
ontologiae has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
ontologiae has quit [Ping timeout: 256 seconds]
dsheets has joined #ocaml
mengu__ has joined #ocaml
mengu has quit [Ping timeout: 248 seconds]
Haudegen has joined #ocaml
ygrek has joined #ocaml
swgillespie has joined #ocaml
swgillespie has quit [Client Quit]
matason has joined #ocaml
Submarine has quit [Remote host closed the connection]
jonludlam has quit [Ping timeout: 264 seconds]
ggole has joined #ocaml
dav has quit [Ping timeout: 256 seconds]
Gama11 has joined #ocaml
dav has joined #ocaml
dsheets has quit [Ping timeout: 272 seconds]
oscar_toro has quit [Ping timeout: 265 seconds]
jyc has quit [Ping timeout: 256 seconds]
thomasga has joined #ocaml
jyc has joined #ocaml
thomasga has quit [Quit: Leaving.]
mengu__ has quit [Ping timeout: 250 seconds]
dsheets has joined #ocaml
thomasga has joined #ocaml
dsheets has quit [Ping timeout: 264 seconds]
testcocoon has quit [Ping timeout: 246 seconds]
aubergines has joined #ocaml
testcocoon has joined #ocaml
oscar_toro has joined #ocaml
thomasga has quit [Quit: Leaving.]
milosn has quit [Ping timeout: 255 seconds]
lordkryss has joined #ocaml
axiles has joined #ocaml
m____ has joined #ocaml
asQuirreL has joined #ocaml
dav has quit [Ping timeout: 256 seconds]
dav has joined #ocaml
Gama11 has quit [Read error: Connection reset by peer]
A1977494 has joined #ocaml
mort___ has joined #ocaml
AltGr has left #ocaml [#ocaml]
A1977494 has left #ocaml [#ocaml]
jonludlam has joined #ocaml
Kakadu has joined #ocaml
thomasga has joined #ocaml
dsheets has joined #ocaml
bjorkintosh has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
rand000 has joined #ocaml
Haudegen has joined #ocaml
milosn has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
TheLemonMan has joined #ocaml
milosn has joined #ocaml
thomasga has quit [Quit: Leaving.]
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
thomasga has joined #ocaml
sdothum has joined #ocaml
<Leonidas> lets see if whitequark reacts to bug reports
c74d has quit [Ping timeout: 276 seconds]
struktured has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
c74d has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
_andre has joined #ocaml
thomasga has quit [Quit: Leaving.]
ygrek has quit [Ping timeout: 256 seconds]
Hannibal_Smith has joined #ocaml
jonludlam has quit [Ping timeout: 264 seconds]
<RichN> Does anyone have experience with LWT?
milosn has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
<reynir> A bit
octachron has joined #ocaml
osa1 has joined #ocaml
milosn_ has joined #ocaml
<RichN> Given: Lwt.pick [recv s; timeout 2.0], if data arrives over the socket, the timeout thread is cancelled. If the timeout occurs, the recv is cancelled.
<RichN> Now if I change it to: Lwt.pick [send s b >> recv s; timeout 2.0], I want the send/recv transaction to entirely complete or not. I guess 'send' is a bad example to use since you can't un-send if the timeout occur.
milosn_ has quit [Client Quit]
milosn__ has joined #ocaml
<RichN> My question is, though, if I make a more complicated thread by composing simpler ones and then use it in a Lwt.pick list, what happens when a thread is partially complete when another fully terminates?
milosn__ is now known as milosn
<companion_cube> I don't think you can do such transactions
<companion_cube> even at the OS level, you might read/receive successfully, and then block on write/send
<companion_cube> block for arbitrarily long that is
<ousado> you can ensure at protocol level that a transaction terminates in a given time frame
<reynir> ls
<reynir> oops
<ousado> if you don't receive the final ack within that period, whether stuff is in send/recv queues or not, it failed, as far as your application is concerned
<RichN> I can agree with that.
<ousado> of course the protocol has to have a notion of such a final acknowledgement
<RichN> What about something like "recv s b >> xlat b >>= Lwt_mvar.put". I want to read a chunk of data, parse it into an internal type and write to an MVar.
<RichN> The recv and the Lwt_mvar.put could block.
<RichN> If I used Lwt.choose instead of Lwt.pick, could I re-apply the partially complete thread?
milosn has quit [Ping timeout: 256 seconds]
<ousado> hm, what does "block" mean in this context? the menaing "blocking" in an async IO context is kind of occupied by "syscalls that don't return immediately"
<ousado> *meaning
<ousado> *meaning of, even
<RichN> I guess the correct term is "sleep" until it can complete (either data is in the socket or the MVar is empty.)
<ousado> OK, I'd call that waiting for notification
TheLemonMan has quit [Remote host closed the connection]
<RichN> So in the example I gave about, there are two threads that may end up waiting for notification.
<RichN> above*
nojb has joined #ocaml
<RichN> Right now, I'm using Lwt.pick with a list of simple threads (not composition) and LWT works great. I was curious if some sort of composition was possible because, in some cases, it would clean up the code.
<ousado> I have very little experience with Lwt, but I think you want join instead of choose if you care about all threads
<nojb> RichN: you have to be careful - Lwt's cancellation semantics are not very clear
<nojb> non-atomic threads may get cancelled midway
<nojb> if you care about atomicity then you have to do it explicitly in your code
<RichN> Ah, so maybe: Lwt.protect (recv >> xlat >>= Lwt_mvar.put) would be better? Would that have a chance of working? :)
<RichN> (I'm abbreviating the recv call...)
<nojb> That thread cannot be cancelled at all
Submarine has joined #ocaml
<RichN> Rats. That's right; once it's waiting for recv, Lwt.pick has no hope of cancelling it.
<ousado> "protected thread creates a new cancelable thread which behave as thread except that cancelling it does not cancel thread" - not very clear indeed
<RichN> (Since it's "inside" the scope of Lwt.protect.)
<RichN> The LWT documentation is rough in spots. I've contributed a few patches to make it clearer. :)
<nojb> indeed
jonludlam has joined #ocaml
<RichN> I don't have the expertise to document how Lwt.protect internals work.
<ousado> I think protected just exists to be able to reuse code for cancelable threads for threads you don't want to be cancelled ever
<RichN> I was hoping the implementation was correct, even if the docs were confusing.
<ousado> although.. the type is the same?
<nojb> cancellable threads should be used very carefully - their semantics are not clear - I would suggest only using them for atomic threads
<RichN> I wonder if: (recv >> Lwt.protect (xlat >>= Lwt_mvar.put)) is the way to go.
<RichN> The recv is cancellable. If it terminates, then the uncancellable part begins.
osa1 has quit [Ping timeout: 245 seconds]
<nojb> if that 's what you want to do then there is a useful idiom to keep in mind Lwt.pick [ recv >>= fun () -> return `Ok | timeout >>= fun () -> return `Timeout ] >>= function `Ok -> xlat >>= Lwt_mvar.put | `Timeout -> ...
matason has quit []
<RichN> Thanks. Maybe I'm trying to do too much in my pick list.
<RichN> Thanks for the discussion and help! (Time to go to work.)
oscar_toro has quit [Ping timeout: 252 seconds]
jonludlam has quit [Ping timeout: 264 seconds]
matason has joined #ocaml
Hannibal_Smith has quit [Quit: Leaving]
thomasga has joined #ocaml
jonludlam has joined #ocaml
<companion_cube> nojb: do you think it would be better to use continuations, in this particular style?
<companion_cube> particular case*
<companion_cube> pick' [ recv, (fun () -> .....); timeout, (fun () -> ... )]
<companion_cube> because you're going to do different things in each case anyway
<nojb> it is equivalent :)
nojb_ has joined #ocaml
<nojb_> sorry got disconnected
<nojb_> I find the control flow easier to follow with the first appraoch
badkins has joined #ocaml
nojb has quit [Ping timeout: 255 seconds]
nojb_ is now known as nojb
osa1 has joined #ocaml
idegen has joined #ocaml
idegen has quit [Read error: Connection reset by peer]
idegen has joined #ocaml
<nojb> what is the meaning of the second argument of Asttypes.Const_string ?
<quaranteigne> it's the "label" for literals of the form {label| ... |label}
<nojb> got it, thanks!
thomasga has quit [Quit: Leaving.]
dsheets has quit [Ping timeout: 255 seconds]
dsheets has joined #ocaml
mcclurmc_ has joined #ocaml
mcclurmc has quit [Ping timeout: 272 seconds]
javamonn has joined #ocaml
johnelse has joined #ocaml
hellome has quit [Remote host closed the connection]
dav has quit [Ping timeout: 250 seconds]
dav has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
thomasga has joined #ocaml
nojb has quit [Quit: nojb]
nojb has joined #ocaml
thbrcr has joined #ocaml
m____ has quit [Ping timeout: 246 seconds]
<thbrcr> There's a problem with aspcud/cmake in OS X and because of this I cannot install OPAM via Homebrew. Where should I make a bug report?
<nojb> what's the problem ? it works fine for me ...
<thbrcr> aspcud fails to install, see: https://gist.github.com/22683912122b152e2774
<nojb> are you installing aspcud via homebrew ?
<thbrcr> Yes
<thbrcr> Well, I tried, at least.
<flux> thbrcr, if you just want it to work regardless of aspcud you can just use this: http://cudf-solvers.irill.org/index.html
<nojb> did you do 'brew update' ?
<nojb> (there used to be problems with aspcud and homebrew in the past)
<thbrcr> Yes, I did a clean install this morning and just installed Homebrew.
<thbrcr> Never had any problems in the past installing OPAM via Homebrew
lordkryss has joined #ocaml
<nojb> sorry - no idea ...
M__ has joined #ocaml
darkf has quit [Quit: Leaving]
thbrcr has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
mcclurmc_ has quit [Ping timeout: 255 seconds]
psy_ has joined #ocaml
nojb has quit [Quit: nojb]
milosn has joined #ocaml
thomasga has quit [Quit: Leaving.]
thomasga has joined #ocaml
thomasga has quit [Client Quit]
nojb has joined #ocaml
<M__> I have added open Lwt and open Lwt_unix, but i receive Unbound value when using >>
<M__> suggestion?
<nojb> >> is the syntax extension
<Drup> and it's equivalent to >>= fun () ->, so you could just use that
<nojb> you need to compile with the package lwt.syntax or lwt.ppx
<M__> thanks
ollehar has quit [Remote host closed the connection]
ollehar has joined #ocaml
Submarine has quit [Ping timeout: 264 seconds]
<pippijn> is it possible to upgrade opam using opam?
<pippijn> I'm trying to get opam to work on heroku
<pippijn> and it works, but it seems to be using an old repository, because 4.02.1 is not in the switch list (only 4.02.0dev+trunk)
<Drup> which version of opam ?
<pippijn> 1.0.0
<Drup> ok, that's very old
<Drup> which system is on heroku ? I'm not really familiar with it
<pippijn> I have no idea
<pippijn> some linux
<pippijn> I'm not even sure of that.. some unix-like system anyway
<pippijn> due to licensing, I'm reasonably sure it's not osx, so most likely linux
A1977494 has joined #ocaml
A1977494 has quit [Client Quit]
<pippijn> Drup: it's AWS
<Drup> hum
<Drup> I don't know, sorry. :(
<pippijn> so it's not possible to upgrade opam using opam?
<Drup> I never did it, so not sure
dsheets has quit [Ping timeout: 246 seconds]
dsheets has joined #ocaml
Hannibal_Smith has joined #ocaml
MrScout has joined #ocaml
dsheets has quit [Remote host closed the connection]
octachron has quit [Quit: Leaving]
shinnya has joined #ocaml
dsheets has joined #ocaml
mehdi has quit [Disconnected by services]
mehdi_ has joined #ocaml
slash^ has joined #ocaml
thbrcr has joined #ocaml
<thbrcr> So I "fixed" the problem with aspcud by using CUDF/cudf_remote_proxy. Thank you so much for the person who told me about it.
mort___ has quit [Ping timeout: 256 seconds]
thomasga has joined #ocaml
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
thomasga has quit [Client Quit]
thbrcr has quit [Remote host closed the connection]
thomasga has joined #ocaml
ollehar1 has joined #ocaml
oscar_toro has joined #ocaml
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
thomasga has quit [Quit: Leaving.]
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
matason has quit []
tg has quit [Ping timeout: 256 seconds]
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
Submarine has joined #ocaml
Submarine has joined #ocaml
matason has joined #ocaml
tg has joined #ocaml
thomasga has joined #ocaml
aubergines has quit [Quit: leaving]
matason has quit [Client Quit]
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
swgillespie has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
swgillespie has joined #ocaml
jwatzman|work has joined #ocaml
kdef has joined #ocaml
freling has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
<M__> what library do you recommend for a tcp-based client-server (muti-client) application? lwt_io.establish_server?
nojb has quit [Quit: nojb]
thomasga has quit [Quit: Leaving.]
<Leonidas> pippijn: as far as I know its not possible. opan developers say "use the binary" afaik.
nojb has joined #ocaml
Haudegen has joined #ocaml
shinnya has quit [Ping timeout: 264 seconds]
jonludlam has quit [Ping timeout: 264 seconds]
thomasga has joined #ocaml
ontologiae has joined #ocaml
nojb has quit [Quit: nojb]
thomasga has quit [Quit: Leaving.]
Nijikokun has joined #ocaml
kmicinski has joined #ocaml
<struk|work> getting a build error I do not know how to resolve..any pointers would be appreciated: https://gist.github.com/struktured/055377ffb0c7a26b3b1a
ollehar has quit [Remote host closed the connection]
ollehar has joined #ocaml
freling has quit [Quit: Leaving.]
<kmicinski> I'm trying to use sexplib with syntax extensions and ocamlbuild
<kmicinski> whenever I add a syntax(ocamlp4o) to my _tags I get
<kmicinski> ocamlfind: Using -syntax, but no package is selected specifying a preprocessor as required for -syntax
<kmicinski> I'm also using package(sexplib), but am I missing something here?
<bernardofpc> +1 for updating opam with opam, (old wish from like 2 weeks ago...)
<smondet> kmicinski: I think you need an argument to `-syntax`, like `-syntax camlp4o`
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<kmicinski> Hmm.... so I'm trying this via ocamlbuild, but it generates the command ocamlfind ocamldep -syntax camlp4o -package sexplib -package ppx_deriving -modules interpreter.ml > interpreter.ml.depends
<kmicinski> So I'm not sure what's happening, when I run that command manually I get an error, and yet there's clearly an argument to -syntax on the command line.
freling has joined #ocaml
<kmicinski> Even stranger, it works fine from within Merlin.
<struk|work> kmicinski: why are you adding camp4o w/o a camlp4 syntax extension?
<struk|work> kmicinski: maybe you mean to add "sexplib.syntax" as a package?
<kmicinski> When I only use sexplib.syntax I get the complier complaining that I have a syntax error
<struk|work> kmicinski: are you using the sexplib extensions?
<kmicinski> I am intending to, yes, and yet my question is: which flags do I need to add to my ocamlbuild "_tags" file to use the syntax extension.
<kmicinski> e.g., I use `with sexp`
<struk|work> well for starters, there's a chance it won't compile at all if you mix "with sexp" and "@@deriving foo" in the same module
<kmicinski> right, I have dropped deriving
<kmicinski> using exclusively sexplib.
<pippijn> Leonidas: that's kind of poor
<kmicinski> struk|work: it looks almost right, but it's pretty bitrotted, e.g., I'm not able to resolve `ocamlfind_query`
<kmicinski> I got to the poitn where I needed to include `Ocamlbuild_pack`
Hannibal_Smith has quit [Quit: Leaving]
djellemah_ has quit [Ping timeout: 265 seconds]
<kmicinski> Duh, ignore my last comment, I'm just not getting `run_and_open` to typecheck.
<kmicinski> alright, thanks for the pointer struk|work, with some tweaking I got it work, modulo some errors that are being generated by the syntax extension..
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
<struk|work> cool good luck
<struk|work> I avoid campl4 extensions like the plague these days
divyanshu has joined #ocaml
divyanshu has quit [Read error: Connection reset by peer]
<struk|work> argh got the good ol types aren't the same but appear to be compiler error..https://gist.github.com/struktured/c2dd85966f483f6ce620 apparently I need to understand phantom types
kmicinski has quit [Quit: Lost terminal]
dsheets has quit [Ping timeout: 256 seconds]
<ggole> The problem is scope escaping there, not whether the types are equal
dav has quit [Ping timeout: 256 seconds]
ggole has quit []
dav has joined #ocaml
M__ has quit [Ping timeout: 246 seconds]
<sheijk> struk|work: any chance you're aware of a ppx replacement for fieldslib? (random question of the day)
<struk|work> sheijk: great question, I think jane street may be replacing all their stuff with ppx eventually, possibly a year or two
<struk|work> ggole: I sort of gathered that's the issue but I don't have a clue on how to resolve it.
<sheijk> struk|work: yep, i sure hope so. but who knows how long it will really take as they can't just switch step-by-step
<struk|work> so anyone know how to resolve my scoping /phantom type issue?
nojb has joined #ocaml
nojb has quit [Client Quit]
javamonn has quit [Read error: Connection reset by peer]
<Drup> struk|work: need to see the code
javamonn has joined #ocaml
<struk|work> so the problem magically went aware in utop, but here is my original post on this (with link to source): http://irclog.whitequark.org/ocaml/2015-04-22#12499793;
Pepe_ has quit [Ping timeout: 246 seconds]
<struk|work> Drup: here's a self contained snippet with same problem (when run in utop at least) : https://gist.github.com/struktured/d1211d40f10112e4619c
ilia has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
<ilia> hello
MrScout has quit [Ping timeout: 245 seconds]
<ilia> I have a very beginner question
Nijikokun has quit [Ping timeout: 245 seconds]
<ilia> I am trying to declare a type
<ilia>
<ilia> type point =
<ilia> { id : int;
<ilia> x : int;
<ilia> y : int;
<ilia> z : int;
<ilia> pref : <type definition goes here>;
<ilia> cos_phi : float;
<ilia> cos_theta : float;
<ilia> mutable eff_modulo : float;
<ilia> };;
<ilia>
<ilia> pref is a pythonic dictionary int to int.
<ilia>
<ilia> how to implement it?
<zozozo> ilia: you can use a Mpa or a Hashtbl
<zozozo> *Map
<ilia> I was thinking about Map
<ilia> Thanks
ontologiae_ has joined #ocaml
<ilia> I tried this --> type dict = A of (int,int) Map.Poly.t with compare,sexp;;
<ilia> and put 'dict' as a type for pref. It did not work
ontologiae has quit [Ping timeout: 250 seconds]
matason has joined #ocaml
<zozozo> well, you have to make your module before you can use it
ollehar has quit [Remote host closed the connection]
<zozozo> the Map module has a fonctor, which takes an implementation of a type with a compare function and return the correponsindg Map module
<zozozo> so, to have a map from ints, you have to do something like :
kakadu_ has joined #ocaml
<zozozo> module M = Map.Make(struct type t = int let compare = compare end)
<zozozo> and then a map from int to int is represented by the type : int M.t
<ilia> let me try
dav has quit [Ping timeout: 264 seconds]
Algebr has joined #ocaml
<zozozo> ah, you seem to use Core, right ?
dav has joined #ocaml
<ilia> yes, I do open Core.Std
<zozozo> well then I suppose it'a a bit different
justgage has joined #ocaml
<ilia> it works!!
<justgage> Hey Ocamlers, I was wondering if there's any good library for date manipulation that you can recomend. I tried "calendar" and it didn't compile when I tried to install it via opam (I am a noob so I could have done it wrong)
<ilia> at least compilattion w/0 errors
<ilia> thanks
asQuirreL has quit [Ping timeout: 245 seconds]
matason has quit []
asQuirreL has joined #ocaml
<MercurialAlchemi> justgage: I would say calendar
<MercurialAlchemi> can you pastebin yoru error?
<justgage> Yes I can
<justgage> MercurialAlchemi: there you go
<MercurialAlchemi> justgage: looks like you are using a broken pinned package
<ilia> with core it does not work, it complains about not providing `t_of_sexp' and 'sexp_of_t'
<MercurialAlchemi> and this has a configure script
Nijikokun has joined #ocaml
<zozozo> ilia: well either provide these, or using the poly version of maps should also work
<justgage> Ok thank you MercurialAlchemi I think that fixed it
<ilia> zozozo, thanks. I am reading docs about how to provide these sexp_of_t,t_of_sexp
<zozozo> ilia: alternatively, something like : "pref : (int, int) Map.Poly.t;" in your type definition should work
ollehar has joined #ocaml
<ilia> thanks a lot, I am going to try it on toplevel as well
MrScout has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
dav has quit [Remote host closed the connection]
dav has joined #ocaml
MrScout has quit [Ping timeout: 245 seconds]
Nijikokun_ has joined #ocaml
<ilia> now it complains about Unbound module Core
Nijikokun has quit [Ping timeout: 256 seconds]
<zozozo> during compilation ?
<ilia> I think I have to provide the path through -I switch
<ilia> yes, during compilation
<zozozo> what do you use to compile ?
<zozozo> I think there is something like corebuild that can be used to compile things using Core
<ilia> ocamlc
<ilia> ocamlc -c <myfile.ml>
osa1 has quit [Ping timeout: 256 seconds]
<ilia> I read man for corebuild, I did not use it before
<zozozo> I think that corebuild should solve your problem in this case
<ilia> one more question, are the values in this dictionary sorted? so I can get key with max value or I have to create a module for this as well?
<zozozo> well values can be really anything actually, so they are not sorted
<ilia> thanks
<zozozo> you would need a more complex data structure to retrieve the key with max value
<ilia> can I retrive max key?
<zozozo> not directly
<zozozo> but if you fold over the map you can
<ilia> folding is a linear time process, right
ontologiae_ has quit [Ping timeout: 250 seconds]
<zozozo> right
<ilia> so I need more complex data structure
<zozozo> yeah sounds like you need some king of bijective map or something like that
<ilia> bijective map allows querying both keys and values, I just need to get max or min
<ilia> like a heap
<zozozo> right
<zozozo> there should be a heap somewhere in Core
Anarchos has joined #ocaml
<ilia> Thanks!
<ilia> ocamlfind ocamlc -thread -package core helped
<ilia> thank you!
osa1 has joined #ocaml
n3ss3s has joined #ocaml
TheLemonMan has joined #ocaml
<n3ss3s> Hey. I have a format string, which works with Printf functions in utop, but when I try to it I get an error, both string and error are at http://pastebin.com/hTWrfXTH
ollehar has quit [Remote host closed the connection]
<struk|work> n3ss3s: I can't see pastebin at work, but you have to pass a string literal to the formatter. most common issue. Eg. Printf.printf "" is good, but let f = "" in Printf.printf f is not
<n3ss3s> I have defined the string as a format type
<n3ss3s> let test_base: ('a, 'b, 'c) format =
<n3ss3s> and it works fine in utop, but not when compiling
ollehar has joined #ocaml
<n3ss3s> I have other format strings which work fine when compiling aswell, so I suspect there is something extremely annoying about this particular string I'm working with lol
freling has quit [Quit: Leaving.]
<apache2> 12
<struk|work> n3ss3s: can you post to gists instead so I can see it? curious
<n3ss3s> yup
MrScout has joined #ocaml
justgage has quit [Quit: Page closed]
<n3ss3s> oh shit
<struk|work> n3ss3s: compiled fine for me
<struk|work> n3ss3s: maybe the copy/paste fixed it
<n3ss3s> It's because I'm trying to sprintf a float into it, where I thought I was using a string
<struk|work> ah
<n3ss3s> (which is now clear in hindsight)
<struk|work> consider yourself lucky, in java etc. that would be a runtime exception :)
<n3ss3s> Hehe :p thanks though
_andre has quit [Quit: leaving]
badon has quit [Quit: Leaving]
jonludlam has joined #ocaml
Hannibal_Smith has joined #ocaml
ollehar has quit [Remote host closed the connection]
ollehar has joined #ocaml
mengu has joined #ocaml
Denommus has joined #ocaml
<Denommus> hi
<ilia> it looks like the heap from core is not polymorphic
<ilia> hi
<struk|work> ilia: ? how so? Heap.add;; - : 'a Heap.t -> 'a -> unit = <fun>
<Denommus> I ended up not doing any programming during my vacations. My library is still dead XD
<struk|work> Denommus: shame on you!
<ilia> I am wrong apparently
<Drup> struk|work: I looked, I'm not sure. It seems related to async's stuff, as you don't use GADTs here
<Drup> (and this error message is almost always GADT related)
<Denommus> struk|work: at least I finished two games and two Netflix series!
<struk|work> Drup: thanks for looking, regardless. If you can't figure it out though that makes me nervous
<Drup> struk|work: and I don't know anything about core/async
<struk|work> Drup: sure. I was hoping this is specific to phantom typeness though.
<Drup> it is, but you don't define phantom types, they are coming from async.
<struk|work> yeah..
nojb has joined #ocaml
ollehar1 has quit [Ping timeout: 276 seconds]
nojb_ has joined #ocaml
nojb has quit [Ping timeout: 250 seconds]
nojb_ is now known as nojb
milosn has quit [Read error: Connection reset by peer]
olibjerd has joined #ocaml
hilquias has joined #ocaml
milosn has joined #ocaml
osa1 has quit [Ping timeout: 256 seconds]
MercurialAlchemi has quit [Ping timeout: 244 seconds]
ericwa has joined #ocaml
claudiuc has joined #ocaml
Hannibal_Smith has quit [Remote host closed the connection]
javamonn has quit [Remote host closed the connection]
javamonn has joined #ocaml
moei has quit [Quit: Leaving...]
martintrojer has quit [Ping timeout: 246 seconds]
jonludlam has quit [Ping timeout: 252 seconds]
martintrojer has joined #ocaml
rand000 has quit [Quit: leaving]
kakadu_ has quit [Remote host closed the connection]
olibjerd has quit [Ping timeout: 245 seconds]
osa1 has joined #ocaml
ontologiae_ has joined #ocaml
ontologiae_ has quit [Ping timeout: 264 seconds]
justgage has joined #ocaml
<justgage> Is there a "round" function in ocaml. I've only found floor and ceil?
<nojb> let round x = int_of_float (x + 0.5)
<justgage> lol, yeah I guess that would do it.
ontologiae_ has joined #ocaml
Simn has quit [Quit: Leaving]
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
troydm has quit [Quit: What is hope? That all of your wishes and all of your dreams come true? (C) Rau Le Creuset]
troydm has joined #ocaml
n3ss3s has quit [Ping timeout: 265 seconds]
mengu has quit [Remote host closed the connection]
javamonn has quit [Remote host closed the connection]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
sgnb` has joined #ocaml
sgnb has quit [Remote host closed the connection]
rbocquet has quit [Ping timeout: 272 seconds]
asQuirreL has joined #ocaml
rbocquet has joined #ocaml
Algebr has quit [Ping timeout: 244 seconds]
hilquias has quit [Remote host closed the connection]
ontologiae_ has quit [Ping timeout: 264 seconds]
Anarchos has quit [Quit: going to bed]
<Denommus> uh
<Denommus> is there a quick one liner to run a OCaml script with a library dependency?
<def`> take a look at ocamlscript
<Denommus> def`: thanks
mal``` has quit [Ping timeout: 264 seconds]
<dmbaturin> Denommus: You can use topfind and its directives in non-interactive scripts.
darnuria has quit [Ping timeout: 252 seconds]
darnuria has joined #ocaml
mal`` has joined #ocaml
asQuirreL has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
javamonn has joined #ocaml
javamonn has quit [Remote host closed the connection]
madroach has quit [Ping timeout: 264 seconds]
javamonn has joined #ocaml
madroach has joined #ocaml
Algebr has joined #ocaml
<Algebr> I'm looking for a trivial example of autogenerating a .ml using ppx_tools.
<nojb> autogenerating ?
<Drup> Algebr: you want to get back the ml file instead of piping in the compiler directly ?
<Algebr> I want to create structure/structure list (line 755 of parsetree.mli) aka the AST and create a .ml
<Drup> ah, I see
<Denommus> I'm trying to demonstrate an example to a friend of mine, but I'm hitting errors I don't know how to solve
<Algebr> Drup: looking at dumpast of ppx_tools
<nojb> if you already wrote the ppx preprocessor then you can see the output using ocamlfind ppx_tools/rewriter <infile> <outfile>
<Drup> Algebr: I would rather use Pprintast, if I were you
<Drup> in compiler-libs
<Drup> the result is not always the prettiest, but it works reasonably, almost.
<nojb> that's what ppx_tools/rewriter uses
<Algebr> Is there any simple example out there of what I'm trying to do?
<Drup> Algebr: not that I know of, but it's really simple
<Drup> just build something of type Parsetree.structure using usual builders (ppx_tools, Ast.helper, etc)
<Drup> and call Pprintast.structure on it
<Denommus> the error I'm getting is "Error: This expression has type (UL.t * string) React.event but an expression was expected of type (UL.t * string) React.event The type constructor UL.t would escape its scope"
<Denommus>
<Drup> If you don't know about formatter, you can create a formatter from an out_channel with Format.formatter_of_out_channel
<Drup> the other solution being, as nojb suggested, to write a regular ppx and then use rewriter when you want the ocaml file.
<Algebr> Thank you, will try this out
Pepe_ has joined #ocaml
Pepe_ has quit [Client Quit]
<Drup> Denommus: just pull the functor application out of the "let () ="
<Drup> or, alternatively, pull the type t out of the functor, since it's independent of the argument
<Denommus> Drup: I fixed it by specifying lifecycle type signature as let lifecycle: (t * Entity.t) event -> unit event = ...
Pepe_ has joined #ocaml
<Denommus> Drup: ok, putting the type out of the functor also works