3 ms·
Higher order functions: f :: ((Num) -> Bool, Num) -> Bool The type of f is not particularly obvious to me; instinctively, it could either be: 1. A functi
by AlexeyMK 15y ago
Higher order functions:
f :: ((Num) -> Bool, Num) -> Bool
The type of f is not particularly obvious to me; instinctively, it could either be:
1. A function that takes (a function from Num to [Bool, Num]) and returns Bool, or
2. A function that takes (a function from Num to Bool) and a Num, and returns a Bool.
Given enough time, I'm going to guess 2, but this makes CoffeeScript's destructing assignment, IE
[a, b] = func()
feel less 'first class'. Is this a serious ambiguity, or just me not having enough experience with precedence in CoffeeScript/functional languages?
- dherman 15y agoNo ambiguity; if you put brackets around it you get a tuple (really, an array of fixed elements), and without brackets, the comma is part of the function signature. If you wanted to express your interpretation #1 you'd write: f :: ((Num) -> [Bool, Num]) -> Bool Dave