[Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

Luke Palmer lrpalmer at gmail.com
Fri Dec 7 15:43:56 EST 2007


On Dec 7, 2007 8:39 PM, Dan Weston <westondan at imageworks.com> wrote:
> > compose f g = f . g
> >
> > compose' f g x = f (g x)
> >
> > Are you saying that these two exactly equivalent functions should have
> > different arity?   If not, then is the arity 2 or 3?
>
> Prelude> :t let compose f g = f . g in compose
> let compose f g = f . g in compose :: (b -> c) -> (a -> b) -> a -> c
> Prelude> :t let compose' f g x = f (g x) in compose'
> let compose' f g x = f (g x) in compose' :: (t -> t1) -> (t2 -> t) -> t2
> -> t1
>
> The arity is the number of top-level ->
>
> Both are arity 3.


Hmm, this still seems ill-defined to me.

compose :: (Int -> Int -> Int) -> (Int -> Int) -> Int -> Int -> Int

Is a valid expression given that definition (with a,b = Int and c = Int -> Int),
but now the arity is 4.

Luke


More information about the Haskell-Cafe mailing list