Created
June 13, 2012 12:18
-
-
Save scan/2923719 to your computer and use it in GitHub Desktop.
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 GADTs #-} | |
module LenList where | |
data Zero | |
data Succ n | |
data LenList n a where | |
Nil :: LenList Zero a | |
Cons :: a -> LenList n a -> LenList (Succ n) a | |
data UnknownLenList a where | |
UnknownLenList :: LenList n a -> UnknownLenList a | |
type Square n a = LenList n (LenList n a) | |
-- type-checks | |
sq3 = | |
Cons (Cons 'a' . Cons 'b' . Cons 'c' $ Nil) . | |
Cons (Cons 'd' . Cons 'e' . Cons 'f' $ Nil) . | |
Cons (Cons 'g' . Cons 'h' . Cons 'i' $ Nil) $ | |
Nil | |
-- fails to type-check | |
sq_bad = | |
Cons (Cons 'a' . Cons 'b' . Cons 'c' $ Nil) . | |
Cons (Cons 'd' . Cons 'e' . Cons 'f' $ Nil) . | |
Cons (Cons 'g' . Cons 'h' $ Nil) $ | |
Nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment