Skip to content

Instantly share code, notes, and snippets.

@djv
Created February 6, 2014 00:16
Show Gist options
  • Save djv/8836081 to your computer and use it in GitHub Desktop.
Save djv/8836081 to your computer and use it in GitHub Desktop.
{-# LANGUAGE GADTs, StandaloneDeriving #-}
data List a b where
Nil :: List a b
ConsI :: Int -> List Bool Int -> List Int Bool
ConsB :: Bool -> List Int Bool -> List Bool Int
deriving instance (Show a, Show b) => Show (List a b)
*Main> :t ConsI 1 (ConsB True Nil)
ConsI 1 (ConsB True Nil) :: List Int Bool
*Main> :t ConsI 1 (ConsI True Nil)
<interactive>:1:10:
Couldn't match expected type `Bool' with actual type `Int'
Expected type: List Bool Int
Actual type: List Int Bool
In the return type of a call of `ConsI'
In the second argument of `ConsI', namely `(ConsI True Nil)'
*Main> :t ConsI 1 (ConsI 2 Nil)
<interactive>:1:10:
Couldn't match expected type `Bool' with actual type `Int'
Expected type: List Bool Int
Actual type: List Int Bool
In the return type of a call of `ConsI'
In the second argument of `ConsI', namely `(ConsI 2 Nil)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment