Created
March 25, 2010 21:08
-
-
Save spockz/344124 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
type Square = Square' Nil | |
data Square' t a = Zero (t (t a)) | Succ (Square' (Cons t) a) | |
data Nil a = Nil deriving Show | |
data Cons t a = Cons a (t a) deriving Show | |
mapNil :: (a -> b) -> Nil a -> Nil b | |
mapNil _ _ = Nil | |
mapCons :: ((a -> b) -> (t a -> t b)) | |
-> (a -> b) | |
-> (Cons t a -> Cons t b) | |
mapCons fT fA (Cons x xs) = Cons (fA x) (fT fA xs) | |
mapSquare' :: (forall b. (a -> b) -> (t a -> t b)) | |
-> (a -> b) | |
-> (Square' t a -> Square' t b) | |
mapSquare' fT fA (Zero xs) = fT (fT fA) xs | |
mapSquare' fT fA (Succ xs) = mapSquare' (mapCons fT) fA xs | |
-- Yields: | |
Ass5.lhs:134:31: | |
Occurs check: cannot construct the infinite type: t = Cons t | |
In the first argument of `mapSquare'', namely `(mapCons fT)' | |
In the expression: mapSquare' (mapCons fT) fA xs | |
In the definition of `mapSquare'': | |
mapSquare' fT fA (Succ xs) = mapSquare' (mapCons fT) fA xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment