Proposal to deprecate and then drop fromJust

Joachim Breitner mail at joachim-breitner.de
Tue Feb 24 11:29:21 UTC 2015


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150224/4a0c5760/attachment-0001.sig>


More information about the Libraries mailing list