[Haskell-cafe] Re: Function composition
Stuart Cook
scook0 at gmail.com
Thu Oct 4 03:57:26 EDT 2007
On 10/4/07, Dominic Steinitz <dominic.steinitz at blueyonder.co.uk> wrote:
> Look at the type of (.).(.).(.)
Indeed, this generalizes to functions of any arity on the "RHS":
Prelude> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
Prelude> :t (.).(.)
(.).(.) :: (b -> c) -> (a -> a1 -> b) -> a -> a1 -> c
Prelude> :t (.).(.).(.)
(.).(.).(.) :: (b -> c) -> (a -> a1 -> a2 -> b) -> a -> a1 -> a2 -> c
Prelude> :t (.).(.).(.).(.)
(.).(.).(.).(.) :: (b -> c) -> (a -> a1 -> a2 -> a3 -> b) -> a -> a1
-> a2 -> a3 -> c
Of course, if you want higher-arity functions anywhere *other* than
the head of your composition chain, you'll have to resort to tupling
and uncurrying.
Stuart
More information about the Haskell-Cafe
mailing list