amulet
amulet copied to clipboard
Curried constructors
Instead of passing a tuple or record to constructors, you should be able to create them from multiple fields. This offers several advantages:
- Operator constructors (and thus better pattern matching)
- Easier usage of some constructors (no
let x :: xs = Cons (x, xs)
wrappers), etc...
So one potentially neat thing that CamlP4 does is using and
instead of *
for constructors. So one might have declare lists like so instead:
type list 'a =
| Nil
| (::) of 'a and list 'a
Allows us to distinguish between tuples and curried constructors, while not breaking backwards compat (not that that is exactly a concern).