
On Tue, 5 Oct 2010 03:36:12 -0600, Luke Palmer
On Mon, Oct 4, 2010 at 9:04 PM, Dean Herington
wrote: With respect to "datatype destructing" functions, the Prelude has:
maybe :: b -> (a -> b) -> Maybe a -> b either :: (a -> c) -> (b -> c) -> Either a b -> c
which suggests the following signatures for the analogues for Bool and list types:
bool :: a -> a -> Bool -> a list :: b -> (a -> [a] -> b) -> [a] -> b
This suggestion is not so clear to me. Maybe and Either are both non-recursive, so the Church and Scott encodings coincide. You've written the Scott encoding of list. The Church encoding should look familiar:
list :: b -> (a -> b -> b) -> [a] -> b
I would argue for the previous one (Scott), since we already have this one (this is foldr with another order for arguments). -- Nicolas Pouillard http://nicolaspouillard.fr