Closed chshersh closed 8 years ago
There's already the invariant
package for this.
@RyanGlScott Oops, didn't find it. This is the fastest issue in my life :D Okay, I guess it can be closed. Sorry for distracting. Thus it was expected. Some math concepts are more likely already written in Haskell than some enterprise package. So you can expect this kind of stuff to be implemented by someone.
It may be useful to have this type class that corresponds to invariant functors:
Obviously most useful instance would be for
Endo a
. BecauseEndo a
can't be neitherFunctor
norContravariant
and even notProfunctor
. But sometimes it is desirable to have some sort of mapping onEndo
. But of course I expect other applications ofInvariant
. Probably it is a good idea to create separateinvariant
package for this purpose. And at current moment I don't expect it to be more than 20 lines or something like that.Careful reader may notice that
invmap
type is very similar toIso
from lens but lifted to some*functor
. And even some laws are true forInvariant
:Maybe this fact can be used somehow or there already exist similar abstraction. But I'm not aware of it.