<d_bot>
<antron> @bikal probably the empty variant, also known as bottom
<d_bot>
<octachron> A type without value: `let never: 'a. void -> 'a = function _ -> . `
Sanduni has quit [Quit: Connection closed]
TheLemonMan has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<d_bot>
<bikal> Is there a specific use case where using `void` type is unavoidable? I mean using just `type _ t = | [] : 'a t .....` works too, right?
<henistein>
I am trying to make a function that removes the first two elements and the last elemento of a list, what am I doing wrong? https://pastebin.pl/view/3daf4913
<d_bot>
<octachron> Using `'a t` will create issues with the value restriction on usage. Whereas using a real type is a bit adhoc.
<d_bot>
<octachron> Using an empty type can be a way to restrict the possible contructors in a ADT: a `void option` is always `None`.
bartholin has quit [Ping timeout: 240 seconds]
<octachron>
henistein, OCaml is white-space independent. The compiler reads your code as `List.rev l (let aux ... in aux m)`. You are missing quite a few connectors. And you are not handling the case of lists with less than three elements.
<henistein>
Well I know I am missing that case, but I will just use this function into a speciefic case, about the connectors could you give me some hints?
<octachron>
Even in this case, your function should cover this case itself and raise an exception. You need to add some `let`s to name your intermediary results.
<octachron>
Note that you took my advice one step further and named your intermediary transforms. That works too.
mbuf has quit [Quit: Leaving]
waleee-cl has joined #ocaml
olle has joined #ocaml
tane has joined #ocaml
<d_bot>
<bikal> So here `type dyn` is the companion type witness?
olle has quit [Ping timeout: 240 seconds]
<henistein>
There are some examples how can I convert a list into matrix (array array)? I have been searching on internet and I could not find too much. Ocaml has Array.of_list, but I want to convert like this: https://pastebin.com/wfdTjGwS
<octachron>
henistein: you can define a chunk function : int -> 'a list -> 'a list list. Then convert the result into an array.
<Armael>
/w 47
<Armael>
arg
<d_bot>
<octachron> @bikal: no the witness is the type 'a ty: since by observing a value of type 'a ty in a pattern matching, you can deduce the type `'a`.
<d_bot>
<octachron> `dyn` is a packing together a matching list of witness and values, then forgetting the type of `'a` to get a value whose type is not-dependent.
<d_bot>
<bikal> Ah, so type witness means *holds type information*. In our case that is `'a ty` since it holds the type information for the HL.
<d_bot>
<bikal> would types like `dyn` be called *universal* type?
<d_bot>
<bikal> RE: type witness, are they sometimes encoded as extensible types, eg `type 'a witness = ..` so that it can be extended by for example user level code?
<d_bot>
<octachron> No? Universal types are distinct notions. Yes, `hmap` work with a extensible type witness that can register a new witness for each keys.
<d_bot>
<bikal> k
<d_bot>
<bikal> hmm ... just a conjecture. We wouldn't need this technique of *type witness* if OCaml provided runtime type information, or reflection in .NET - correct ?
<d_bot>
<octachron> A typed runtime type representation *is* a type witness.
vicfred has joined #ocaml
<d_bot>
<Curzon> Just wondering
<d_bot>
<Curzon> What do you guys use OCaml for other than compilers
<henistein>
What is the easiest method to print an array of int?
<octachron>
Using the Fmt library: Fmt.(Dump.array int) Fmt.stdout [|1;2;3|]
<d_bot>
<rw> it's a general-purpose language, so you can find people using it for just about anything
<d_bot>
<rw> I'm personally interested in using it for CLI tools and web apps
<d_bot>
<bikal> 👍
Sumera[m] has quit [Ping timeout: 245 seconds]
Sumera[m] has joined #ocaml
anton_5[m] has quit [Ping timeout: 245 seconds]
<d_bot>
<EduardoRFS> Is OCaml with MSVC still a thing? Like, do people still use it?
anton_5[m] has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
TheLemonMan has joined #ocaml
TheLemonMan has quit [Client Quit]
TheLemonMan has joined #ocaml
hackinghorn has quit [Quit: Leaving]
wonko7 has joined #ocaml
tmhoang520 has quit [Quit: Alpine Linux, the security-oriented, lightweight Linux distribution]
ania123 has joined #ocaml
tmhoang520 has joined #ocaml
ania123 has quit [Quit: Connection closed]
vicfred has quit [Quit: Leaving]
henistein has quit [Quit: Connection closed]
henistein has joined #ocaml
<henistein>
It is possible to merge this two lambdas in only one? The first removes two first elements, and second removes last, https://pastebin.com/mSb1c5Zk
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
olle has joined #ocaml
<zozozo>
henistein: I think your second function is not correct
<zozozo>
you probably want something like `fun l -> List.rev (m2 (List.rev your_input_list)` to actually remove the last element
<zozozo>
err. `fun l -> List.rev (m2 (List.rev l))`
<olle>
2 revs to remove one elemtent???
<olle>
booo
<zozozo>
assuming `m2 = fun hd :: tl -> tl`
<zozozo>
yeah, it's hreally not efficient indeed
<olle>
what about double-linked lists in ocaml?
<zozozo>
you need to use mutable fields for that, and well, it's slightly more complicated
<olle>
hm
<zozozo>
but *if* removing the last element is a time-sensitive operation (i.e. you use it frequently), it highyl suggests simple lists are not the best data structure
<olle>
yeah
<olle>
might as well use array with option elements
<olle>
and just skip the none's
<zozozo>
or vectors/resizable arrays
<olle>
yeah
safinaskar has joined #ocaml
safinaskar has quit [Client Quit]
safinaskar has joined #ocaml
<safinaskar>
i am attempting to install ocaml using instructions from https://ocaml.org/learn/tutorials/up_and_running.html . (i am installing in docker.) i reached command "opam switch create 4.11.1". i typed it and i see: "[ERROR] Compiler selection '4.11.1' is ambiguous. matching packages: { ocaml-base-compiler.4.11.1, ocaml-system.4.11.1 }". what to do?
olle has quit [Ping timeout: 265 seconds]
<octachron>
I would propose to install 4.12.0 (or 4.11.2, if you really need 4.11), then no more conflict with your system version of ocaml.
radiopotin[m] has quit [Ping timeout: 248 seconds]
pqwy[m] has quit [Ping timeout: 258 seconds]
serif[m] has quit [Ping timeout: 258 seconds]
jimt[m] has quit [Ping timeout: 258 seconds]
peddie has quit [Ping timeout: 258 seconds]
BitPuffin has quit [Ping timeout: 258 seconds]
Sumera[m] has quit [Ping timeout: 272 seconds]
smondet[m] has quit [Ping timeout: 247 seconds]
lnxw37d4 has quit [Ping timeout: 247 seconds]
Tardigreat[m] has quit [Ping timeout: 272 seconds]
ELLIOTTCABLE has joined #ocaml
nullcone has quit [Ping timeout: 248 seconds]
b20n has joined #ocaml
adi__________ has joined #ocaml
raver has joined #ocaml
bytesighs has joined #ocaml
chewbranca has joined #ocaml
higherorder__ has joined #ocaml
bronsen has joined #ocaml
cbarrett has joined #ocaml
artart78 has joined #ocaml
webshinra has joined #ocaml
jbrown has joined #ocaml
dwt has joined #ocaml
thizanne has joined #ocaml
mrallen1 has joined #ocaml
notnotdan_ has joined #ocaml
Coldfusion[m] has quit [Ping timeout: 276 seconds]
aspiwack[m] has quit [Ping timeout: 276 seconds]
higherorder__ has quit [Ping timeout: 283 seconds]
dash has quit [Ping timeout: 246 seconds]
anton_5[m] has quit [Ping timeout: 276 seconds]
ahf has quit [Ping timeout: 260 seconds]
stux|RC has joined #ocaml
robmyers has joined #ocaml
cemerick has quit [Ping timeout: 258 seconds]
stephe has quit [Ping timeout: 250 seconds]
chewbranca has quit [Ping timeout: 265 seconds]
b20n has quit [Ping timeout: 265 seconds]
ahf has joined #ocaml
cemerick has joined #ocaml
cbarrett has quit [Ping timeout: 260 seconds]
higherorder__ has joined #ocaml
waleee-cl has joined #ocaml
b20n has joined #ocaml
rfv has joined #ocaml
JSharp has joined #ocaml
chewbranca has joined #ocaml
SrPx has joined #ocaml
stephe has joined #ocaml
terabit has joined #ocaml
JSharp has quit [Client Quit]
JSharp has joined #ocaml
cbarrett has joined #ocaml
nullcone has joined #ocaml
waleee-cl has quit []
waleee-cl has joined #ocaml
<d_bot>
<Curzon> Like I heard Jane Street uses it for like trading?
waleee-cl has quit [Client Quit]
<drakonis>
yes.
aecepoglu[m] has joined #ocaml
<d_bot>
<froyo> I find the interaction beterrn or-patterns and when-guards a little annoying..
<d_bot>
<froyo> `function A | B | C x when x < 2 -> ... | C x -> ...`
<d_bot>
<froyo> won't work because the `when` guard binds to the whole or-pattern, not just its own clause. i.e.
<d_bot>
<froyo> `function (A | B | C x when x < 2) -> ... | C x -> ...`
<d_bot>
<froyo> not
<d_bot>
<froyo> `function A | B | (C x when x < 2) -> ... | C x -> ...`
<d_bot>
<froyo> I wonder what's the rationale
dash1 has joined #ocaml
waleee-cl has joined #ocaml
tane has quit [Quit: Leaving]
rpcope has quit [Ping timeout: 268 seconds]
pqwy[m] has joined #ocaml
radiopotin[m] has joined #ocaml
labor[m] has joined #ocaml
lnxw37d4 has joined #ocaml
Sumera[m] has joined #ocaml
BitPuffin has joined #ocaml
aditi314 has joined #ocaml
jimt[m] has joined #ocaml
dieggsy has joined #ocaml
peddie has joined #ocaml
Tardigreat[m] has joined #ocaml
smondet[m] has joined #ocaml
flux has joined #ocaml
aspiwack[m] has joined #ocaml
avsm[m] has joined #ocaml
anton_5[m] has joined #ocaml
Coldfusion[m] has joined #ocaml
serif[m] has joined #ocaml
elusive has quit [Ping timeout: 245 seconds]
c4rc4s has quit [Changing host]
c4rc4s has joined #ocaml
ahf has joined #ocaml
ahf has quit [Changing host]
dieggsy is now known as Guest50292
ELLIOTTCABLE is now known as Guest10365
terabit is now known as Guest17825
nullcone is now known as Guest43593
dan64 is now known as Guest19992
JSharp is now known as Guest98452
Jesin has joined #ocaml
astronavt has joined #ocaml
Guest98452 has quit []
JSharp has joined #ocaml
cantstanya has joined #ocaml
andreas303 has joined #ocaml
Ekho has joined #ocaml
Serpent7776 has quit [Quit: leaving]
<henistein>
There is some easy way to slice a list list? Per example, get 1st quadrant of a list list
waleee-cl has quit []
waleee-cl has joined #ocaml
<d_bot>
<score> many libraries provide a `List.take` function (not in Stdlib unfortunately) which you could use like: `List.take (List.length lst / 4) lst`
<d_bot>
<score> if you don't have a "take", it's easy to write. e.g. `let rec take n = function x :: xs when n > 0 -> x :: take (pred n) xs | _ -> []`
<henistein>
Oh this is exactly what I need, thank you