Types of generated data constructors for dictionaries
Simon Peyton-Jones
simonpj at microsoft.com
Thu Aug 28 09:50:46 EDT 2008
> class Eq a => Eq2 a where eq :: a -> a -> Bool
Based on the runtime representation above, I expect the type of Main.:DEq2 to be
Main.:DEq2 :: GHC.Base.:TEq a -> (a -> a -> Bool) -> Main.:TEq2 a
but GHC tells me, via (fmap dataConRepType . tcLookupDatacon), the following
Main.:DEq2 :: (a -> a -> Bool) -> Main.:TEq2 a
Why does the type of :DEq2 differ from what :print sees at runtime ?
Are you sure it's different? Here's what I get (below). Note the type of :DEq2.
Can you tell me how to reproduce what you are seeing?
Simon
module Foo where
class Eq a => Eq2 a where
op :: a -> a -> Bool
ghc -c -ddump-types Foo.hs -dppr-debug
TYPE SIGNATURES
main:Foo.$p1Eq2{v r5P} [gid] :: forall a{tv a5D} [tv].
(main:Foo.Eq2{tc r5z} a{tv a5D} [tv]) =>
<pred>base:GHC.Base.Eq{tc 23} a{tv a5D} [tv]
main:Foo.:DEq2{v r5R} [gid] :: forall a{tv a5D} [tv].
(base:GHC.Base.Eq{tc 23} a{tv a5D} [tv]) =>
(a{tv a5D} [tv] -> a{tv a5D} [tv] -> base:GHC.Base.Bool{(w) tc 3c})
-> (main:Foo.:TEq2{tc r5Q}) a{tv a5D} [tv]
main:Foo.op{v r5B} [gid] :: forall a{tv a5D} [tv].
(main:Foo.Eq2{tc r5z} a{tv a5D} [tv]) =>
a{tv a5D} [tv] -> a{tv a5D} [tv] -> base:GHC.Base.Bool{(w) tc 3c}
TYPE CONSTRUCTORS
data (:TEq2{tc}) a
RecFlag NonRecursive
Generics: no
= :DEq2{d} :: forall a.
base:GHC.Base.Eq{tc 23} a =>
(a -> a -> base:GHC.Base.Bool{(w) tc 3c}) -> :TEq2{tc} a
Stricts: _
FamilyInstance: none
Tycons with generics:
Dependent modules: []
Dependent packages: [base]
bash-3.2$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/cvs-ghc/attachments/20080828/9ec23e38/attachment.htm
More information about the Cvs-ghc
mailing list