Re:I learned Haskell in just 15 years
by nextaccountic on Tuesday June 18, 2024 @09:34AM
(#40717688)
Exceptions define an effect. Code with exceptions aren't actually pure in the sense that their return type doesn't fully describe what the code does, so it doesn't just map an input into an output: there is something else going on
In some pure functional languages, the pure fragment doesn't have exceptions, and you add exceptions as an effect (or as a monad)
(If you reify the effect with a type like Either or Result, then the code becomes pure: but that's just a monad like said above)
> in the sense that their return type doesn't fully describe what the code does
Sure they do, at least in Haskell. Bottom inhabits all types.
Re:I learned Haskell in just 15 years
by nextaccountic on Sunday June 23, 2024 @12:25AM
(#40764780)
There's a difference between "doesn't return because it has an infinite loop" and "doesn't return because it threw an exception"
Haskell can't express the difference, but languages with effects, like Koka and F*, can!
The first effect is called div in Koka and the second is called exn, section 2.2 here
https://www.microsoft.com/en-us/research/wp-content/uploads/...
It's fine if the poster above me wishes to change languages. Anyone who chooses to stick with Haskell should get comfortable with the notion that all functions can diverge, and accept that this is fully consistent with the Haskell type system.
Re:I learned Haskell in just 15 years
by nextaccountic on Tuesday June 18, 2024 @09:43AM
(#40717787)
Anyway I really like the take that Haskell is pure in the same sense that Rust is safe
Haskell has impure constructs but sets you up to define referentially transparent abstractions with them, and this is actually valued by the Haskell community
Exceptions aren't impure anyway.