Well (^) is already used for their traditional meaning and using this exact operator would require

  1. Shadowing (^) from prelude
  2. Making (a -> a) an instance of Num (impossible to do sanely)

You can just use a different operator

    f .^. n = foldl (.) id $ replicate n f

    main = print . (+1) .^. 5 $ 1

Will print 6


Cheers,
Danny Gratzer


On Tue, Dec 10, 2013 at 10:45 AM, Doug McIlroy <doug@cs.dartmouth.edu> wrote:
Is there a trick whereby the customary notation f^n for iterated
functional composition ((\n f -> foldl (.) id (replicate n f)) n f) can
be defined in Haskell?

Doug McIlroy
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe