Created
September 9, 2014 12:39
-
-
Save anonymous/d838e68ce6a02412859f to your computer and use it in GitHub Desktop.
This file contains 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 #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE TypeFamilies #-} | |
data Z | |
data S n | |
type family Plus m n where | |
Plus Z m = m | |
Plus (S n) m = S (Plus n m) | |
data Vect n where | |
ZV :: Vect Z | |
CV :: Int -> Vect n -> Vect (S n) | |
instance Show (Vect n) where | |
show ZV = "Nil" | |
show (CV x v) = show x ++ " : " ++ show v | |
vecReverse :: Vect n -> Vect m -> Vect (Plus n m) | |
vecReverse ZV w = w | |
vecReverse (CV x v) w = vecReverse v (CV x w) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment