Why
let ab a b = a 5 + b
will produce
val ab : a:(int -> int) -> b:int -> int
and
let ab2 a b = a 5 +b
will produce
val ab2 : a:(int -> int -> 'a) -> b:int -> 'a
Why this one space between '+' and 'b' makes this difference?
The most effective and challenging assignments focus on questions that lead students to thinking and explaining, rather than simple yes or no answers, whether explicitly part of the assignment description or in the brainstorming heuristics (Gardner, 2005).
An assignment is a piece of (academic) work or task. It provides opportunity for students to learn, practice and demonstrate they have achieved the learning goals. It provides the evidence for the teacher that the students have achieved the goals.
Additionally, grading provides students with feedback on their own learning, clarifying for them what they understand, what they don't understand, and where they can improve. Grading also provides feedback to instructors on their students' learning, information that can inform future teaching decisions.
It is all down to how the parser prioritises different syntactic options to avoid ambiguity.
+
is both the binary addition operator and the unary "positive"1 operator. 5 + b
is thus the application of addition to two arguments; but +b
is the positive operator applied to some symbol b
.
Thus
let ab a b = a 5 + b
is parsed as:
let ab a b = (a 5) + b
with a
being a function of one integer argument returning an int so it can be added to b
; but
let ab2 a b = a 5 +b
is parsed as:
let ab2 a b = a (5) (+b)
with a
being a function of two arguments, with no way to infer the type it returns.
1 I don't have an F# operator list to hand, so can't check the correct name. Edit: it appears I couldn't remember correctly: Arithmetic Operators (F#) :-).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With