Proposal: Add readMaybe (and possibly readEither) to Prelude, make Haddocks for read more cautionary

Kris Nuttycombe kris.nuttycombe at gmail.com
Thu Jan 5 16:22:17 UTC 2017


On Thu, Jan 5, 2017 at 7:01 AM, Phil Ruffwind <rf at rufflewind.com> wrote:

> Rather than deprecating a function, it would be nice to have some sort
> of {-# PARTIAL #-} pragma to warn the user that 'read' is a partial
> function (and similarly for 'head', 'tail' and its friends), much like
> how GHC already warns about partial case-blocks.  That being said, it's
> probably best to delay this until there is a way to explicitly turn of
> the warnings individually at the call site for those who want
> warning-free code.


This strikes me as the right avenue to pursue. While I'd personally be
happy to expunge partial functions from base entirely, I recognize that
others have different needs - and a {-# PARTIAL #-} pragma would have broad
utility. Coupled with a -fno-warn-partial flag, users would be able to
opt-in to the status quo, but the default would be to steer people away
from partial functions, which seems like the right thing. For new users,
the warnings would be educational, since for many people coming from
languages where many "functions" are partial the idea of totality is
something that needs to be learned.

Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170105/5991acea/attachment.html>


More information about the Libraries mailing list