#2641: Make -XExtendedDeafultRules a bit less liberal
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 6.12 branch
Component: Compiler | Version: 6.8.3
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Old description:
> The `-XExtendedDefaultRules` flag is very liberal about type-class
> defaults. Perhaps too liberal:
> {{{
> > *Main> quickCheck (\xs -> reverse xs == xs)
> > +++ OK, passed 100 tests.
> }}}
> Not good (reverse on lists is not the identity function). I expect a type
> error! Reason: reverse on list of () is indeed the identity function!
>
> [http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-
> evaluation.html#extended-default-rules The rules] are currently these:
> * All of the classes Ci are single-parameter type classes.
> * At least one of the classes Ci is numeric, or is Show, Eq, or Ord.
>
> Maybe we should tighten up the second rule to say:
> * '''All''' of the classes Ci is numeric, or is Show, Eq, or Ord.
> Then the Quickcheck example would not bogusly succeed in typechecking,
> because there's an `Arbitrary` constraint involved.
>
> This ticket is to record the idea and canvas opinion. Record thoughts
> below.
New description:
The `-XExtendedDefaultRules` flag is very liberal about type-class
defaults. Perhaps too liberal:
{{{
> *Main> quickCheck (\xs -> reverse xs == xs)
> +++ OK, passed 100 tests.
}}}
Not good (reverse on lists is not the identity function). I expect a type
error! Reason: reverse on list of () is indeed the identity function!
[http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-
evaluation.html#extended-default-rules The rules] are currently these:
* All of the classes Ci are single-parameter type classes.
* At least one of the classes Ci is numeric, or is Show, Eq, or Ord.
Maybe we should tighten up the second rule to say:
* '''All''' of the classes Ci is numeric, or is Show, Eq, or Ord.
Then the Quickcheck example would not bogusly succeed in typechecking,
because there's an `Arbitrary` constraint involved.
This ticket is to record the idea and canvas opinion. Record thoughts
below.
See also
* #2853
* #2854
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2641#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs