I've just noticed F# allows me to use let bindings with literals and other patterns as follows:
let fib 0 = 1
let exists item [] = false
let car (hd :: tl) = hd
let cdr (hd :: tl) = tl
F# correctly interprets these functions as a kind of pattern matching, because gives me the following warnings:
Warning 1 Incomplete pattern matches on this expression. For example, the value '1' will not be matched
Warning 2 Incomplete pattern matches on this expression. For example, the value '[_]' will not be matched
etc.
These functions work as expected, but I want to define a function in this style with complete pattern matches, however I can't find anything about this alternative pattern matching syntax in the F# manual.
I know I can use let whatever = function ...
and let whatever x = match x with ...
to get the results I want, but I've just discovered yet another syntax for pattern matching and it'll nag at me forever if I don't figure out how to use it.
How do I write functions using the alternative pattern matching syntax shown above?