#7268: Explicit type signatures for top level record pattern matches 
polymorphism
fail
---------------------------------------+------------------------------------
 Reporter:  TristanAllwood             |          Owner:                        
 
     Type:  bug                        |         Status:  new                   
 
 Priority:  normal                     |      Component:  Compiler (Type 
checker)
  Version:  7.4.1                      |       Keywords:                        
 
       Os:  Unknown/Multiple           |   Architecture:  Unknown/Multiple      
 
  Failure:  GHC rejects valid program  |       Testcase:                        
 
Blockedby:                             |       Blocking:                        
 
  Related:                             |  
---------------------------------------+------------------------------------
 Consider the following module, which declares a record with two fields
 (X), an instance of this record (x), and then (at the top level) pattern
 matches the fields of x to create two new functions.

 {{{
 {-# LANGUAGE RankNTypes #-}
 module Foo where

 data X
   = X { a :: forall a . a -> a , b :: Int -> Int }

 x :: X
 x = X { a = id, b = succ }

 succ' :: Int -> Int

 X { a = id', b = succ' } = x

 }}}

 If we ask ghci what the type of id' is, we get told:

 {{{
 :t id'
 id' :: a -> a
 }}}

 However adding this type explicitly, gives the following:

 {{{
 Foo.hs:15:9:
     Couldn't match expected type `forall a. a -> a'
                 with actual type `a -> a'
     In the pattern: X {a = id', b = succ'}
     In a pattern binding: X {a = id', b = succ'} = x
 Failed, modules loaded: none.
 }}}

 This can happen in practice when using (e.g.) Parsec's TokenParser.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7268>
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

Reply via email to