Let’s make that precise by writing down if’s type: if : Bool -> a -> a -> a ![]() ![]() But if and cond aren’t the same, semantically if takes a boolean and two other arguments and returns one of the latter, while cond is a boolean-albeit evidently a boolean represented as a function. Now instead of if making the decision about which argument to return, we’ve deferred it to cond. This feels strangely like cheating: surely we’ve only moved the problem around. Nevertheless, we will leave this and likely other definitions in their full, η-long forms for the sake of clarity. ![]() Under standard semantics for the lambda calculus, we could simplify this definition further by “ η-reducing” it, noting that λ x. Thus, in the same way that our if_ functions in Haskell
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |