3 ms·
> But the obvious and easy solution in the current language would be to return Maybe, which isn't done because there's a feeling that it's not a big enough step
by tome 3y ago
> But the obvious and easy solution in the current language would be to return Maybe, which isn't done because there's a feeling that it's not a big enough step to be worth the effort, and dependent types will eventually solve this anyway.
That's not why it's not done. listToMaybe already exists[1] and you can't change the type of head without breaking everyone's code, so head in the next version of base will come with a warning[2] and that's about as much as you can do whilst still maintaining backwards compatibility.
[1] https://www.stackage.org/haddock/lts-21.14/base-4.17.2.0/Data-Maybe.html#v:listToMaybe https://www.stackage.org/haddock/lts-21.14/base-4.17.2.0/Dat...
[2] https://github.com/haskell/core-libraries-committee/issues/87 https://github.com/haskell/core-libraries-committee/issues/8...