[External] : Re: Q on Patterns and Streams

Brian Goetz brian.goetz at oracle.com
Wed Jan 20 15:34:49 UTC 2021



> If I had to guess the future, then I would guess that a pattern, 
> followed by the creation of some product type (record...) could be 
> often desired. But that's just a guess.

Yes, this is a part we're wrestling with.  If there was a 
SAM-conversion-like conversion from a pattern to a T -> Optional<U>, 
then the `mapMaybe` path works great, but this only works for patterns 
that yield one binding.  For patterns that have multiple, an 
intermediate record is required, which is an additional moving part.  
It's possible this could be a synthetic anonymous record, but there's a 
lot of details to work through, and an evaluation of whether the cost is 
justified by the benefit.  To be continued.




More information about the amber-dev mailing list