diff options
Diffstat (limited to 'testsuite/tests/stranal/should_compile/ins.hs')
-rw-r--r-- | testsuite/tests/stranal/should_compile/ins.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/should_compile/ins.hs b/testsuite/tests/stranal/should_compile/ins.hs new file mode 100644 index 0000000000..a50320cefa --- /dev/null +++ b/testsuite/tests/stranal/should_compile/ins.hs @@ -0,0 +1,27 @@ +-- !! TEST OF DEFACTORISATION FOR FUNCTIONS THAT DROP +-- !! POLYMORPHIC VARIABLES + +module Test where +data Boolean = FF | TT +data Pair a b = MkPair a b +data LList alpha = Nill | Conss alpha (LList alpha) +data Nat = Zero | Succ Nat +data Tree x = Leaf x | Node (Tree x) (Tree x) +data A a = MkA a (A a) + +append :: LList a -> LList a -> LList a +append xs ys = case xs of + Nill -> ys + Conss z zs -> Conss z (append zs ys) + +-- The following function drops @b@. + +flat :: Tree (Pair a b) -> LList a +flat t = case t of + Leaf (MkPair a b) -> Conss a Nill + Node l r -> append (flat l) (flat r) + +fl :: Boolean -> LList Boolean +fl x = flat (Leaf (MkPair TT Zero)) + + |