<discocaml>
<gubsey> Does anyone know why ocaml doesn't have list comprehension? Being so similar to Haskell it's an interesting omission. I'm okay with it not being there, and I can think of plenty of reasons on my own, but I'd love to know the actual reason.
<discocaml>
<gubsey> I much prefer the list tools we have btw.
<discocaml>
<Kali> it doesn't have specific syntax for list comprehension, but list comprehension is just `map`; you could use a let-op if you wanted to make it special:
<discocaml>
<Kali> ```ocaml
<discocaml>
<Kali> let ( let+ ) = List.map
<discocaml>
<Kali>
<discocaml>
<Kali> let () = List.iter print_int (let+ x = [1;2;3;4;5] in x + 2)
<discocaml>
<Kali> (* 34567 *)
<discocaml>
<Kali> ```
<discocaml>
<._null._> You can get some equivalent with monadic lets, e.g. `let* i = List.init 10 Fun.id in let* j = List.init 5 ((+) 100) in [i+1; i*j]`. If you also give yourself nice operators for simple lists, you get something
<discocaml>
<Kali> it doesn't have specific syntax for list comprehension, but list comprehension is just `map` or `concat_map` depending on the context; you could use a let-op if you wanted to make it special:
<discocaml>
<Kali> ```ocaml
<discocaml>
<Kali> let ( let+ ) = List.map
<discocaml>
<Kali>
<discocaml>
<Kali> let () = List.iter print_int (let+ x = [1;2;3;4;5] in x + 2)
<discocaml>
<Kali> (* 34567 *)
<discocaml>
<Kali> ```
<discocaml>
<Kali> *oops, i meant `let ( let+ ) l f = List.map f l`
<discocaml>
<Kali> and `let ( let* ) l f = List.concat_map f l`, respectively
<discocaml>
<Kali> you can also do some stuff with the custom indexing operators, like this:
<discocaml>
<Kali> ```ocaml
<discocaml>
<Kali> let ( .>() ) l f = List.map f l
<discocaml>
<Kali> let ( .!() ) l f = List.iter f l
<discocaml>
<Kali>
<discocaml>
<Kali> let () = [1;2;3;4;5].>(fun x -> x + 2).!(print_int)
<discocaml>
<Kali> ```
<discocaml>
<Kali> (the indexing operators don't have standard operator names associated with them like let-ops for applicatives (`+`)and monads (`*`) do as far as i know, so take my choice of indexing operator with a grain of salt)
<discocaml>
<geoff> oh god, I never thought of that use of indexing operators 😂
<discocaml>
<Kali> 😂 yeah, i would certainly not recommend doing this, it's not exactly the most readable
<discocaml>
<Kali> it looks kinda cool though...
<discocaml>
<Kali> i once gave all the common list functions their own indexing operation just for fun:
<discocaml>
<Kali> this is a very silly way to program, but it's good for laughs
<discocaml>
<vphantom> Kind of reminds me of Brainf*ck.
chrisz has quit [Ping timeout: 245 seconds]
chrisz has joined #ocaml
spip has quit [Quit: Konversation terminated!]
azimut has quit [Ping timeout: 240 seconds]
bartholin has joined #ocaml
Serpent7776 has joined #ocaml
Bitwiser has joined #ocaml
<discocaml>
<froyo> no that looks like something someone who writes apl-family langs would do lol
Bitwiser has quit [Ping timeout: 246 seconds]
bartholin has quit [Quit: Leaving]
Tuplanolla has joined #ocaml
bartholin has joined #ocaml
mima has joined #ocaml
mima has quit [Ping timeout: 245 seconds]
mima has joined #ocaml
amk has quit [Remote host closed the connection]
amk has joined #ocaml
mima has quit [Ping timeout: 246 seconds]
tom1212 has joined #ocaml
mima has joined #ocaml
<tom1212>
Hello! concerning "recursive" modules: got a functor UniPoly (R: Ring) -> sig include Ring module BaseRing = R end for univariate polys, I can define UniPoly(UniPoly(Integers)) for bivariate polys Z[X][Y]
<tom1212>
but if you do UniPoly(UniPoly(Integers)).BaseRing you get a Ring and loose the fact that it is actually a poly
<tom1212>
is there a way to keep the info that BaseRing is actually a poly in this case?
<tom1212>
I'd like to define NVariatePoly (R: Ring) (sig val arity:int end) -> sig include Ring module BaseRing = R val arity: int end and do write a function to assert that NVariatePoly(Z)(struct let arity=2 end)=UniPoly(UniPoly(Integers)) and for that I need to introspect the base ring
mima has quit [Ping timeout: 246 seconds]
<tom1212>
brb, can check out the logs
tom1212 has left #ocaml [#ocaml]
mima has joined #ocaml
mima has quit [Ping timeout: 245 seconds]
mima has joined #ocaml
mima has quit [Ping timeout: 246 seconds]
<discocaml>
<yugamii> si there any documentation on using cohttp-eio?
<discocaml>
<yugamii> si there any documentation on using cohttp-eio client?
bartholin has quit [Quit: Leaving]
mima has joined #ocaml
waleee has joined #ocaml
tom1212 has joined #ocaml
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
spip has joined #ocaml
mima has quit [Ping timeout: 246 seconds]
tom1212 has quit [Remote host closed the connection]
tom1212 has joined #ocaml
azimut has joined #ocaml
mima has joined #ocaml
bartholin has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
norris98 has joined #ocaml
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Ping timeout: 246 seconds]
waleee has quit [Ping timeout: 246 seconds]
norris98 has quit [Ping timeout: 246 seconds]
tom1212 has left #ocaml [#ocaml]
alexherbo2 has joined #ocaml
waleee has joined #ocaml
ced1 has joined #ocaml
ced1 is now known as cedb
norris14 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
norris14 has quit [Quit: Client closed]
bartholin has quit [Quit: Leaving]
mima has quit [Ping timeout: 246 seconds]
mima has joined #ocaml
mima has quit [Ping timeout: 240 seconds]
Serpent7776 has quit [Ping timeout: 246 seconds]
azimut has quit [Remote host closed the connection]