Open LightAndLight opened 1 year ago
Bump, I expected this today.
bind args <- case args of
[arg1, arg2] ->
...
["-h"] ->
exitWithHelp (None ())
["--help"] ->
exitWithHelp (None ())
_ ->
exitWithHelp (Some "expected 2 arguments, got ${int.toString (array.length args)}")
When I implemented #81 I only implemented a single level of pattern matching:
Supporting nested patterns seems pretty complicated:
A single level of array patterns has a pretty good cost:benefit ratio right now. I'm noting that I might want nested pattern support in the future. The Implementation of Functional Programming Languages[^impl-fp] Chapter 5 has a good general algorithm for un-nesting pattern matches.
[^impl-fp]: Peyton Jones, S. L. (1987). The implementation of functional programming languages (prentice-hall international series in computer science). Prentice-Hall, Inc..