X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FilxGen%2Ftests%2Ftest13.hs;fp=ghc%2Fcompiler%2FilxGen%2Ftests%2Ftest13.hs;h=559c8674fa56df2ee738e82bf0b8ee455868bdd3;hb=81027250abf0099f1dbaef1ddb8534547268ad41;hp=0000000000000000000000000000000000000000;hpb=44637383d831bd3ca8f3aa3cf80e6a0c90986b41;p=ghc-hetmet.git diff --git a/ghc/compiler/ilxGen/tests/test13.hs b/ghc/compiler/ilxGen/tests/test13.hs new file mode 100644 index 0000000..559c867 --- /dev/null +++ b/ghc/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")))