
#13537: Adding underscore (m :: _) to pattern variable makes it fail -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | 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: | -------------------------------------+------------------------------------- Comment (by simonpj): Consider this: {{{ data T where MkT :: (forall a. a->a) -> T f (MkT (g :: Int->Int)) = .. }}} Is this ok? Well yes. The argument of `MkT` has type `forall a. a->a`, but it can be instantiated to the type `Int->Int`, so we can legitimately end up with `g :: Int->Int`. In FC it'd look like {{{ f x = case x of MkT (g2 :: forall a.a->a) -> let g::Int->Int = g2 @ Int in ... }}} 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. And that is what you see in the first message "Found type wildcard...". But alas of course, in your example we need `m` to be a polytype, and making it a monotype leads to a subsequent rather obscure error message. Does that help? Is there some way we could improve the user manual? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13537#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler