On Mon, Feb 25, 2013 at 3:56 PM, Travis Brown
<
travisro...@gmail.com> wrote:
> I'd have two concerns about rolling this out right away:
>
> Even though that commit on my demo branch doesn't break any tests, it's a
> pretty big change in behavior—it's not inconceivable that someone out there
> is using code that expects filter not to return subtypes of the query type.
> I'm not, and the behavior in my version makes good sense to me, but it isn't
> an insignificant change.
> If we make this change to FilterAux, we'll also need at the very least to
> change FilterNotAux for consistency, and there'd be a strong argument for
> making Remove and Replace and Select match as well. Which makes the
> possibility of breaking other people's code even more of a problem.
Other options:
* We could introduce a new (pair of) method(s) which also filter subtypes.
* We could introduce a single new method which normalizes subtypes to
a common supertype, ie. Foo :: Bar :: String :: HNil => Foo :: Foo ::
String :: HNil, then use the existing Filter/FilterNot on the result
of that.
* We could and come up with a more general idea of type-level
predicate and have a revise filter work in terms of that.
> I do think the second part of my change—ensuring that you can't create
> instances like FilterAux[Foo :: Foo :: HNil, Foo, Foo :: HNil]—could be
> implemented immediately (it could be done independently of the first part by
> using =:!= instead of <:!<). I was actually pretty surprised this morning to
> see that Shapeless would happily pull these things out of the air.
Agreed. Both with the proposal and the surprise.