[Haskell-cafe] more functions to evaluate

Derek Elkins derek.a.elkins at gmail.com
Sat Oct 13 17:47:33 EDT 2007


On Fri, 2007-10-12 at 16:20 -0700, Dan Weston wrote:
> I like that name, and will henceforth use it myself until someone sees 
> fit to add it to the Prelude!
> 
> Maxime Henrion wrote:
> > Isaac Dupree wrote:
> >> Dan Weston wrote:
> >>> applyNtimes :: (a -> a) -> Int -> a -> a
> >>>
> >>> This sounds like it should be in the library somewhere
> >> agree, I've used it a few times (mostly for testing things) - modulo 
> >> argument order and Int vs. Integer vs. (Num a => a)
> > 
> > What do you think about calling it iterateN instead?

The type of foldr:
foldr :: (a -> b -> b) -> b -> [a] -> b
Church encoding [a]
[a] = forall b.(a -> b -> b) -> b -> b
Permuting arguments, foldr is one way of an isomorphism between [a] and
it's Church encoding, i.e. \c n -> foldr c n list is the Church encoded
version of list.
Church encoding of Nat
Nat = forall a.(a -> a) -> a -> a
iterateN is foldNat up to permutations of arguments and ignoring
negative values



More information about the Haskell-Cafe mailing list