I was using Cayley to derive binary instances for Signal (url)
newtype Signal a b = Signal (Finalizer -> IO (a -> IO b))
deriving
( Profunctor, Strong, Costrong, Choice
, Category, Arrow, ArrowChoice, ArrowLoop, ArrowPlus, ArrowZero
)
via Cayley (Kleisli IO Finalizer) (Kleisli IO)
However to derive Applicative or Alternative, I need to use explicit Compose instead of reusing the same type for unary and binary instances:
deriving (Functor, ..) via Cayley (Kleisli IO Finalizer) (Kleisli IO) a
deriving (Profunctor, ..) via Cayley (Kleisli IO Finalizer) (Kleisli IO)
I think it makes sense to derive the instances for Cayley so I can use Cayley (Kleisli IO Finalizer) (Kleisli IO) a for unary instances as well!
deriving via Compose f (pro a :: Type -> Type)
instance (Functor f, Functor (pro a)) => Functor (Cayley f pro a)
deriving via Compose f (pro a :: Type -> Type)
instance (Applicative f, Applicative (pro a)) => Applicative (Cayley f pro a)
deriving via Compose f (pro a :: Type -> Type)
instance (Alternative f, Applicative (pro a)) => Alternative (Cayley f pro a)
deriving via Compose f (pro a :: Type -> Type)
instance (Foldable f, Foldable (pro a)) => Foldable (Cayley f pro a)
instance (Traversable f, Traversable (pro a)) => Traversable (Cayley f pro a) where
..
The Functor, Foldable, and Traversable instances were added in 4af782eb86f092f8880890facaef8c1880b3c7a2. The only missing ones (AFAICT) are Applicative and Alternative.
I was using
Cayley
to derive binary instances forSignal
(url)However to derive
Applicative
orAlternative
, I need to use explicitCompose
instead of reusing the same type for unary and binary instances:I think it makes sense to derive the instances for
Cayley
so I can useCayley (Kleisli IO Finalizer) (Kleisli IO) a
for unary instances as well!