#2193: Monomorphic Pattern Bindings and Error Messages
-------------------------+--------------------------------------------------
    Reporter:  sclv      |       Owner:          
        Type:  bug       |      Status:  new     
    Priority:  normal    |   Component:  Compiler
     Version:  6.8.2     |    Severity:  normal  
    Keywords:            |    Testcase:          
Architecture:  Multiple  |          Os:  Multiple
-------------------------+--------------------------------------------------
 Not clear to me if the following should be a type error or if it should be
 allowed to unify properly. In either case, the error message is borked.


 {{{
 {-# OPTIONS -fglasgow-exts #-}

 module Test where

 data Foo x y = Foo {foo1 :: x, foo2 :: y}
 instance Functor (Foo x) where
     fmap f (Foo x y) = Foo x (f y)

 bar :: a -> Foo (forall s. s) a
 bar a = Foo undefined a

 main = print (foo2 (fmap (*2) (bar 2)))

 {-
 sclv.hs:12:20:
     Cannot match a monotype with `forall s. s'
     When matching `forall s. s'
               and `forall s. s'
       Expected type: Foo (forall s1. s1) a
       Inferred type: Foo (forall s1. s1) a
     In the first argument of `foo2', namely `(fmap ((* 2)) (bar 2))'
 -}
 }}}


 {{{
 *Test> :t bar (2 :: Integer)
 bar (2 :: Integer) :: Foo (forall s. s) Integer
 *Test> :t foo2 (bar (2 :: Integer))
 foo2 (bar (2 :: Integer)) :: Integer
 *Test> :t fmap (*2) (bar (2 :: Integer))
 fmap (*2) (bar (2 :: Integer)) :: Foo (forall s. s) Integer
 *Test> :t foo2 (fmap (*2) (bar (2 :: Integer)))

 <interactive>:1:6:
     Cannot match a monotype with `forall s. s'
     When matching `forall s. s'
               and `forall s. s'
       Expected type: Foo (forall s1. s1) Integer
       Inferred type: Foo (forall s1. s1) Integer
     In the first argument of `foo2', namely
         `(fmap ((* 2)) (bar (2 :: Integer)))'
 }}}

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