Skip to content

Instantly share code, notes, and snippets.

@keigoi
Created September 10, 2012 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keigoi/3694857 to your computer and use it in GitHub Desktop.
Save keigoi/3694857 to your computer and use it in GitHub Desktop.
weaker kind-inference in ghc 7.4.1
{-# LANGUAGE ScopedTypeVariables, KindSignatures #-}
import Data.Typeable
innerTypeOf :: Typeable a => t a -> TypeRep
innerTypeOf (x :: t a) = typeOf (undefined :: a) -- fail
-- giving a kind explicitly will do
-- innerTypeOf (x :: t (a:: *)) = typeOf (undefined :: a) -- ok
main = print (innerTypeOf ([1]::[Int])) -- print 'Int'
{-
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1
$ ghc --make Kind.hs
[1 of 1] Compiling Main ( Kind.hs, Kind.o )
Kind.hs:5:34:
Expecting an ordinary type, but found a type of kind k_agq
In an expression type signature: a
In the first argument of `typeOf', namely `(undefined :: a)'
In the expression: typeOf (undefined :: a)
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment