ygrek has quit [Remote host closed the connection]
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<twobitsprite>
So, I've noticed that libraries often will return an Error | Ok option, but ocaml does support exceptions... are exceptions not preferred in ocaml?
<discocaml>
<._null._> Exceptions bubble up potentially indefinitely, such `result` values cannot. Some users want the first behaviour, some the second one
<discocaml>
<ada2k> twobitsprite: result values are also encoded in the type of a function, whereas the best we have for exceptions is odoc
<discocaml>
<Kali> hopefully with typed effects that will not be the case, but those don't exist yet
Anarchos has joined #ocaml
<twobitsprite>
ok, so typed results are more easy to handle than exceptions?
<discocaml>
<._null._> Not easier to handle, rather more difficult (impossible) to forget
<twobitsprite>
ah, good point
<discocaml>
<yawaramin> but on the other hand, exceptions are more flexible, offer stack traces, and unwind the stack safely for you. they don't force you to use convoluted logics to handle lists of values and whatnot
<discocaml>
<yawaramin> and I/O errors are always surfaced as exceptions because they come from the 'Unix' layer
<twobitsprite>
So, maybe for "fatal" errors, I could use exceptions, but for handle-able errors, use result options?
<discocaml>
<ada2k> yeah, that's generally good practice
<twobitsprite>
ok, thanks
<discocaml>
<ada2k> if you add odoc comments as well people using ides with support will be able to see hints about what exceptions a function can throw
<twobitsprite>
I just use vim...
<discocaml>
<ada2k> like typed exceptions?
<discocaml>
<._null._> (In this context, exceptions are an instance of effects)
<twobitsprite>
I've tried the vi implementation in several IDEs, including emacs vile/viper/etc, but my fingers just find unimplemented vim features and I can't adjust
<discocaml>
<._null._> How well does vim support LSP ? OCaml has one, so maybe this already works
<discocaml>
<Kali> there is merlin for vim, i think
<discocaml>
<Kali> i tried using it but it didn't work the first time so i kinda just gave up since i don't really care about lsp features
<twobitsprite>
what is LSP?
<discocaml>
<ada2k> how would that work? using effects instead of exceptions, or having exceptions be a type of effect that can't continue or?
<discocaml>
<Kali> "language server protocol", it's a thing for integrating your editor with the compiler of a language you're using for real-time errors and hints and stuff
<discocaml>
<._null._> The latter I guess. I think it's more that exceptions behave the same as effects wrt. typing, so supporting one means supporting both
<discocaml>
<ada2k> yeah, that would be less confusing than leaving exceptions untyped or having two overlapping types for control flow breaking stuff
<discocaml>
<ada2k> is there any formal proposal for any of this yet?
<discocaml>
<ada2k> "formal" as in somebody sketching out how it might work
<discocaml>
<._null._> There are languages where this is implemented, Koka I think
<twobitsprite>
doesn't java have a way to declare what exceptions a method can raise?