data List a = Nil |
list_size Nil = 0 |
data Tree a = Leaf a |
tree_size (Leaf x) = 1 |
polytypic fl :: f a [a] -> [a] (second arg is result now)Where the line above either fl fl really means either flf flg. You can think of instantiation of this polytypic function as involving elaboration of this definition based on the (known) datatype. So:
= case f of
f + g -> either fl fl
f X g -> \(x,y) -> (fl x) ++ (fl y)
() -> \x -> []
Par -> \x -> [x]
Rec -> \x -> x
d @ g -> concat o flatten o pmap fl
Con t -> []