Ramda's documentation for clamp states:
clamp
Ord a => a → a → a → a
Restricts a number to be within a range.
Also works for other ordered types such as Strings and Dates.
R.clamp(1, 10, -1) // => 1 R.clamp(1, 10, 11) // => 10 R.clamp(1, 10, 4) // => 4
I understand what "a → a → a → a" means (a curried function that takes three arguments of the same type and returns a result of the same type as arguments).
What does "Ord" and fat arrow (=>) mean?
Jared's answer is great. This just adds a little more perspective from the Ramda side.
Ramda has a long article on its type annotations (disclaimer: I wrote it.) The section on type constraints describes these.
The fat arrow implies that the phrases on the left constrain the description on the right. Ord
means that the type is ordered, that is, that it works properly with <
and >
. This includes built-in types such as Strings, Numbers, and Dates, as well as user types with valueOf
methods that give a proper ordering.
Ord
is an ordered datatype. The fat arrow denotes a precondition for the arguments. In this case, I believe it means that the datatype is constrained to types for which things like <
and >
are meaningful (in a strongly-typed language you'd get a compile-time error for anything else).
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