mirror of
https://github.com/enso-org/enso.git
synced 2024-11-27 03:43:20 +03:00
ae66087bb9
This change brings by-type pattern matching to Enso. One can pattern match on Enso types as well as on polyglot types. For example, ``` case x of _ : Integer -> ... _ : Text -> ... _ -> ... ``` as well as Java's types ``` case y of _ : ArrayList -> ... _ : List -> ... _ : AbstractList -> ... _ -> .. ``` It is no longer possible to match a value with a corresponding type constructor. For example ``` case Date.now of Date -> ... ``` will no longer match and one should match on the type (`_ : Date`) instead. ``` case Date of Date -> ... ``` is fine though, as requested in the ticket. The change required further changes to `type_of` logic which wasn't dealing well with polyglot values. Implements https://www.pivotaltracker.com/story/show/183188846 # Important Notes ~I discovered late in the game that nested patterns involving type patterns, such as `Const (f : Foo) tail -> ...` are not possible due to the old parser logic. I would prefer to add it in a separate PR because this one is already getting quite large.~ This is now supported! |
||
---|---|---|
.. | ||
src | ||
package.yaml |