adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | Current MOOC: https://huit.re/ocamlmooc | OCaml 4.04.0 release notes: http://ocaml.org/releases/4.04.html | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
ontologiae has joined #ocaml
fantasticsid has joined #ocaml
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
ontologiae has quit [Ping timeout: 260 seconds]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
fantasticsid has quit [Remote host closed the connection]
fantasticsid has joined #ocaml
mfp has quit [Ping timeout: 245 seconds]
bitbckt has quit [Remote host closed the connection]
bitbckt has joined #ocaml
jack5638 has quit [Ping timeout: 240 seconds]
jack5638 has joined #ocaml
iitalics has joined #ocaml
dudelson has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
raphaelss has joined #ocaml
jlam__ has joined #ocaml
jlam has quit [Ping timeout: 240 seconds]
MercurialAlchemi has joined #ocaml
pierpa has quit [Read error: Connection reset by peer]
govg has quit [Ping timeout: 245 seconds]
Algebr has joined #ocaml
_whitelogger has joined #ocaml
ygrek has joined #ocaml
jlam has joined #ocaml
jlam__ has quit [Ping timeout: 245 seconds]
iitalics has quit [Quit: /thread]
groovy2shoes has quit [Quit: Leaving]
govg has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
groovy2shoes has joined #ocaml
raphaelss has quit [Remote host closed the connection]
seangrove has joined #ocaml
<seangrove> Hey all, looking to use postgres, and looks like episql might be good. How can I get https://github.com/paurkedal/episql installed/running? It's not on opam, which makes sense since it's a code-gen piece, but there aren't any instructions on how to get it installed.
<seangrove> I guess I can pin-add it
<seangrove> Hrm, it needs something called `prime` that isn't on opam. Will try to find that...
cbot has joined #ocaml
MercurialAlchemi has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
Simn has joined #ocaml
seangrove has quit [Ping timeout: 268 seconds]
govg has joined #ocaml
dtornabene has joined #ocaml
jlam has quit [Ping timeout: 260 seconds]
jlam has joined #ocaml
dhil has joined #ocaml
moei has quit [Quit: Leaving...]
ygrek has quit [Ping timeout: 245 seconds]
freyr has joined #ocaml
dhil has quit [Ping timeout: 240 seconds]
cbot has quit [Quit: Leaving]
argent_smith has joined #ocaml
AltGr has joined #ocaml
moei has joined #ocaml
moei has quit [Client Quit]
moei has joined #ocaml
rossberg has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
rossberg has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
mfp has joined #ocaml
fantasticsid has quit [Ping timeout: 245 seconds]
Algebr has quit [Ping timeout: 260 seconds]
<Leonidas> because what we needed was a 3rd extlib
<Leonidas> oh, he's also in Copenhagen
picolino has joined #ocaml
<reynir> Who is?
adrien is now known as SpecialSnowflake
<Leonidas> paurkedal
sz0 has joined #ocaml
selite has joined #ocaml
<selite> Trying to learn the simple concept of for loop. Somehow I can't wrap my mind around it. Why does this not modify s? for i = 0 to 10 do s = s + i done;;
<zozozo> selite: the expression "s = s + 1" is actually the boolean test of wetehr s and s +1 are equal, it returns a bool
<zozozo> if you want to modify the contents of a variable, you need to use a reference
<zozozo> something like: let s = ref 0 in s := !s + 1
<selite> thanks.
<Leonidas> or don't use for loops, which is most of the times the better approach
<toolslive> someting like : let rec loop sum i = if i = 10 then sum else loop (sum+i) (i+1) in loop 0 0
<selite> Well our prof gave us assignment to implement merge sort and I'm afraid it'll look like I cheated it if I make it too elegant.
<selite> :D
govg has joined #ocaml
<toolslive> a naive merge sort is 3-4 lines or so
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
<selite> toolslive: well with my ocaml skills just the merge procedure will take more than that xD
zpe has quit [Ping timeout: 260 seconds]
<Leonidas> not sure what in merge sort would require a for loop
<Leonidas> or even make it any easier.
<Leonidas> it's a great way to make it confusing and hard to debug, though!
<zozozo> I suppose a merge sort using arrays ?
zpe has joined #ocaml
mpenet has joined #ocaml
mpenet has left #ocaml [#ocaml]
<selite> why does this code give error let whichEverNotEmpty A B = match A B with |[], _ -> B |_, [] -> A;; ?
<selite> I am trying to do pattern matching to return the array which is not empty
<selite> I realize it's not exhaustive.
<picolino> you can't use uppercase for variable
<picolino> word starting with an uppercase are assumed to be constructors of sum types
<selite> with lowercase it says: "Error: This expression has type 'a -> 'b list * 'c list but an expression was expected of type 'a The type variable 'a occurs inside 'a -> 'b list * 'c list"
<picolino> furthermore, you should match a,b no a b
<picolino> the type checker think you apply a to b ...
<selite> Now it works.
<picolino> and you match the result with a pattern of type 'b list * 'c list, hence the infered type for a : 'a -> 'b list * 'c list
zpe has quit [Remote host closed the connection]
kakadu has joined #ocaml
<selite> Is there an already implemented function in ocaml to slice a list? for example 0 index to 5?
<selite> oh found it
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
yegods has joined #ocaml
yegods has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
SpecialSnowflake is now known as adrien
<selite> guys why won't my slice work? https://pastebin.com/cW5sRFdx
<selite> very simple naive implementation.
zpe_ has joined #ocaml
zpe has quit [Read error: Connection reset by peer]
<octachron> selite, the type error is telling you that the first argument of slice should be a list and that (index1 + 1) is an int and not a list
selite has quit [Ping timeout: 260 seconds]
selite has joined #ocaml
selite has quit [Ping timeout: 260 seconds]
govg has quit [Ping timeout: 240 seconds]
<kakadu> vk
<kakadu> oops. wrong window
zpe_ has quit [Remote host closed the connection]
ziyourenxiang has joined #ocaml
silver has joined #ocaml
govg has joined #ocaml
zpe has joined #ocaml
selite has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
selite has quit [Client Quit]
selite has joined #ocaml
<selite> Guys
<selite> can someone tell me what's wrong with my recursive slice function?
<selite> I get an error. Error: This expression has type int but an expression was expected of type 'a list
<zozozo> selite: in your recursive call to slice, you forgot to give the list as first argument
<selite> Alright.
<selite> It works.
<octachron> selite, note that using List.nth (or your own implementation) make your algorithm complexity quadratic in the list of the lenght, which defeat the purpose of the merge sort
<selite> I know.
FreeBirdLjj has joined #ocaml
zpe has quit [Remote host closed the connection]
<selite> How do I put a variable in function for example if I do let rec mergesort let mid = (start + finish)/2 ... for some reason doesn't work?
<flux> let foo x = let bar = x + 42 in bar * bar
dudelson has joined #ocaml
<selite> Ok, guys https://pastebin.com/6UDpJDnq. Why do I get error here Error: Unbound value merge_sorted. merge_sorted is clearly defined above it?
<flux> I don't get that error. I do get a "Unbound value mid"
<_y> same
<selite> Yeah think I compiled older version.
<selite> But the mid is defined in there.
<selite> Like so: let mid = (start + finish) / 2
zpe has joined #ocaml
<selite> Why is it unbound I think one sided if statement is ok in ocaml.
<selite> So that shouldn't be a problem.
<chelfi> selite: bindings in ocaml are non recursive by default
<selite> meaning?
<chelfi> try with "let rec mid = ..." instead
<chelfi> you will probably have the same problem with your mergesort definition
<selite> Yes added 2 recs one for merge_sort another for mid. Here's how it looks like now: let rec mergesort a start finish = let rec mid = (start + finish) / 2 and first_half = slice a start mid and second_half = slice a (mid + 1) finish in if start < finish then merge_sorted (mergesort first_half start mid) (mergesort second_half (mid + 1) finish);;
<selite> Now i get Error: This expression has type 'a list but an expression was expected of type unit
<chelfi> an "if ... then ..." without a else clause is considered of type unit
<selite> So no way to have empty else statement?
<selite> is there something like do nothing statement?
<chelfi> only if your "then" clause returns an expression of type unit
<selite> Well if my intuition for merge_sort is right when start = finish then we have a single number and that list of a single number is already sorted so I can just return the original list.
<selite> Like so: let rec mergesort a start finish = let rec mid = (start + finish) / 2 and first_half = slice a start mid and second_half = slice a (mid + 1) finish in if start < finish then merge_sorted (mergesort first_half start mid) (mergesort second_half (mid + 1) finish) else a;;
<selite> but now i get: Error: This kind of expression is not allowed as right-hand side of `let rec'
<selite> *then
<octachron> selite, you should define mid before other values: "let mid = … in let first_half = … and secod_half = … in … "
<octachron> there is a restriction on the expressions allowed in recursive definition which is here to avoid non-terminating definitions
<octachron> e.g. "let rec x = x;;"
<chelfi> selite: in general, you should avoid using recursive definitions when there ii is not needed
<chelfi> they are not needed*
<selite> octachron: But it is defined before the others definitely before first_half and second_half.
<selite> what i do is let rec mid = ... and first_half = ... and second_half..
<selite> does that not mean that it comes before?
<chelfi> you separated your bindings with the "and" keyword which tie their scope together, which is why you needed the "let rec"
<chelfi> what you really wanted was, as octachron said, "let mid = ... in let first_half = ..."
<chelfi> rather than "let mid = ... and first_half = ..."
<selite> let rec mergesort a start finish = let mid = (start + finish) / 2 in first_half = slice a start mid and second_half = slice a (mid + 1) finish in if start < finish then merge_sorted (mergesort first_half start mid) (mergesort second_half (mid + 1) finish);;
<chelfi> this way, all your bindings are non recursive, and the aforementioned restriction is no longer a problem for you
<selite> Like this I get Unbound value: first_half Error.
<chelfi> you need "in let", not "in"
<chelfi> (same thing for "second_half")
<chelfi> when you do "let x = expr_x in expr", you bind x to the result of the evaluation of expr_x, and then you add it to "expr"'s scope which you then evaluate
<chelfi> and you can nest those bindings
<chelfi> if you omit the let, then "first_half = expr" is a boolean expression which compares the values of first_half and expr
<chelfi> while if you add the let, "let first_half = expr" introduces another binding (and you will need a matching "in")
sepp2k has joined #ocaml
<selite> I see the syntax is ok now.
<selite> Here's what I have:
<selite> let rec mergesort a start finish = let mid = (start + finish) / 2 in let first_half = slice a start mid and second_half = slice a (mid + 1) finish in if start < finish then merge_sorted (mergesort first_half start mid) (mergesort second_half (mid + 1) finish) else a;;
<selite> Now the syntax is ok but when I call mergesort [2;1] 0 1;; I get Exception: Failure "hd". The slices work ok and other than for slice i don't think I call List.hd.
<selite> In the interpreter I type the slice calls that my code executes and they work.
<selite> Can I somehow let the first_half and second_half definitions in the if statement?
<selite> Because this way I'm calling mergesort [2] 1 1;; and the slice functions trigger a List.hd which fails. If I can postpone those to be computed in the if then I think it'll work.
<chelfi> yes, you can
<chelfi> for instance "if ... then let first_half = ... in ... else ..."
MercurialAlchemi has quit [Ping timeout: 246 seconds]
olibjerd has joined #ocaml
spew has joined #ocaml
selite has quit [Quit: Page closed]
selite has joined #ocaml
<selite> thanks a lot guys it's working perfectly now tested the algorithm.
<selite> :D
<freyr> Sup, I'm trying to build js_of_ocaml project with jbuilder and getting an error:
<freyr> Error: The following required libraries are missing in the default context:
<freyr> - js_of_ocaml-ppx
<freyr> Hint: try: opam install js_of_ocaml-ppx
<freyr> Seems no ppx package. I've used camlp4 syntax before and that was fine
<freyr> How to install ppx for jsoo via opam?
<freyr> And how to use camlp4 with jbuilder?
<freyr> Thanx
<Drup> is your opam install up to date ?
<freyr> Drup: It is 2.8.4
<Drup> then you should use the package js_of_ocaml.ppx, but I'm pretty that's not going to work with jbuilder just yet, you might need the dev version
<Drup> (about camlp4 ... using it is with jbuilder is probably a pain, and you really shouldn't use it anyway, it's deprecated)
selite has quit [Ping timeout: 260 seconds]
<freyr> Drup: Ok, so it seems to be quite early to move away from ocamlbuild. Is there any chance to see a decent jsoo support in jbuilder soon?
<Drup> it's already there, afaik, it just needs jsoo 3.0, which is not yet released :)
<freyr> Drup: Oh, I see, that's a good news, thanx.
copy` has joined #ocaml
<octachron> Drup, deprecated might be a tad too strong for camlp4, I would rather say only advisable in very specific circumstances and as poorly undocumented as ever
<Drup> octachron: jsoo's camlp4 extension is deprecated, though.
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
MercurialAlchemi has joined #ocaml
shinnya has joined #ocaml
jao has joined #ocaml
jlam__ has joined #ocaml
jlam has quit [Ping timeout: 240 seconds]
cbot has joined #ocaml
spew has quit [Ping timeout: 272 seconds]
oliverfriedmann has joined #ocaml
jlam__ has quit [Ping timeout: 246 seconds]
jlam has joined #ocaml
<oliverfriedmann> Any idea how to specify the output directory of a binary executable via OASIS?
Anarchos has joined #ocaml
freyr has quit [Remote host closed the connection]
AltGr has left #ocaml [#ocaml]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
ziyourenxiang has quit [Ping timeout: 245 seconds]
shinnya has quit [Ping timeout: 240 seconds]
fraggle_ has quit [Ping timeout: 240 seconds]
<Leonidas> How do I print a Core_kernel.Or_error.t?
fraggle_ has joined #ocaml
mengu has joined #ocaml
SpiceGuid has joined #ocaml
<Leonidas> oh, got it, I matched on it and handled the Error case
ontologiae has joined #ocaml
SpiceGuid has quit [Quit: ChatZilla 0.9.93 [SeaMonkey 2.46/20161213183751]]
kevinqiu has joined #ocaml
kevinqiu has left #ocaml [#ocaml]
ygrek has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
<Leonidas> *sigh*
<Leonidas> How do I actually get a Deferred.t to run? Do I have to do the Scheduler.go dance?
MercurialAlchemi has joined #ocaml
jao has quit [Ping timeout: 245 seconds]
letaris has joined #ocaml
TheLemonMan has joined #ocaml
tianon has quit [Ping timeout: 272 seconds]
tianon has joined #ocaml
<copy`> Leonidas: Well, usually you chain deferreds and call `Scheduler.go` only once in your program
<Leonidas> copy`: yes, but then I need to somehow also terminate the scheduler once it has ran
<Leonidas> I was using Thread_safe.block_on_async_exn but that only works sometimes
oliverfr_ has joined #ocaml
oliverfriedmann has quit [Read error: Connection reset by peer]
jnavila has joined #ocaml
ontologiae has quit [Ping timeout: 240 seconds]
raphaelss has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
vaartis has joined #ocaml
<vaartis> Hey, anybody here used llvm api?
FreeBirdLjj has quit [Ping timeout: 260 seconds]
ontologiae has joined #ocaml
<Drup> What's your question ?
<vaartis> Is there any way to get type the pointer type points to in OCaml, like Type::getContainedType in C++?
<Drup> hum, it might not be in the API
<Drup> You could add it, it's not difficult, especially if it's already in the C API
<vaartis> Yeah, sounds good. So.. i think i need to write a patch and send it to their mail list?
tianon has quit [Ping timeout: 255 seconds]
<Drup> I don't know the llvm contribution process these days. You can ask whitequark too, he take cares of the ocaml bindings
<vaartis> Well.. It does not exist in C api.. That makes things a little harder
tianon has joined #ocaml
<vaartis> > You can ask whitequark too
<vaartis> Ok, gonna do that!
jnavila has quit [Ping timeout: 272 seconds]
MercurialAlchemi has quit [Ping timeout: 245 seconds]
tane has joined #ocaml
jnavila has joined #ocaml
jlam__ has joined #ocaml
jlam has quit [Ping timeout: 260 seconds]
vaartis has quit [Quit: ERC (IRC client for Emacs 26.0.50)]
ontologiae has quit [Ping timeout: 245 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
kakadu has joined #ocaml
jlam has joined #ocaml
jlam__ has quit [Ping timeout: 240 seconds]
tianon has quit [Ping timeout: 245 seconds]
tianon has joined #ocaml
jnavila has quit [Ping timeout: 240 seconds]
jao has joined #ocaml
_andre has quit [Quit: leaving]
jao has quit [Ping timeout: 268 seconds]
olibjerd has quit [Quit: olibjerd]
dudelson has quit [Ping timeout: 246 seconds]
tane has quit [Quit: Leaving]
pierpa has joined #ocaml
Simn has quit [Read error: Connection reset by peer]
ontologiae has joined #ocaml
oliverfr_ has quit [Remote host closed the connection]
oliverfriedmann has joined #ocaml
oliverfriedmann has quit [Ping timeout: 240 seconds]
iitalics has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
jao has joined #ocaml
dudelson has joined #ocaml
silver_ has joined #ocaml
silver has quit [Ping timeout: 240 seconds]
andreas has quit [Quit: Connection closed for inactivity]
iitalics has quit [Quit: /thread]
oliverfriedmann has joined #ocaml
ontologiae has quit [Ping timeout: 245 seconds]
kakadu has quit [Remote host closed the connection]
sepp2k has quit [Ping timeout: 240 seconds]
argent_smith has quit [Quit: Leaving.]
oliverfriedmann has quit [Ping timeout: 245 seconds]
oliverfriedmann has joined #ocaml
pierpa has quit [Remote host closed the connection]