mechap has quit [Remote host closed the connection]
mechap has joined #ocaml
mizlan has joined #ocaml
tomku has joined #ocaml
<discocaml>
<dexmax> Is there a list function like hd that doesn't fail on an empty list and instead returns an empty list?
<companion_cube>
it wouldn't have the correct type
<companion_cube>
`List.hd [1] + 2` is ok, but `List.hd [] + 2` is not
<discocaml>
<octachron> Well, one could use the `List.t` encoding of option to have
<discocaml>
<octachron> `hd_opt_as_list: 'a list -> 'a list`. I am not sure if that function is really .. fruitful however.
<discocaml>
<partial.evaluation> you could always boot up common lisp and get what you want
<discocaml>
<contificate> at the cost of things you don't want
tomku has quit [Quit: Lost terminal]
waleee has quit [Ping timeout: 258 seconds]
waleee has joined #ocaml
tomku has joined #ocaml
<companion_cube>
:D
<companion_cube>
it exists, it's called Fun.id
<companion_cube>
(for most intent and purpose anyway)
<discocaml>
<deepspacejohn> I guess it would make sense if your objective is to "trim" a list, e.g. `trim: int -> 'a list -> 'a list` where you could use `trim 1 [1; 2; 3;] = [1]`
<companion_cube>
`CCList.take 1` does it :)
<discocaml>
<contificate> was looking at another stdlib impl via its odocs docs and realised that.. at least on that version of odoc, you can't.. Ctrl-f to find things by type
<companion_cube>
does it capture ctrl-f?? :s
<discocaml>
<contificate> nah, I think it just displays the type in some element that makes it hard to do a "literal" search - unless I'm sorely mistaken
<discocaml>
<contificate> this is an older version though, I gather - and at least the docs on ocaml.org/p/ work w/ my browser's C-f
<companion_cube>
hmm it works for me on firefox
<discocaml>
<contificate> works for me in firefox as well
motherfsck has quit [Read error: Connection reset by peer]
<companion_cube>
blame it on Sergei and Larry :p
<discocaml>
<contificate> but is it showing a different page in firefox
<discocaml>
<deepspacejohn> yeah, searching `'a t -> bool` works for me on that page, but I don't see `is_empty` on that page at all.
<discocaml>
<contificate> haha what
<discocaml>
<contificate> yeah, so I can search for `is_empty` on chromium, but not `'a t -> bool`, but I can search for instances of `'a t -> bool` that don't concern the non-present `is_empty` in Firefox
<discocaml>
<contificate> maybe it's different in a modern build and this has already been addressed but is too obscure a piece of lore to have reached me yet
<discocaml>
<deepspacejohn> oh nevermind, it's because I didn't open the collapsible section under `include Container.S1 with type 'a t := 'a t`. I see `is_empty` now.
<discocaml>
<contificate> ah
<discocaml>
<contificate> I'd still say that I can't search it in chromium, but maybe it's a me problem
<discocaml>
<deepspacejohn> I just tried in chrome and it doesn't work for me too. Firefox works as expected. Weird...
<discocaml>
<contificate> as I say, just something I noticed - maybe already discovered and addressed in newer version 🤷♂️
<companion_cube>
it just makes me angry at IO channels again :/
<sleepydog>
companion_cube: what part are you angry at? i remember you made a modular IO RFC that got approved awhile back
<companion_cube>
oh yeah, it was merged, but no one will have the patience to do it
<companion_cube>
certainly not me :((
<sleepydog>
ah, i saw the {In|Out}_channel modules come in at 4.1* and just assumed your ideas were taking time to percolate in. That's too bad, it's so nice being able to disguise arbitrary data sources behind a file-like interface in other languages
<companion_cube>
it is!
waleee has joined #ocaml
<discocaml>
<lubegasimon_> Do teams / individuals still use specification (pre-and postconditions) to reason about correctness or majority rely on writing tests?
<discocaml>
<lubegasimon_> Do teams / individuals still use specifications (pre-and postconditions) to reason about correctness or majority rely on writing tests?
mechap has joined #ocaml
Everything has quit [Quit: leaving]
dhil has quit [Ping timeout: 264 seconds]
<discocaml>
<sim642> In OCaml the first thing would be good typing even to rule out misuse if feasible
<discocaml>
<sim642> Tests are probably more common. I don't remember seeing function contracts because they can't be automatically checked (easily)
<discocaml>
<sim642> Property based testing would be somewhere between the two
Serpent7776 has quit [Quit: leaving]
bartholin has quit [Quit: Leaving]
olle has quit [Ping timeout: 272 seconds]
<discocaml>
<Ada> yeah, i came to this conclusion myself. OPAM definitely has a learning curve coming from other languages but it works well