[core libraries] Tightening up on inferred type signatures
Edward Kmett
ekmett at gmail.com
Mon Apr 21 12:25:10 UTC 2014
No objections here.
The types involved really *do* have FlexibleContexts in them, so it makes
sense to require the extension.
The upgrade path for library authors is also clear. It'll complain to add
the extension, and they'll fix it by adding the line of code suggested and
perhaps realize something about their code in the process.
-Edward
On Mon, Apr 21, 2014 at 4:30 AM, Simon Peyton Jones
<simonpj at microsoft.com>wrote:
> Friends
>
> GHC generally obeys this rule
>
> · If GHC infers a type *f::type*, then it’s OK for you to add a
> type signature saying exactly that.
>
> For example, it rejects inferred types that are ambiguous. I think this
> is a good property; it was certainly the source of many bug reports before
> inferred ambiguous types were rejected.
>
> However, up to now (including in 7.8) GHC hasn’t followed this rule
> consistently. In particular, it will infer types like
>
> fold :: (Functor (PF a), Regular a) => (PF a b -> b) -> a -> b
>
> (where PF is a type family). If you write this as a type signature, GHC
> will insist on FlexibleContexts and TypeFamilies.
>
> So in https://ghc.haskell.org/trac/ghc/ticket/8883, Jan has made GHC
> check inferred types in the same way that it checks declared types, thus
> rejecting the above inferred type unless you give the language extensions.
>
> This makes the compiler more consistent.
>
> But it does mean that some code may be rejected that 7.8 accepts. This
> email is just a heads-up that you might want to compile your library with
> 7.10 (i.e. a snapshot of HEAD) well in advance. There will be other
> breaking changes of course; e.g Applicative will finally be a superclass of
> Monad, for example.
>
> Simon
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "haskell-core-libraries" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to haskell-core-libraries+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140421/34f53f6e/attachment.html>
More information about the Libraries
mailing list