Created
January 9, 2016 16:33
-
-
Save kosmikus/8348f0030d2fa7e6e149 to your computer and use it in GitHub Desktop.
Strange TypeError behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
import Data.Kind | |
import GHC.TypeLits (TypeError, ErrorMessage(..)) | |
type family Resolve (t :: Type -> Type) :: Type -> Type where | |
Resolve _ = TypeError (Text "ERROR") | |
-- testOK :: Resolve [] Int | |
-- testOK = [] | |
-- | |
-- • ERROR | |
-- • In the expression: [] | |
-- In an equation for ‘testOK’: testOK = [] | |
-- | |
-- testNOTOK1 :: Resolve [] Int | |
-- testNOTOK1 = () | |
-- | |
-- • Couldn't match type ‘()’ with ‘(TypeError ...)’ | |
-- Expected type: Resolve [] Int | |
-- Actual type: () | |
-- • In the expression: () | |
-- In an equation for ‘testNOTOK1’: testNOTOK1 = () | |
-- | |
-- testNOTOK2 :: Resolve [] Int | |
-- testNOTOK2 = 1 | |
-- | |
-- • No instance for (Num (TypeError ...)) | |
-- arising from the literal ‘1’ | |
-- • In the expression: 1 | |
-- In an equation for ‘testNOTOK2’: testNOTOK2 = 1 | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment