@sig(H/ (H/ "a" >> "b" >> "b") >> "a" >> ["a"] >> "b")
def foldr(f, z, xs):
    """
    foldr :: (a -> b -> b) -> b -> [a] -> b

    foldr, applied to a binary operator, a starting value (typically the
    right-identity of the operator), and a list, reduces the list using the
    binary operator, from right to left
    """
    return ~(caseof(xs)
                | m(L[[]])     >> z
                | m(m.a ^ m.b) >> f(p.a, foldr(f, z, p.b)))
dataset/ETHPy150Open billpmurphy/hask/hask/Data/List.py/foldr/original