Proposal to deprecate and then drop fromJust

Michael Snoyman michael at snoyman.com
Tue Feb 24 11:32:14 UTC 2015


We could also automatically detect basic partiality, like incomplete
pattern matches, and add partiality warnings. Depending on how much work
that is, it may be easier than trying to mark up all of base correctly.

On Tue, Feb 24, 2015, 1:29 PM Joachim Breitner <mail at joachim-breitner.de>
wrote:

> Hi,
>
> Am Dienstag, den 24.02.2015, 11:33 +0100 schrieb Henning Thielemann:
> > On Tue, 24 Feb 2015, Joachim Breitner wrote:
> >
> > > If you would continue this thought of line towards some consistency,
> > > then we’d need a way to annotate partial functions in general, and have
> > > a dedicated flag -fwarn-partial-functions. (It would behave just like
> > > deprecations – but reported separately.).  This would go well with
> > > -fwarn-incomplete-patterns. Such a thing might be useful.
> >
> > I have thought about it in the past and it is certainly better than no
> > such warning. On the other hand partiality can be caused by infinite
> loops
> > and is then hard to detect. To be completely sure you would have to
> > implement a termination checker as in liquid-haskell. Nonetheless, a
> > partiality marker for every function that might call 'error' or
> > 'undefined' would be useful.
>
> note that I am not proposing that GHC would figure out what is total and
> what not, but simply that you could say
>
> fromJust :: Maybe a -> a
> fromJust (Just a) = a
> {-# WARNING (partial) fromJust "fromJust is partial #-}
>
> and the user will see the warnings if he enables -fwarn-partial. If no
> such annotation is given, no warning is printed.
>
> A proper totally checker would be a whole different beast :-)
>
> (Note that here, I am inventing a syntax to categorize the warnings into
> groups, so that the user can choose whether to see partiality warnings
> or not independently from other uses of WARNING.)
>
> Greetings,
> Joachim
>
> --
> Joachim “nomeata” Breitner
>   mail at joachim-breitner.dehttp://www.joachim-breitner.de/
>   Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0xF0FBF51F
>   Debian Developer: nomeata at debian.org
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150224/0ab5edb4/attachment.html>


More information about the Libraries mailing list