-
Notifications
You must be signed in to change notification settings - Fork 2
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
Generic Functor attempt 1: IcelandJack's categorical functor proposal #46
Conversation
4c81d17
to
829270d
Compare
With some modification we have a working
This lets us be functorial over both parameters of a bifunctor:
Unfortunately
|
f0596f5
to
a41cbb2
Compare
I've fleshed this out quite a bit, we are going to need to come up with a nicer API on top of this machinery but if I can solve a few more issues then I think its going to work for us. We now have working Bifunctors, Profunctors, and Witherable. I had to drop the type Nat :: Cat s -> Cat t -> Cat (s -> t)
data Nat source target f f' where
Nat :: (forall x. target (f x) (f' x)) -> Nat source target f f'
|
efe01f0
to
9dc7284
Compare
type (<->) :: Cat Type
type (<->) = Iso (->)
instance Functor Endo where
type Dom Endo = (<->)
type Cod Endo = (->)
map :: (a <-> b) -> Endo a -> Endo b
map Iso {..} (Endo f) = Endo (fwd . f . bwd)
invmap :: (FunctorOf (<->) (->) f) => (a -> b) -> (b -> a) -> f a -> f b
invmap f g = map (Iso f g) okay we've got examples of 1,2, and 3 param functors with various positions covariant, contravariant, and invariant. The next step is a nicer interface ontop of FunctorOf that is a bit easier to work with. |
8e7f038
to
d731e34
Compare
d731e34
to
6195f1e
Compare
This version is nice cause it collapes `Functor` and `FunctorOf` into one class and it prevents overlapping instances when the same domain and co-domain can yield multiple functors. However, it also has more difficulty with instance resolution and requires more type ascription/application.
456be5d
to
87cf7f9
Compare
@masaeedu I've moved this project into a separate repo: https://github.com/solomon-b/kindly-functors/ |
We need a more generic version of
Functor
that operates at any kind and which allows us to specify the variance of all parameters it is functorial over. This would allow us to merge the Functor/Bifunctor/Trifunctor class hierarchies (and allow for way arbitrary numbers of parameters and variances). It would also help with implementing generic sequencing operations for #45.@Icelandjack has a proposal which is based on work by Ed Kmett. It looks really close to what we need and looks relatively simple compared to other categorical functor implementations out there.
I made this MR to facilitate discussion while we workshop the idea and decide if it will work for us.