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
Currently, the filter methods on HLists and Coproducts filter elements of a given type only.
Wouldn't it make more sense to have a filtering based on value types - Boolean literals - returned by a Poly? This way it would
look closer to the filter method of standard collections (like map is),
allow more complex filtering (filtering more than one type, or filtering based on value types)
be closer to a filterKeys method that could be added for records and unions - as keys have value types, it doesn't make really sense to filter them only on their types (if it was, only two types of filtering would be allowed then: all-or-nothing, or filtering one or all but one key).
The problem with this new filter is that it would use boolean literal types, and in particular some macro to manipulate these value types. But these macro cannot be called during their own build (the one of the shapeless-core project). So they have to be built separately, in a bootstrap project say. So the new filtering would require a bootstrap project for some macro and definitions that they use.
It would also require renaming the former filter methods to something else, like filterType, so that would break compatibility with former shapeless versions.
So all of this is feasible, but requires big changes. I let you decide whether you think they are worth it. (I think they are as far as I'm concerned :-)
The text was updated successfully, but these errors were encountered:
alexarchambault
changed the title
Boolean literal based filtering
Boolean literal types based filtering
Dec 5, 2014
Currently, the
filter
methods onHList
s andCoproduct
s filter elements of a given type only.Wouldn't it make more sense to have a filtering based on value types - Boolean literals - returned by a
Poly
? This way it wouldfilter
method of standard collections (likemap
is),filterKeys
method that could be added for records and unions - as keys have value types, it doesn't make really sense to filter them only on their types (if it was, only two types of filtering would be allowed then: all-or-nothing, or filtering one or all but one key).For example, it allows to write things like
The problem with this new
filter
is that it would use boolean literal types, and in particular some macro to manipulate these value types. But these macro cannot be called during their own build (the one of theshapeless-core
project). So they have to be built separately, in a bootstrap project say. So the new filtering would require a bootstrap project for some macro and definitions that they use.It would also require renaming the former
filter
methods to something else, likefilterType
, so that would break compatibility with former shapeless versions.I gave a try to all of this here:
https://github.com/alexarchambault/shapeless/tree/refactor/bootstrap (bootstrap project),
https://github.com/alexarchambault/shapeless/tree/refactor/filtertype (renaming the former
filter
tofilterType
), andhttps://github.com/alexarchambault/shapeless/tree/feature/filter (new
filter
method).So all of this is feasible, but requires big changes. I let you decide whether you think they are worth it. (I think they are as far as I'm concerned :-)
The text was updated successfully, but these errors were encountered: