Adapting my previous class sample with these ideas, we have:
class Multicompose t1 t2 t3 | t1 t2 -> t3 where
infixr 9 +.
(+.)::t1 -> t2 -> t3
instance Multicompose t1 t2 t3 => Multicompose t1 (a -> t2) (a -> t3) where
(+.) = (.).(+.)
instance Multicompose (b -> c) (a -> b) (a -> c) where
(+.) = (.)
The only advantage is having the compiler calculate the number of
compositions.
Cheers,
Jorge.
Stuart Cook escreveu:
> On 10/4/07, Dominic Steinitz <[EMAIL PROTECTED]> 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
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
Jorge M. Pelizzoni
ICMC - Universidade de São Paulo
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe