Opened 11 years ago

Closed 11 years ago

Last modified 46 years ago

#310 closed bug (Fixed)

Data.Generics type error

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.4
Keywords: Cc:
Operating System: Architecture:
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

I get a strange type error when using
Data.Generics.Twins - but if I include the text of the
definition in my own file it works!

I attach two files, one type checks, one does not. The
only difference is that I move a definition between
modules.

/Patrik

Attachments (1)

testeq_bad.2.hs (701 bytes) - added by nobody 11 years ago.

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by nobody

comment:1 Changed 11 years ago by p1738j

Logged In: YES 
user_id=1151788

This was submitted by me (Patrik Jansson = p1738j at sf.net)
- I just loggon on too late. 

comment:2 Changed 11 years ago by p1738j

Logged In: YES 
user_id=1151788

-- I did not manage to later add the second file - here it
is instead:
-- I tested this with ghci-6.4.20050214
-----
{-# OPTIONS -fglasgow-exts #-}
import Data.Generics.Basics
import Data.Generics.Aliases
import Data.Generics.Twins(gmapAccumQ)

-- | Twin map for queries
gzipWithQ :: GenericQ (GenericQ r) -> GenericQ (GenericQ [r])
gzipWithQ f x y = case gmapAccumQ perkid funs y of
                   ([], r) -> r
                   _       -> error "gzipWithQ" 
 where
  perkid a d = (tail a, unGQ (head a) d)
  funs = gmapQ (\k -> GQ (f k)) x

-- | Generic equality: an alternative to \"deriving Eq\"
geq :: Data a => a -> a -> Bool
geq x y = geq' x y
  where
    geq' :: forall a b. (Data a, Data b) => a -> b -> Bool
    geq' x y =     (toConstr x == toConstr y)
                && and (gzipWithQ geq' x y)



comment:3 Changed 11 years ago by p1738j

Logged In: YES 
user_id=1151788

The error is the following:
Compiling Main             ( testeq_bad.hs, interpreted )

testeq_bad.hs:21:34:
    Inferred type is less polymorphic than expected
      Quantified type variable `a' escapes
      Expected type: a1 -> GenericQ Bool
      Inferred type: a1 -> a -> Bool
    In the first argument of `gzipWithQ', namely `geq''
    In the first argument of `and', namely `(gzipWithQ geq'
x y)'
Failed, modules loaded: none.

comment:4 Changed 11 years ago by p1738j

Logged In: YES 
user_id=1151788

Background: I tried to use Nils Ander Danielssons
"ChasingBottoms" package for doing some "bottom-debugging"
of code. In 6.2.2 it works fine, but when "upgrading" to a
6.4 release candidate I had to do this strange copying

comment:5 Changed 11 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 
user_id=50165

Fixed, thank you.  Type synonyms in interface files weren't 
being "hoisted".   tc191.hs is the regression test
Note: See TracTickets for help on using tickets.