serokell/servant-util

Why isn't IsAutoFilter a subclass of Functor?

Closed this issue · 4 comments

IsAutoFilter includes a method mapAutoFilterValue :: (a -> b) -> filter a -> filter b. This method is not documented. Is it expected to obey the functor laws? If so, why not drop it and add a Functor filter superclass? If not, how is it expected to behave?

Yeah, mapAutoFilterValue is mostly fmap and should behave like it.
It's my oversight that this function lacks documentation, gonna fix this after our discussion.

I didn't want to add Functor superclass because I was not sure - maybe filter types will get more type arguments in the future, and fmap could stop working if a became not the last type argument.

@treeowl What do you think?

Why would extra type arguments come after and not before?

I can't come with a sensible example when it would be necessary.

Thinking about it now, probably having extra mapAutoFliterValue is really not worth it, let's replace with Functor superclass.

@treeowl Created #45 for this.