adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.09 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.09/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
Haudegen has quit [Client Quit]
Haudegen has joined #ocaml
mahmudov has quit [Changing host]
mahmudov has joined #ocaml
vicfred has quit [Remote host closed the connection]
spew has quit [Quit: Connection closed for inactivity]
vicfred has joined #ocaml
ygrek__ has quit [Ping timeout: 240 seconds]
rzmt_ has quit [Ping timeout: 260 seconds]
rzmt has joined #ocaml
smazga has quit [Quit: leaving]
cemerick has quit [Read error: Connection reset by peer]
cemerick has joined #ocaml
strmpnk has quit [Ping timeout: 246 seconds]
strmpnk has joined #ocaml
mahmudov has quit [Remote host closed the connection]
ocaml459 has joined #ocaml
kleisli has quit [Ping timeout: 272 seconds]
ocaml459 has quit [Client Quit]
serge_ has joined #ocaml
serge_ has quit [Ping timeout: 272 seconds]
Haudegen has quit [Ping timeout: 265 seconds]
nullifidian has quit [Read error: Connection reset by peer]
nullifidian has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
olle has joined #ocaml
rzmt has quit [Ping timeout: 268 seconds]
serge_ has joined #ocaml
serge_ has quit [Ping timeout: 260 seconds]
mfp has quit [Ping timeout: 272 seconds]
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
nullifidian_ has joined #ocaml
nullifidian has quit [Read error: Connection reset by peer]
vicfred has quit [Quit: Leaving]
vicfred has joined #ocaml
tormen has joined #ocaml
kleisli has joined #ocaml
tormen_ has quit [Ping timeout: 240 seconds]
ygrek__ has joined #ocaml
serge has joined #ocaml
serge has quit [Ping timeout: 260 seconds]
dborisog has joined #ocaml
sagax has quit [Ping timeout: 272 seconds]
pierpal has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
FreeBirdLjj has joined #ocaml
sagax has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 240 seconds]
TC01 has quit [Remote host closed the connection]
TC01 has joined #ocaml
gravicappa has joined #ocaml
malina has quit [Remote host closed the connection]
ygrek__ has quit [Ping timeout: 240 seconds]
bartholin has quit [Quit: Leaving]
serge has joined #ocaml
narimiran has joined #ocaml
serge has quit [Ping timeout: 260 seconds]
kleisli has quit [Ping timeout: 260 seconds]
serge has joined #ocaml
serge has quit [Ping timeout: 272 seconds]
NSA_Spy has quit [Ping timeout: 260 seconds]
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
Haudegen has joined #ocaml
ggole has joined #ocaml
mbuf has joined #ocaml
jnavila has joined #ocaml
<mbuf> For exercise 55 from https://ocaml.org/learn/tutorials/99problems.html?ref=dzone#Binary-Trees, I get "Line 3, characters 19-52: Error: This expression should not be a function, the expected type is 'a list" for the add_trees_with function. Why?
Serpent7776 has joined #ocaml
serge has joined #ocaml
serge has quit [Ping timeout: 272 seconds]
<reynir> mbuf: Is the error coming from your code? Anyway, maybe you forgot to supply an argument to a function
<mbuf> The code seems to work fine on https://try.ocamlpro.com/ though.
<mbuf> On try.ocampro.com, # List.fold_left;; gives ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a = <fun>
<mbuf> On my utop, I get List.fold_left;; - : 'a list -> init:'b -> f:('b -> 'a -> 'b) -> 'b = <fun>. Probably, because I am using the Base from RWO
jnavila has quit [Ping timeout: 256 seconds]
<Leonidas> mbuf: yes, your fold_left has labelled arguments, that's often a giveaway for Base/Core.
<mbuf> Leonidas, how do I fix it?
<Leonidas> you can probably change the code to use ~init and ~f and it should be fine, also you probably should've gotten a warning about unapplied labels.
<Leonidas> the first argument corresponds to ~f, the second to ~init
<mbuf> Leonidas, yes, that fixes the add_trees_with function. Now, moving on to hbal_tree function.
<Leonidas> mbuf: where is the code, I don't see it on the page you linked
<Leonidas> ah, unfolding the solution helps
<mbuf> Leonidas, it is throwing a type mismatch for "add_trees_with t1 t1"
ProfV has joined #ocaml
<Leonidas> mbuf: can you post the code?
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
<ProfV> I finally got around to make use of the Result module. However, I can only access it as "Stdlib.Result" (e.g. "Stdlib.Result.to_option"). Is that on purpose? I would have expected it to be accessible directly ("Result.to_option" instead of "Stdlib.Result.to_option"). I'm using OCaml 4.08.1 from a freshly compiled OCaml switch.
<ProfV> Right now I'm adding "module Result = Stdlib.Result" to the top of my files, but this feels very wrong.
<Leonidas> mbuf: compiles just fine for me
<Leonidas> mbuf: val hbal_tree : int -> char binary_tree list = <fun>
<Leonidas> mbuf: but you don't have any open Base or anything, so I am confused on whether you use base or not
<Leonidas> use it or don't but be consistent about it
<Leonidas> ProfV: you should be able to just use Result.to_option without the alias because ocaml implicitly does `open Stdlib`
<ProfV> Leonidas: That was my understanding, too, but if I do that, I get the follwing compiler error:
<Leonidas> ProfV: https://gist.github.com/Leonidas-from-XIV/74bb0edb3df606bd65e699a4c6d9a722 so if you do this, you get a different result?
<Leonidas> (that's the ocaml toplevel)
<ProfV> Error: Unbound value Result.to_option
<ProfV> Leonidas: Strange, at toplevel this works. I was executing "opam exec ocaml" followed by Result.to_option and everything was fine.
<Leonidas> ProfV: what is your code you're trying to compile
<ProfV> Leonidas: Just a second, I'll reduce it to a minimal example
<mbuf> Leonidas, works in utop, after I use open Base;;
<mbuf> Leonidas, thanks!
<mbuf> Leonidas, and with CLI, I am able to compile using ocamlfind ocamlc -linkpkg -package base tree.ml
<ProfV> Leonidas: Okay, this seems to be an issue with caqti-driver-postgresql (or one of its dependencies).
<ProfV> Leonidas: main.ml: let _ = Result.to_option
<ProfV> Leonidas: dune: (executable (name main) (libraries caqti-driver-postgresql) (modes native))
jnavila has joined #ocaml
<ProfV> Leonidas: Without the caqti-driver-postgresql library, the code compiles fine
<Leonidas> ProfV: that sounds weird to me, that's usually not what libraries are capable of
<ProfV> Leonidas: Okay, I traversed the library dependency tree:
<ProfV> Leonidas: caqti-driver-postgresql > caqti > ptime > result
<ProfV> Leonidas: So the dune file can be simplified to: (executable (name main) (libraries result) (modes native))
<ProfV> Leonidas: So the offender is the "result" library, which is supposed to provide the Result module for old OCaml stdlibs.
<ProfV> Leonidas: Okay, seems to be a known issue: https://github.com/janestreet/result/issues/8
<ProfV> Arggh ...
<ProfV> There's even a pull request to fix this, it is just not yet reviewed: https://github.com/janestreet/result/pull/9
<ProfV> Seems that I need to stick with "module Result = Stdlib.Result" for some time ...
<Leonidas> hmm, curious
<Leonidas> ah, ok, now I understand
pierpal has quit [Ping timeout: 268 seconds]
m_oss has joined #ocaml
<ProfV> Anyway, thanks!
ProfV has quit [Quit: leaving]
<mbuf> If I get a return value from a function as Some x, how do I obtain and use x? Is there a function to extract x from the same?
<Leonidas> mbuf: match v with | None -> ... | Some x -> ...
<mbuf> Leonidas, pattern matching, okay
<Leonidas> mbuf: you can also use monadic let syntax
<Leonidas> you can also change your code so it breaks when you get a None (wouldn't recommend)
<Leonidas> `Base.Option.value_exn` or a less breaking thing `Base.Option.value`.
vicfred has quit [Quit: Leaving]
pierpal has joined #ocaml
<mbuf> Leonidas, I see
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
<mbuf> With hbal_tree 5, the program runs, but, with hbal_tree 6, the process gets killed when executed through ./a.out or utop. Why? https://pastebin.com/h3DxK88p
<Leonidas> probably out of memory
<mbuf> I have given Buffer.create 32768, or is because of stack overflow?
<Leonidas> you should also probably not use List.hd
<mbuf> Leonidas, why?
<Leonidas> mbuf: because it is better to just pattern match on the list itself, that way you avoid going through option to begin with.
SpiceGuid has joined #ocaml
serge has joined #ocaml
<mbuf> Leonidas, sorry, how would I pattern match on the list? hbal_tree returns a char binary_tree list, but, string_of_tree requires a char binary_tree
serge has quit [Ping timeout: 268 seconds]
<mbuf> Okay, using \n let main =
<mbuf> match (hbal_tree 6) with
<mbuf> | h::t -> string_of_tree h
<mbuf> | [] -> ()
<mbuf> I now need to see how to prevent the executable from getting being killed
nullcone has quit [Quit: Connection closed for inactivity]
nullifidian__ has joined #ocaml
nullifidian_ has quit [Ping timeout: 240 seconds]
khodzha1 has joined #ocaml
m_oss has quit [Ping timeout: 246 seconds]
mfp has joined #ocaml
<Nikkel> Ocaml warns me when I try to do this: https://pastebin.com/sfQXQt9b
<Nikkel> Sorry, this: https://pastebin.com/5S6S9JZa
<Nikkel> Is there any way to get rid of the warning? I am not sure what it is asked
nullcone has joined #ocaml
<ggole> 22 is for ppx warnings, so this is likely an issue with eliom
<ggole> You could locally suppress the warning with an attribute, but it's probably better to figure out why it is happening and address that
SpiceGuid has quit [Quit: ChatZilla 0.9.93 [SeaMonkey 2.49.4/20180713174829]]
serge has joined #ocaml
serge has quit [Ping timeout: 240 seconds]
<Nikkel> I'm gonna suppress it.
<Nikkel> ggole: thanks
dhil has joined #ocaml
pierpal has quit [Ping timeout: 272 seconds]
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
m_oss has joined #ocaml
mbuf has quit [Quit: Leaving]
pierpal has quit [Read error: Connection reset by peer]
barockobamo has joined #ocaml
<Leonidas> does anyone know what the Async equivalent of an Lwt_unix.job is?
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 240 seconds]
<gahr> hi - I'm looking into Incr_dom and got curious about janestreet/ppx_let. I'm trying to deconstruct this simple usage of let%map into the corresponding call to map model ~f:(model -> (*rest of the function*))
<gahr> but I can't figure which module's map to call, and how to express it
<gahr> it should be something like Incremental.S.map, but with the Model injected somehow
nicoo has quit [Ping timeout: 240 seconds]
Haudegen has quit [Quit: Bin weg.]
pierpal has joined #ocaml
nicoo has joined #ocaml
<Leonidas> gahr: `let%map x = y in z` is just `let%bind x = y in return z`
<Leonidas> which basically desugars into `x >>= fun y -> return z`
<Leonidas> *into `y >>= fun x -> return z`
ollehar has joined #ocaml
<ollehar> Is there any research on how the expression problem applies in different domains?
<ollehar> E.g. if certain domains more often change operations on existing types, and others more often add new types than new operations?
serge has joined #ocaml
pierpal has quit [Ping timeout: 246 seconds]
ollehar_ has joined #ocaml
* ollehar_ test
<gahr> ah, so that'd be (model >== fun model -> let apply_action = ... in let view = ... in return (Component.create ...))
serge has quit [Ping timeout: 265 seconds]
<gahr> where it says that they are rewritten into calls to bind and map
ollehar has quit [Ping timeout: 260 seconds]
<gahr> s/>==/>>=/
<gahr> ah of course, that's be (bind model (fun model -> ...))
<gahr> and where would *that* bind come from?
khodzha1 has quit [Quit: Leaving.]
kleisli has joined #ocaml
* ollehar_ monads...
<gahr> yeah but which module
<gahr> if I want to call it explicitely and desugar the expression completely
<Leonidas> gahr: Incr.Let_syntax
<Leonidas> I think it doesn't desugar into >>= and >>| but rather into `bind` and `map` but the intuition is the same.
<Leonidas> (yes, Let_syntax has a nested Let_syntax module and that's what ppx_let uses)
<gahr> yeah but which map and bind?
<gahr> as in, what would Foo be in Foo.map model ~f:(fun model -> return (..))
<gahr> or am I not getting something else?
<Leonidas> gahr: `Incr.Let_syntax.Let_syntax.map`
<gahr> oh
<gahr> thanks!
<gahr> which comes from State.map
jnavila has quit [Ping timeout: 272 seconds]
dhil has quit [Ping timeout: 245 seconds]
m_oss has quit [Remote host closed the connection]
m_oss has joined #ocaml
dhil has joined #ocaml
pierpal has joined #ocaml
FreeBirdLjj has joined #ocaml
dborisog has quit [Remote host closed the connection]
dborisog has joined #ocaml
cartwright has quit [Ping timeout: 240 seconds]
cartwright has joined #ocaml
spew has joined #ocaml
serge has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
serge has quit [Ping timeout: 260 seconds]
ygrek__ has joined #ocaml
nullcone has quit [Quit: Connection closed for inactivity]
Haudegen has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
dhil has quit [Ping timeout: 240 seconds]
mbuf has joined #ocaml
m_oss has quit [Ping timeout: 272 seconds]
Serpent7776 has quit [Quit: Leaving]
dhil has joined #ocaml
smazga has joined #ocaml
serge has joined #ocaml
serge has quit [Ping timeout: 240 seconds]
barockobamo has quit [Remote host closed the connection]
mbuf has quit [Quit: Leaving]
ollehar_ has quit [Ping timeout: 272 seconds]
dborisog has quit [Ping timeout: 240 seconds]
vicfred has joined #ocaml
Serpent7776 has joined #ocaml
nullcone has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
malina has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
sugarwren has joined #ocaml
bartholin has joined #ocaml
serge has joined #ocaml
serge has quit [Ping timeout: 265 seconds]
dborisog has joined #ocaml
tmhoang has joined #ocaml
TC01 has quit [Ping timeout: 265 seconds]
TC01 has joined #ocaml
dborisog has quit [Ping timeout: 260 seconds]
mahmudov has joined #ocaml
dhil has quit [Ping timeout: 248 seconds]
Haudegen has quit [Quit: Bin weg.]
Haudegen has joined #ocaml
kakadu_ has joined #ocaml
pierpal has joined #ocaml
ggole has quit [Quit: Leaving]
serge has joined #ocaml
serge has quit [Ping timeout: 265 seconds]
ocaml459 has joined #ocaml
narimiran has quit [Quit: leaving]
Serpent7776 has quit [Quit: leaving]
serge has joined #ocaml
gravicappa has quit [Ping timeout: 272 seconds]
ocaml459 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
serge has quit [Ping timeout: 265 seconds]
sugarwren has quit [Quit: Leaving]
rwmjones is now known as rwmjones|hols
Jesin has quit [Quit: Leaving]
Jesin has joined #ocaml
nullifidian_ has joined #ocaml
kakadu_ has quit [Remote host closed the connection]
nullifidian__ has quit [Read error: Connection reset by peer]
nicoo has quit [Ping timeout: 240 seconds]
serge_ has joined #ocaml
serge_ has quit [Ping timeout: 260 seconds]
nicoo has joined #ocaml
nullifidian_ has quit [Read error: Connection reset by peer]
pierpal has quit [Read error: Connection reset by peer]
nullifidian__ has joined #ocaml
zgasma has joined #ocaml
smazga has quit [Ping timeout: 272 seconds]