Opened 7 years ago

Closed 4 years ago

#2193 closed bug (fixed)

Monomorphic Pattern Bindings and Error Messages

Reported by: sclv Owned by: simonpj
Priority: normal Milestone: 7.0.1
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: boxy/T2193
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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)))'

Change History (9)

comment:1 Changed 7 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 6.8.3

Thanks for the report!

comment:2 Changed 7 years ago by igloo

  • Milestone changed from 6.8.3 to 6.10.1

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Multiple to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Multiple to Unknown/Multiple

comment:5 Changed 6 years ago by igloo

  • Milestone changed from 6.10.1 to 6.10.2

comment:6 Changed 6 years ago by simonpj

  • Owner set to igloo

The HEAD now correctly says

T2193.hs:9:0:
    Illegal polymorphic or qualified type: forall s. s
    Perhaps you intended to use -XImpredicativeTypes
    In the type signature for `bar':
      bar :: a -> Foo (forall s. s) a

If you add -XImpredicativeTypes then we indeed get the (silly) error message described in the original bug report, but I'm not going to fiddle with that now, because Dimitrios and I are (still) planning to rejig the entire implementation of impredicative types.

So let's leave this open for that reason.

IAN: I hope 6.10.2 also reports the above Illegal polymorphic... error. Can you check, and then bump the milestone to 6.12 and assign it to me?

Simon

comment:7 Changed 6 years ago by igloo

  • Milestone changed from 6.10.2 to 6.12.1
  • Owner changed from igloo to simonpj

comment:8 Changed 5 years ago by igloo

  • Milestone changed from 6.12.1 to 6.14.1
  • Type of failure set to None/Unknown

Still happens with 6.12.

comment:9 Changed 4 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to boxy/T2193

This works with GHC 7.0.

Simon

Note: See TracTickets for help on using tickets.