1 -- !!! a file mailed us by Ryzard Kubiak. This provides a good test of the code
2 -- !!! handling type signatures and recursive data types.
4 module ShouldSucceed where
7 data Pair a b = Mkpair a b
8 data List alpha = Nil | Cons alpha (List alpha)
9 data Nat = Zero | Succ Nat
10 data Tree t = Leaf t | Node (Tree t) (Tree t)
12 idb :: Boolean -> Boolean
16 swap :: Pair a b -> Pair b a
18 Mkpair x y -> Mkpair y x
20 neg :: Boolean -> Boolean
25 nUll :: List alpha -> Boolean
30 idl :: List a -> List a
33 Cons y ys -> Cons y (idl ys)
35 add :: Nat -> Nat -> Nat
38 Succ c -> Succ (add c b)
40 app :: List alpha -> List alpha -> List alpha
41 app xs zs = case xs of
43 Cons y ys -> Cons y (app ys zs)
45 lEngth :: List a -> Nat
46 lEngth xs = case xs of
48 Cons y ys -> Succ(lEngth ys)
50 before :: List Nat -> List Nat
51 before xs = case xs of
53 Cons y ys -> case y of
55 Succ n -> Cons y (before ys)
57 rEverse :: List alpha -> List alpha
58 rEverse rs = case rs of
60 Cons y ys -> app (rEverse ys) (Cons y Nil)
63 flatten :: Tree alpha -> List alpha
66 Node l r -> app (flatten l) (flatten r)
68 sUm :: Tree Nat -> Nat
71 Node l r -> add (sUm l) (sUm r)