Nahra has quit [Remote host closed the connection]
mfp has quit [Ping timeout: 240 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
mbuf has joined #ocaml
ania123 has joined #ocaml
snowpanda has joined #ocaml
waleee-cl has joined #ocaml
narimiran has joined #ocaml
ania123 has quit [Quit: Connection closed]
stylewarning has quit [Ping timeout: 245 seconds]
stylewarning has joined #ocaml
stylewarning has joined #ocaml
stephe_ has joined #ocaml
stephe has quit [Ping timeout: 245 seconds]
stephe_ is now known as stephe
ELLIOTTCABLE has quit [Ping timeout: 245 seconds]
ELLIOTTCABLE has joined #ocaml
bytesighs has quit [Ping timeout: 245 seconds]
stylewarning has quit [Ping timeout: 245 seconds]
rfv has quit [Ping timeout: 245 seconds]
rfv has joined #ocaml
bytesighs has joined #ocaml
stylewarning has joined #ocaml
arecaceae has quit [Remote host closed the connection]
arecaceae has joined #ocaml
wonko7 has joined #ocaml
bacam_ has joined #ocaml
bacam has quit [Ping timeout: 245 seconds]
b20n has quit [Ping timeout: 245 seconds]
pmonson has quit [Ping timeout: 245 seconds]
pmonson has joined #ocaml
Druup has joined #ocaml
Drup has quit [Ping timeout: 245 seconds]
b20n has joined #ocaml
stylewarning has quit [Ping timeout: 245 seconds]
narimiran has quit [Ping timeout: 245 seconds]
stylewarning has joined #ocaml
caasih has quit [Ping timeout: 245 seconds]
olle has joined #ocaml
b20n has quit [Ping timeout: 245 seconds]
narimiran has joined #ocaml
b20n has joined #ocaml
caasih has joined #ocaml
olle has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
snowpanda has quit [Quit: Leaving...]
olle has joined #ocaml
Nahra has joined #ocaml
vicfred has quit [Quit: Leaving]
sagax has joined #ocaml
narimiran has quit [Ping timeout: 252 seconds]
TheLemonMan has joined #ocaml
serif[m] has quit [Ping timeout: 245 seconds]
bartholin has joined #ocaml
serif[m] has joined #ocaml
sagax has quit [Ping timeout: 252 seconds]
<Sumera[m]>
Hi all! Is this channel for general discussions for all things Ocaml or just for things related to development of the Ocaml language toolchain?
<Druup>
All things ocaml :)
<Druup>
(which includes the compiler, naturally)
Druup is now known as Drup
<Sumera[m]>
That's awesome!
<Sumera[m]>
I was wondering if there a library for encoding Strings in Ascii-8/utf-8. I came across Camomile but the repo doesn't look very active and I am not really able to find proper docs. Any help would be great!
<octachron>
It depends on the source and destination encoding.
<octachron>
For utf-n on both sides, uutf is sufficient
mfp has joined #ocaml
sagax has joined #ocaml
<d_bot>
<bikal> am trying to get this to work
<d_bot>
<bikal> ```
<d_bot>
<bikal> module Params = struct
<d_bot>
<bikal> type _ t =
<d_bot>
<bikal> | [] : 'a t
<d_bot>
<bikal> | ( :: ) : 'a * 'b t -> ('a -> 'b) t
<d_bot>
<bikal>
<d_bot>
<bikal> let c = [ "s"; 1; 2.3; true ]
<d_bot>
<bikal>
<d_bot>
<bikal> let parse l =
<d_bot>
<bikal> let parse_int s =
<d_bot>
<bikal> try Some (int_of_string s) with
<d_bot>
<bikal> | _ -> None
<d_bot>
<bikal> in
<d_bot>
<bikal> let parse_float s =
<d_bot>
<bikal> try Some (float_of_string s) with
<d_bot>
<bikal> | _ -> None
<d_bot>
<bikal> in
<d_bot>
<bikal> Core.List.fold_left l ~init:[] ~f:(fun acc s ->
<d_bot>
<bikal> match parse_int s with
<d_bot>
<bikal> | Some i -> i :: acc
<d_bot>
<bikal> | None -> (
<d_bot>
<bikal> match parse_float s with
<d_bot>
<bikal> | Some f -> f :: acc
<d_bot>
<bikal> | None -> s :: acc))
<d_bot>
<bikal> end
<d_bot>
<bikal> ```
<d_bot>
<bikal> but getting ```This expression has type (int -> 'a) t
<d_bot>
<bikal> but an expression was expected of type 'a t
<d_bot>
<bikal> The type variable 'a occurs inside int -> 'a
<d_bot>
<bikal> ```
<olle>
??
<olle>
Don't spam code like that ;(
<olle>
Looks shit in IRC
<olle>
Couple of lines are ok, but keep them under 5. Otherwise, pastbin or whatever.
<d_bot>
<bikal> IRC?
<olle>
This channel is linked with IRC channel through a bot
<d_bot>
<octachron> Note that this not that different of having a list of `type t = Float of float | Int of int`. The tag and the corresponding type information is just stored in a different list.
<d_bot>
<bikal> yes, that would be my fallback option. Was wondering if GADT would be more concise ... looking at your example now
<d_bot>
<octachron> There are few cases where the GADT option would be more concise, but if you don't have some extra constraints, the list of a variant types will be simpler *and* shorter.
narimiran has joined #ocaml
<d_bot>
<bikal> I was looking at implementing a function like 'scanf' in userland but with my own custom parsing in fmt, so gadt looked like it would allow me ... but it seems they type mastery required is quite high
<d_bot>
<bikal> like this func `route "/home/about/:int" (fun i -> i + 2)`
<d_bot>
<octachron> Beware that the `format strings` are not strings at all, they are GADTs masquerading as strings with the complicity of the compiler.
Haudegen has quit [Quit: Bin weg.]
<d_bot>
<Anurag> If combinators are okay to use instead of format strings you can do this with my routes library https://github.com/anuragsoni/routes
<d_bot>
<bikal> yep
<d_bot>
<octachron> Typically, `"%d"` is `Format (Int (Int_d, No_padding, No_precision, End_of_format), "%d")` without the magic sugar
<d_bot>
<bikal> Not exactly format string but just string with some special keyword
<d_bot>
<octachron> You cannot derive types from values in the language. This is more the job of a ppx.
<d_bot>
<bikal> This looks nice.
<d_bot>
<bikal> @Anurag can `routes` go the other way? so from string `"/user/:string/:int64"` to value `sum`?
<d_bot>
<bikal> I probably need to experiment with a bit more but thanks for the lib, it looks promising
Haudegen has joined #ocaml
TheLemonMan has joined #ocaml
<d_bot>
<Anurag> Hmm, not sure I fully understand, but routes allows for scanf style parsing `<pattern> => handler`, and printf/sprintf style printing `keys -> format -> string/unit`
<d_bot>
<Anurag> for printing if you have a route pattern of `/user/:string:int64` you can get a `sprintf` style function out of routes via `Routes.sprintf <pattern for "/user/:string/:int64"`. That'll return something with a signature `string -> int64 -> string`
curtosis has joined #ocaml
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
curtosis has joined #ocaml
curtosis is now known as curtosis[away]
curtosis[away] is now known as curtosis
curtosis is now known as curtosis[away]
curtosis[away] is now known as curtosis
<d_bot>
<bikal> What I meant was if there is a way to create routes via string and not the combinators, for eg
<d_bot>
<Anurag> No, that isn't available. I believe the ocaml compiler does some magic to convert the strings to the GADT representation (like @octachron mentioned).
<d_bot>
<octachron> Yes, the compiler essentially uses a builtin typed-ppx for doing the translation.
olle has quit [Ping timeout: 265 seconds]
<d_bot>
<bikal> Ah, I was just re-looking at this article by @Drup https://drup.github.io/2016/08/02/difflists/ and wanted to see if I can do essentially `val parse : string list -> ('ty, 'v) t` or `val parse : string -> ('ty, 'v)t`
<d_bot>
<bikal> But yeah got the same issue with my earlier attempt.
<d_bot>
<octachron> General rule: in a non-dependently typed language, you cannot generate type information from a value.
<d_bot>
<Drup> Yeah, you need a ppx for that
<d_bot>
<bikal> ok
<d_bot>
<Drup> it's not terribly satisfying :/
<d_bot>
<bikal> yeah
<d_bot>
<Drup> @bikal if you want to use this to do routing, I suggest you take a look at Furl
<d_bot>
<Drup> there is also a thing by ocamlpro to do routing for rest APIs which uses a similar concept (and is published/finished)
<d_bot>
<bikal> oh, which one?
<d_bot>
<Drup> ah `resto`, it's called
<companion_cube>
there's a tiny version of that in tiny_httpd, too
Haudegen has quit [Quit: Bin weg.]
<d_bot>
<bikal> `resto` looks nice, is the ez_resto module the one to use or just resto?
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<d_bot>
<Anurag> `ezresto` adds some abstraction on top of `resto` which provide a simpler UX. I'd recommend starting there and seeing if it meets your needs, and then see if there is something you aren't able to achive with ezresto and then go to `resto`
mbuf has quit [Quit: Leaving]
<d_bot>
<antron> is discuss.ocaml.org really slow right now? or just for me?
bartholin has quit [Quit: Leaving]
Haudegen has joined #ocaml
<d_bot>
<mseri> Works fine for me
narimiran has quit [Ping timeout: 252 seconds]
<d_bot>
<antron> seems to be fine for me now, also
narimiran has joined #ocaml
vicfred has joined #ocaml
olle has joined #ocaml
Tuplanolla has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
olle has quit [Ping timeout: 265 seconds]
curtosis has joined #ocaml
wonko7 has quit [Ping timeout: 260 seconds]
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
dckc has quit [Read error: Connection reset by peer]
dckc has joined #ocaml
Nahra has quit [Ping timeout: 245 seconds]
narimiran has quit [Ping timeout: 245 seconds]
tinga has joined #ocaml
<d_bot>
<hcarty> @sgrove I haven't created tars in memory but have extracted them. Looking at the ocaml-tar interface it should be possible to do something resembling an inverse of what's in this gist, but I haven't tried to be sure. This is a partial and simplified version of what I've used: <https://gist.github.com/hcarty/18650157caa9f0f6d1a19df62d89c138>
<d_bot>
<sgrove> @hcarty I managed to figure it out, thank you!
<d_bot>
<Zach5050> Does anyone know how to add multiple things to a list at the same time?
<d_bot>
<Zach5050> my professor gives the psuedocode on the left and i must add two tuples to the list at the same time, i looked in List and cant find anything