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.
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@joachim-breitner.de • http://www.joachim-breitner.de/
Jabber: nomeata@joachim-breitner.de • GPG-Key: 0xF0FBF51F
Debian Developer: nomeata@debian.org
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries