User loginNavigation 
Function arity with currying and callbypushvalueIn λcalculus, all functions are unary, and nary functions are encoded through currying. But knowing the arity of a function can be useful for optimization — a curried function starts computing only after applying it to at least N arguments, and this N can be useful to know.
Below I explain the details. Applications of arity: But function arity is a tricky concept in λcalculus. For instance, id should be unary, Haskell's ($) is binary, but ($) is defined as equal to id: ($) :: (a > b) > a > b So, a notion of arity seems tricky, and one of my colleague keeps repeating it's a bad idea. Today, while reading a paper using CBPV (Hammer et al. 2014), I got a hunch that the callbypushvalue (CBPV) λcalculus seems to allow for a natural notion of arity. But Googling does not find this spelled out anywhere, maybe because CBPV seems typically used in theoretical contexts. I'm So, why should CBPV help? (1) It distinguishes values (A) and computations (C): Computations are either functions (A > C) which take values and return computations, or base computations F A which wrap values in a "return" expression: C ::= A > C  F A So, the return type of a function is wrapped by the F constructor. In particular, this distinguishes A1 > A2 > F A3 (a binary function) from A1 > F (U (A2 > F A3)), a unary function returning another unary function. (2) Moreover, we also distinguish partial and full applications: since a full application produces a result of type F A, we need to use the elimination form for F. Thus, after conversion to CBPV, we can distinguish syntactically between partial and full applications. Questions: Bibliography: Liu, Y. A., and Teitelbaum, T. Caching intermediate results for program improvement. In Proceedings of the 1995 ACM SIGPLAN symposium on Partial evaluation and semanticsbased program manipulation (New York, NY, USA, 1995), PEPM '95, ACM, pp. 190—201. By Blaisorblade at 20140909 15:27  LtU Forum  previous forum topic  next forum topic  other blogs  5471 reads

Browse archivesActive forum topics 
Recent comments
47 min 43 sec ago
3 hours 36 min ago
5 hours 35 min ago
6 hours 34 min ago
1 day 11 hours ago
1 day 14 hours ago
2 days 16 hours ago
2 days 23 hours ago
3 days 58 min ago
3 days 1 hour ago