Open vihanb opened 8 years ago
When will where
ever be used?
Also, how would I define pattern matching funcs with more than one arg? Ones that aren't strictly typed? One where the input is strictly typed, but the output not? Vice versa?
@ConorOBrien-Foxx where
will be needed when both sides are a variable, in which case it is unclear which one is the argument name.
@somebody1234 ah, of course.
(draft) This proposal details the workings of the planned
let f ::
pattern matching statementOverview
The pattern matching definition allows behavior to be assigned independently for given instance depending upon the operands.
To avoid ambiguation with
let ... =
, thelet f ::
syntax is taken as an alternative requiring the function to provide a specific type signature outlining at minimum it's I/O.Due to Cheddar's design philosophy to provide freedom, a specific type signature is not enforced and
any -> any
as a generic signature fulfills the I/O requirements for type enforcement.The functional type signatures are targeted to be able to be provided within any type annotation.
Examples
Illustrating the
where
clause when multiple variables are used requiring a statement for disambiguation:Illustrating multiple arguments:
Functional type annotation examples (separate proposal but inlining for sake of completeness):
Illustrating un-proposed generics:
Definition
TODO
Formal Grammar
TODO