-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Useful Tuple type matches #9212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Fold prototype: type Fold[Z, F[_, _], T <: Tuple] = T match
case EmptyTuple => Z
case h *: t => F[h, Fold[Z, t]]
type Size[T <: Tuple] = Fold[0, [X, Y] => S[X], T] |
FlatMap prototype : type FlatMap[Tup <: Tuple, F[_]] <: Tuple = Tup match
case EmptyTuple => EmptyTuple
case h *: t => F[h] ++ FlatMap[t, F] |
Not sure how the predicate of a Filter should look like. It could be a type |
Does anyone have other suggestions for the |
That sounds reasonable. How could we filter all the elements of a tuple that have type [X] => X match { case Foo => true case _ => false } ? |
I came up with the following implementation of the |
Uh oh!
There was an error while loading. Please reload this page.
We already have a type match
Tuple.Map
.We could also have:
Tuple.Fold
(Add Tuple match types #9217)Tuple.Filter
(Add Filter type to Tuple #9235)Tuple.FlatMap
(Add Tuple match types #9217)We can take inspiration for the type matches we already have in Tuple. For example
Size
is just a fold.The text was updated successfully, but these errors were encountered: