Tightening up on inferred type signatures

Simon Peyton Jones simonpj at microsoft.com
Mon Apr 21 08:30:59 UTC 2014


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140421/935588c2/attachment-0001.html>


More information about the Libraries mailing list