Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data W = Constr (A -> W) (B -> C -> W) D W
- foldW :: ((A -> x) -> (B -> C -> x) -> D -> x -> x)
- -> W
- -> x
- foldW f (Constr aw bcw d w) =
- f (a -> foldW f (aw a))
- (b c -> foldW f (bcw b c))
- d
- (foldW f w)
- recW :: ((A - W) -> (A -> x) -> (B -> C -> W) -> (B -> C -> x) -> D -> W -> x -> x)
- -> W
- -> x
- recW f (Constr aw bcw d w) =
- f aw
- (a -> recW f (aw a))
- bcw
- (b c -> recW f (bcw b c))
- d
- w
- (recW f w)
- data N = Zero | Succ N
- foldN :: x -> (x -> x) -> N -> x
- foldN z s Zero = z
- foldN z s (Succ n) = s (foldN z s n)
- recN :: x -> (N -> x -> x) -> N -> x
- recN z s Zero = z
- recN z s (Succ n) = s n (recN z s n)
- recN :: x -> (N -> x -> x) -> N -> x
- recN z s n = snd (foldN (Zero, z) ((m, x) -> (Succ m, s m x)) n)
- recW :: ((A - W) -> (A -> x) -> (B -> C -> W) -> (B -> C -> x) -> D -> W -> x -> x)
- -> W
- -> x
- recW f w =
- snd (foldW
- (awx bcwx d (w', x) ->
- (Constr (a -> fst (awx a)) (b c -> fst (bcwx b c)) d w',
- f (a -> fst (awx a))
- (a -> snd (awx a))
- (b c -> fst (bcwx b c))
- (b c -> snd (bcwx b c))
- d
- w'
- x))
- w)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement