mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 16:18:23 +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! |
||
---|---|---|
.. | ||
Codecs | ||
Data | ||
Codecs.enso | ||
Main.enso |