diff options
Diffstat (limited to 'compiler/ilxGen/tests/test13.hs')
-rw-r--r-- | compiler/ilxGen/tests/test13.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/ilxGen/tests/test13.hs b/compiler/ilxGen/tests/test13.hs new file mode 100644 index 0000000000..559c8674fa --- /dev/null +++ b/compiler/ilxGen/tests/test13.hs @@ -0,0 +1,20 @@ +class NewFunctor f where + inj :: a -> f a + surj :: f a -> a + +data N a = Z a + +ninj x = (Z x) +nsurj (Z x) = x + +instance NewFunctor N where + inj = ninj + surj = nsurj + +twice :: NewFunctor f => a -> f (f a) +twice x = inj(inj x) + +undo :: NewFunctor f => f (f a) -> a +undo x = surj(surj x) + +main = putStr (undo (Z (Z "hello world\n"))) |