Skip to content

Wrong diagnostics for instance signature mismatch

Consider:


{-# LANGUAGE InstanceSigs, DataKinds, KindSignatures, GADTs #-}

data DayKind = Work | Rest

data Day :: DayKind -> * where

Mon :: Day Work Sat :: Day Rest

instance Num (Day c) where

fromInteger :: Int -> Day p fromInteger 1 = Mon fromInteger 6 = Sat


I get

$ ~/bin/ghci NumGADT.hs GHCi, version 7.5.20120410: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( NumGADT.hs, interpreted )

NumGADT.hs:10:18:

Method signature does not match class; it should be

fromInteger forall (p :: DayKind). Int -\> Day p
In the instance declaration for \`Num (Day c)'

Failed, modules loaded: none. Prelude>

It appears to me that instead of telling me the expected signature GHCi simply echoes what I have provided. This is not really useful ;-)

Trac metadata
Trac field Value
Version 7.5
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information