Skip to content

Commit

Permalink
Applicative, Alternative instances for Cayley.
Browse files Browse the repository at this point in the history
  • Loading branch information
Icelandjack committed Feb 21, 2024
1 parent cfdad38 commit 07b06ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
6 [unreleased]
--------------
* `Applicative`, `Alternative` instances for `Cayley`
* Removed support for GHC < 8.6
* Inverted dependency between `distributive` v1 and `profunctors` v6
* `Data.Profunctor.Mapping`, `Data.Profunctor.Closed`, `Data.Profunctor.Rep`
Expand Down
16 changes: 13 additions & 3 deletions src/Data/Profunctor/Cayley.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
#if __GLASGOW_HASKELL__ < 900
{-# LANGUAGE DerivingStrategies #-}
#endif
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
Expand All @@ -21,11 +25,13 @@ import Control.Arrow as A
import Control.Category
import Control.Comonad
import Data.Biapplicative
import Data.Bifoldable
import Data.Bifunctor as B
import Data.Bifunctor.Functor
import Data.Bifoldable
import Data.Bitraversable
import Data.Data
import Data.Functor.Compose
import Data.Kind
import Data.Profunctor
import Data.Profunctor.Functor
import Data.Profunctor.Monad
Expand All @@ -45,6 +51,10 @@ newtype Cayley f p a b = Cayley { runCayley :: f (p a b) }
deriving stock instance (Functor f, Functor (p a)) => Functor (Cayley f p a)
deriving stock instance (Foldable f, Foldable (p a)) => Foldable (Cayley f p a)
deriving stock instance (Traversable f, Traversable (p a)) => Traversable (Cayley f p a)
deriving via Compose f (p a :: Type -> Type)
instance (Applicative f, Applicative (p a)) => Applicative (Cayley f p a)
deriving via Compose f (p a :: Type -> Type)
instance (Alternative f, Applicative (p a)) => Alternative (Cayley f p a)

instance Functor f => ProfunctorFunctor (Cayley f) where
promap = \f -> Cayley #. fmap f .# runCayley
Expand Down

0 comments on commit 07b06ee

Please sign in to comment.