Luke Palmer wrote:
On Dec 7, 2007 7:57 PM, Luke Palmer <[EMAIL PROTECTED]> wrote:
On Dec 7, 2007 7:41 PM, Dan Weston <[EMAIL PROTECTED]> wrote:
Luke Palmer wrote:
You can project the compile time numbers into runtime ones:
Yes, that works well if I know a priori what the arity of the function
is. But I want to be able to have the compiler deduce the arity of the
function (e.g. by applying undefined until it is no longer a function),
precisely so I don't have to supply it myself.
Function arity is (I think) something already known to GHC, so I don't
know why we can't get at it too.
No, it is not. Consider:
compose f g x = f (g x)
What is the arity of f?
Oh, you're saying at run-time, given an object.
No, at compile time. Type is static.
Still no, by some definition.
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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe