You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ruby 2.7 introduces pattern matching, which could make the API nicer for users. From what I've read, we can support this by implementing #=== and #deconstruct and/or #deconstruct_keys on data types. We have a number of classes like Either, Result, and AbstractCursor that might be good candidates for this. These are abstract classes that imitate algebraic data types.
I would like to be able to hide some constructor parameters though, if for example, they are irrelevant to users or the parameters cannot be easily provided. This may be possible using #deconstruct_keys, though I'm not sure if it's possible to specify the expected class using that syntax. Another option would be to attempt to emulate Haskell's view patterns or Scala's extractor objects.
For now, I won't begin working on this until other changes are completed and released, but it will eventually happen.
The text was updated successfully, but these errors were encountered:
Ruby 2.7 introduces pattern matching, which could make the API nicer for users. From what I've read, we can support this by implementing
#===
and#deconstruct
and/or#deconstruct_keys
on data types. We have a number of classes likeEither
,Result
, andAbstractCursor
that might be good candidates for this. These are abstract classes that imitate algebraic data types.I would like to be able to hide some constructor parameters though, if for example, they are irrelevant to users or the parameters cannot be easily provided. This may be possible using
#deconstruct_keys
, though I'm not sure if it's possible to specify the expected class using that syntax. Another option would be to attempt to emulate Haskell's view patterns or Scala's extractor objects.For now, I won't begin working on this until other changes are completed and released, but it will eventually happen.
The text was updated successfully, but these errors were encountered: