<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>
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:
<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]
<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*))