4 ms·
There is a Haskell function called headMay [1] that returns a Maybe, but the Prelude head function throws when given an empty list. Either way, pure code can t
by chadaustin 11y ago
There is a Haskell function called headMay [1] that returns a Maybe, but the Prelude head function throws when given an empty list.
Either way, pure code can throw exceptions in Haskell. Consider division by zero for example.
[1] https://hackage.haskell.org/package/safe-0.3.9/docs/Safe.html https://hackage.haskell.org/package/safe-0.3.9/docs/Safe.htm...