Closed Icelandjack closed 4 years ago
@RyanGlScott I mentioned my motivation in the description, I want to Ap
behaviour via Cayley
, in the end I had to use Representational1
so I couldn't
deriving (Semigroup, Monoid)
via f `Cayley` OneObject a `Endo` '()
but it works standalone (basically I create a category from a monoid, I lift it with Applicative
, and apply it to dummy arguments with a generalized Endo
)
deriving
via Endo (Cayley f (OneObject a)) '()
instance (Representational1 f, Applicative f, Monoid a) => Semigroup (MyAp f a)
deriving
via Endo (Cayley f (OneObject a)) '()
instance (Representational1 f, Applicative f, Monoid a) => Monoid (MyAp f a)
where OneObject
and newtype Endo cat a = Endo (cat a a)
This forces Semigroup
to have a Monoid
constraint. If we were able to subtract methods from a type class we could write something like
type Semigroupoid :: Cat ob -> Constraint
type Semigroupoid cat = Category cat - id
instance Semigroup a => Semigroupoid (OneObject a) where (.) = .. (<>) ..
instance Monoid a => Category (OneObject a) where id = .. mempty ..
instance Semigroupoid cat => Semigroup (Endo cat a) where (<>) = .. (.) ..
instance Category cat => Monoid (Endo cat a) where mempty = .. id ..
I hope we can avoid the ..
s soon, writing instances via
instance Semigroupoid cat => Semigroup (Endo cat a) where
via cat a a
(<>) :: cat a a -> cat a a -> cat a a
(<>) = (.)
Enabled PolyKinds for Cayley, Procompose, Rift, ProfunctorFunctor, Ran, Codensity, Prep, Coprep, Star, Costar, WrappedArrow, Forget are now polykinded.
I also added some kind signatures in comments until we can use
StandaloneKindSignatures
. Let me know and I'll remove it. The reason for this is a polymorphicCayley
, I wanted to defineData.Monoid.Ap
in terms of it.