[GHC] #1809: type families: difference in type-checking between
compile-time and run-time
GHC
trac at galois.com
Sun Oct 28 20:29:51 EDT 2007
#1809: type families: difference in type-checking between compile-time and run-
time
-----------------------+----------------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8
Severity: normal | Keywords:
Difficulty: Unknown | Os: Linux
Testcase: | Architecture: x86
-----------------------+----------------------------------------------------
in the module
{{{
{-# LANGUAGE TypeFamilies #-}
module Main where
import Prelude hiding (head)
import qualified Prelude
type family Elem a :: *
class ListLike t where
head :: t -> Elem t
-- Instances
type instance Elem [a] = a
instance ListLike [a] where
head = Prelude.head
x = head [1 :: Int,2,3]
main = putStrLn . show $ x
}}}
Here is the resulting interactive session, which I think is weird:
{{{
$ ghci Main
GHCi, version 6.9.20071027: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( Main.hs, interpreted )
Ok, modules loaded: Main.
*Main> :t x
x :: Elem [Int]
*Main> putStrLn . show $ x
<interactive>:1:11:
No instance for (Show (Elem [Int]))
arising from a use of `show' at <interactive>:1:11-14
Possible fix: add an instance declaration for (Show (Elem [Int]))
In the second argument of `(.)', namely `show'
In the first argument of `($)', namely `putStrLn . show'
In the expression: putStrLn . show $ x
*Main> main
1
}}}
Behavior is similar in GHC version 6.8.0.20071028
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1809>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list