[GHC] #13537: Adding underscore (m :: _) to pattern variable makes it fail
GHC
ghc-devs at haskell.org
Fri Apr 7 09:33:17 UTC 2017
#13537: Adding underscore (m :: _) to pattern variable makes it fail
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1
checker) |
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by Iceland_jack):
* status: new => closed
* resolution: => invalid
Comment:
Replying to [comment:2 simonpj]:
> Now you want to force the type of the pattern to be `_`. But since GHC
only supports predicative polymorphism, `_` must be a monotype. So GHC
instantiates `forall a. a->a` to `alpha -> alpha` (for some new
unification variable alpha), and proceeds.
I suspected this was related to impredicativity. As a user I expected
transforming the pattern `m` to `(m :: _)` would have no effect since it
binds nothing (the compiler ''could'' special-case it, even though it
brings no benefits).
> Does that help?
>
> Is there some way we could improve the user manual?
Yes it helps. I think the impredicative polymorphism entry is rather good,
thanks for the explanation.
To be clear, this is also expected? Closing the ticket
{{{#!hs
-- Works
tId :: T -> T
tId (MkT g) = MkT g
-- Fails
tId :: T -> T
tId (MkT g) = MkT g' where
g' = g
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13537#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list