[GHC] #12121: FlexibleContexts is under specified

GHC ghc-devs at haskell.org
Thu May 26 11:54:41 UTC 2016


#12121: FlexibleContexts is under specified
-------------------------------------+-------------------------------------
        Reporter:  thomie            |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Documentation     |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Documentation     |  Unknown/Multiple
  bug                                |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #12020            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 That's bad.  Would you be willing to fix it if I tell you the
 specification?

 > I would like to know which type-class constraints are allowed with
 FlexibleContexts. Or in other words: what is a definition of a "type-class
 constraint" with FlexibleContexts?

 With `FlexibleContexts` you can put anything `Constraint`-kinded in the
 context. Except
  * For class decls, no implicit parameters
  * For instance decls, no implicit parameters, and must be smaller than
 the head unless `UndecidableInstances`.

 For contexts in type signatures Haskell 98 allowed `Functor (m k)`, or
 even `Functor (m [k])`; anything headed by a tyvar, as in the syntax for
 `context` above.  But the Haskell 98 report is more restrictive for class
 decls; they are supposed to be `cls tyvar`.  Alas, GHC does not do this;
 it treats them the same as type signatures.  Henc, yes,
 {{{
 class Functor (m k) => FiniteMap m k where
 }}}
 does not require `FlexibleContexts`.  (It does compile with
 `FlexibleContexts` though, doesn't it?)   I don't know whether it is worth
 tightening this up.

 Does that help?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12121#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list