[GHC] #12121: FlexibleContexts is under specified
GHC
ghc-devs at haskell.org
Thu May 26 11:04:33 UTC 2016
#12121: FlexibleContexts is under specified
-------------------------------------+-------------------------------------
Reporter: thomie | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Documentation | Version: 8.0.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Documentation
Unknown/Multiple | bug
Test Case: | Blocked By:
Blocking: | Related Tickets: #12010
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
I've been reading the documentation on `FlexibleContexts`. It's pretty
confusing.
=== Structure
The documentation is scattered around 3 different sections:
* 9.8.1.2. The superclasses of a class declaration (this is where the
[http://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/glasgow_exts.html
#ghc-flag--XFlexibleContexts link] from the flag reference takes you).
* 9.8.3.3. Relaxed rules for instance contexts
* 9.15.2. The context of a type signature
Maybe it's ok to separate it like this, but it took me a while to figure
out that there //are// actually three different sections. A simple
solution would be to mention that there are 3 different sections, in each
section (it already does so in the last section).
=== Specification
> The -XFlexibleContexts flag lifts the Haskell 98 restriction that the
type-class constraints in a type signature must have the form `(class
type-variable)` or `(class (type-variable type1 type2 ... typen))`.
That's all fine and well, but hardly teaches me anything.
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`?
This is the old grammar:
{{{
context → class
| ( class1 , … , classn ) (n ≥ 0)
class → qtycls tyvar
| qtycls ( tyvar atype1 … atypen ) (n ≥ 1)
}}}
What is the new one?
=== Examples
* These are the example mentioned in the section on the context of a class
declaration (9.8.1.2):
{{{
class Functor (m k) => FiniteMap m k where
class (Monad m, Monad (t m)) => Transform t m where
lift :: m a -> (t m) a
}}}
Problem is, they neither require `FlexibleContexts`, nor do they compile
with `FlexibleContexts`!
Those examples require `MultiParamTypeClasses`. `MultiParamTypeClasses`
doesn't enable `FlexibleContexts` automatically.
* The section on instance contexts doesn't have any examples.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12121>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list