MatrixAI / Architect

Programming Language for Type Safe Composition of Distributed Infrastructure
Apache License 2.0
1 stars 0 forks source link

Pattern matching #18

Open CMCDragonkai opened 6 years ago

CMCDragonkai commented 6 years ago

Just an issue to discuss pattern matching. Given the difference between hnix and haskell functions.

One thing we can do something where all functions are "anonymous" although they can be bound to names, and names can be within a recursive set. That's how nix works. There's also the use of :, I would prefer to use -> which is more obvious and frees up : to be used for other things (like list deconstruction.

[a, b] -> a + b
(a, b) -> a + b
{a, b} -> a + b
{a, b, ...c) -> a + b
(a: b) -> a + 1

Shall we have \ as a prefix to functions? It would make it easier to parse since we don't have to assume that : is an infix operator compared to Nix: x: x + 1. Although nix makes the left side an equivalent expression. It's just when the : is used, the meanings of the left side data constructors switch from construction to deconstruction.

(Cons a b): a + b

Would mean that Cons is deconstructing.

a: Cons a 1

Would mean that Cons is constructing.

Also like Haskell we would have syntax sugar for multiparmeter functions converted to nested lambdas.