summaryrefslogtreecommitdiff
path: root/compiler/ilxGen/tests/test13.hs
blob: 559c8674fa56df2ee738e82bf0b8ee455868bdd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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")))