{-# LANGUAGE
DeriveGeneric
, DeriveDataTypeable
, DerivingVia
, FlexibleContexts
, FlexibleInstances
, GeneralizedNewtypeDeriving
, MultiParamTypeClasses
, ScopedTypeVariables
, StandaloneDeriving
, UndecidableInstances
#-}
module Data.Act
( Act(..)
, transportAction
, Trivial(..)
, Torsor(..)
, intertwiner
)
where
import Data.Coerce
( coerce )
import Data.Data
( Data )
import Data.Functor.Const
( Const(..) )
import Data.Functor.Contravariant
( Op(..) )
import Data.Monoid
( Any(..), All(..)
, Sum(..), Product(..)
, Ap(..), Endo(..)
)
import Data.Semigroup
( Max(..), Min(..), Dual(..) )
import GHC.Generics
( Generic, Generic1 )
import Control.DeepSeq
( NFData )
import Data.Group
( Group(..) )
class Semigroup s => Act s x where
{-# MINIMAL (•) | act #-}
(•), act :: s -> x -> x
(•) = s -> x -> x
forall s x. Act s x => s -> x -> x
act
act = s -> x -> x
forall s x. Act s x => s -> x -> x
(•)
infixr 5 •
infixr 5 `act`
transportAction :: ( a -> b ) -> ( b -> a ) -> ( g -> b -> b ) -> ( g -> a -> a )
transportAction :: (a -> b) -> (b -> a) -> (g -> b -> b) -> g -> a -> a
transportAction a -> b
to b -> a
from g -> b -> b
actBy g
g = b -> a
from (b -> a) -> (a -> b) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g -> b -> b
actBy g
g (b -> b) -> (a -> b) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
to
instance Semigroup s => Act s s where
• :: s -> s -> s
(•) = s -> s -> s
forall s. Semigroup s => s -> s -> s
(<>)
newtype Trivial a = Trivial { Trivial a -> a
getTrivial :: a }
deriving stock ( Int -> Trivial a -> ShowS
[Trivial a] -> ShowS
Trivial a -> String
(Int -> Trivial a -> ShowS)
-> (Trivial a -> String)
-> ([Trivial a] -> ShowS)
-> Show (Trivial a)
forall a. Show a => Int -> Trivial a -> ShowS
forall a. Show a => [Trivial a] -> ShowS
forall a. Show a => Trivial a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Trivial a] -> ShowS
$cshowList :: forall a. Show a => [Trivial a] -> ShowS
show :: Trivial a -> String
$cshow :: forall a. Show a => Trivial a -> String
showsPrec :: Int -> Trivial a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Trivial a -> ShowS
Show, ReadPrec [Trivial a]
ReadPrec (Trivial a)
Int -> ReadS (Trivial a)
ReadS [Trivial a]
(Int -> ReadS (Trivial a))
-> ReadS [Trivial a]
-> ReadPrec (Trivial a)
-> ReadPrec [Trivial a]
-> Read (Trivial a)
forall a. Read a => ReadPrec [Trivial a]
forall a. Read a => ReadPrec (Trivial a)
forall a. Read a => Int -> ReadS (Trivial a)
forall a. Read a => ReadS [Trivial a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Trivial a]
$creadListPrec :: forall a. Read a => ReadPrec [Trivial a]
readPrec :: ReadPrec (Trivial a)
$creadPrec :: forall a. Read a => ReadPrec (Trivial a)
readList :: ReadS [Trivial a]
$creadList :: forall a. Read a => ReadS [Trivial a]
readsPrec :: Int -> ReadS (Trivial a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Trivial a)
Read, Typeable (Trivial a)
DataType
Constr
Typeable (Trivial a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Trivial a -> c (Trivial a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Trivial a))
-> (Trivial a -> Constr)
-> (Trivial a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Trivial a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Trivial a)))
-> ((forall b. Data b => b -> b) -> Trivial a -> Trivial a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Trivial a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Trivial a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a))
-> Data (Trivial a)
Trivial a -> DataType
Trivial a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Trivial a))
(forall b. Data b => b -> b) -> Trivial a -> Trivial a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Trivial a -> c (Trivial a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Trivial a)
forall a. Data a => Typeable (Trivial a)
forall a. Data a => Trivial a -> DataType
forall a. Data a => Trivial a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Trivial a -> Trivial a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Trivial a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Trivial a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Trivial a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Trivial a -> c (Trivial a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Trivial a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Trivial a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Trivial a -> u
forall u. (forall d. Data d => d -> u) -> Trivial a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Trivial a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Trivial a -> c (Trivial a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Trivial a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Trivial a))
$cTrivial :: Constr
$tTrivial :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
gmapMp :: (forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
gmapM :: (forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Trivial a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Trivial a -> u
gmapQ :: (forall d. Data d => d -> u) -> Trivial a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Trivial a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Trivial a -> r
gmapT :: (forall b. Data b => b -> b) -> Trivial a -> Trivial a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Trivial a -> Trivial a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Trivial a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Trivial a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Trivial a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Trivial a))
dataTypeOf :: Trivial a -> DataType
$cdataTypeOf :: forall a. Data a => Trivial a -> DataType
toConstr :: Trivial a -> Constr
$ctoConstr :: forall a. Data a => Trivial a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Trivial a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Trivial a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Trivial a -> c (Trivial a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Trivial a -> c (Trivial a)
$cp1Data :: forall a. Data a => Typeable (Trivial a)
Data, (forall x. Trivial a -> Rep (Trivial a) x)
-> (forall x. Rep (Trivial a) x -> Trivial a)
-> Generic (Trivial a)
forall x. Rep (Trivial a) x -> Trivial a
forall x. Trivial a -> Rep (Trivial a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Trivial a) x -> Trivial a
forall a x. Trivial a -> Rep (Trivial a) x
$cto :: forall a x. Rep (Trivial a) x -> Trivial a
$cfrom :: forall a x. Trivial a -> Rep (Trivial a) x
Generic, (forall a. Trivial a -> Rep1 Trivial a)
-> (forall a. Rep1 Trivial a -> Trivial a) -> Generic1 Trivial
forall a. Rep1 Trivial a -> Trivial a
forall a. Trivial a -> Rep1 Trivial a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 Trivial a -> Trivial a
$cfrom1 :: forall a. Trivial a -> Rep1 Trivial a
Generic1 )
deriving newtype ( Trivial a -> Trivial a -> Bool
(Trivial a -> Trivial a -> Bool)
-> (Trivial a -> Trivial a -> Bool) -> Eq (Trivial a)
forall a. Eq a => Trivial a -> Trivial a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Trivial a -> Trivial a -> Bool
$c/= :: forall a. Eq a => Trivial a -> Trivial a -> Bool
== :: Trivial a -> Trivial a -> Bool
$c== :: forall a. Eq a => Trivial a -> Trivial a -> Bool
Eq, Eq (Trivial a)
Eq (Trivial a)
-> (Trivial a -> Trivial a -> Ordering)
-> (Trivial a -> Trivial a -> Bool)
-> (Trivial a -> Trivial a -> Bool)
-> (Trivial a -> Trivial a -> Bool)
-> (Trivial a -> Trivial a -> Bool)
-> (Trivial a -> Trivial a -> Trivial a)
-> (Trivial a -> Trivial a -> Trivial a)
-> Ord (Trivial a)
Trivial a -> Trivial a -> Bool
Trivial a -> Trivial a -> Ordering
Trivial a -> Trivial a -> Trivial a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Trivial a)
forall a. Ord a => Trivial a -> Trivial a -> Bool
forall a. Ord a => Trivial a -> Trivial a -> Ordering
forall a. Ord a => Trivial a -> Trivial a -> Trivial a
min :: Trivial a -> Trivial a -> Trivial a
$cmin :: forall a. Ord a => Trivial a -> Trivial a -> Trivial a
max :: Trivial a -> Trivial a -> Trivial a
$cmax :: forall a. Ord a => Trivial a -> Trivial a -> Trivial a
>= :: Trivial a -> Trivial a -> Bool
$c>= :: forall a. Ord a => Trivial a -> Trivial a -> Bool
> :: Trivial a -> Trivial a -> Bool
$c> :: forall a. Ord a => Trivial a -> Trivial a -> Bool
<= :: Trivial a -> Trivial a -> Bool
$c<= :: forall a. Ord a => Trivial a -> Trivial a -> Bool
< :: Trivial a -> Trivial a -> Bool
$c< :: forall a. Ord a => Trivial a -> Trivial a -> Bool
compare :: Trivial a -> Trivial a -> Ordering
$ccompare :: forall a. Ord a => Trivial a -> Trivial a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Trivial a)
Ord, Int -> Trivial a
Trivial a -> Int
Trivial a -> [Trivial a]
Trivial a -> Trivial a
Trivial a -> Trivial a -> [Trivial a]
Trivial a -> Trivial a -> Trivial a -> [Trivial a]
(Trivial a -> Trivial a)
-> (Trivial a -> Trivial a)
-> (Int -> Trivial a)
-> (Trivial a -> Int)
-> (Trivial a -> [Trivial a])
-> (Trivial a -> Trivial a -> [Trivial a])
-> (Trivial a -> Trivial a -> [Trivial a])
-> (Trivial a -> Trivial a -> Trivial a -> [Trivial a])
-> Enum (Trivial a)
forall a. Enum a => Int -> Trivial a
forall a. Enum a => Trivial a -> Int
forall a. Enum a => Trivial a -> [Trivial a]
forall a. Enum a => Trivial a -> Trivial a
forall a. Enum a => Trivial a -> Trivial a -> [Trivial a]
forall a.
Enum a =>
Trivial a -> Trivial a -> Trivial a -> [Trivial a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Trivial a -> Trivial a -> Trivial a -> [Trivial a]
$cenumFromThenTo :: forall a.
Enum a =>
Trivial a -> Trivial a -> Trivial a -> [Trivial a]
enumFromTo :: Trivial a -> Trivial a -> [Trivial a]
$cenumFromTo :: forall a. Enum a => Trivial a -> Trivial a -> [Trivial a]
enumFromThen :: Trivial a -> Trivial a -> [Trivial a]
$cenumFromThen :: forall a. Enum a => Trivial a -> Trivial a -> [Trivial a]
enumFrom :: Trivial a -> [Trivial a]
$cenumFrom :: forall a. Enum a => Trivial a -> [Trivial a]
fromEnum :: Trivial a -> Int
$cfromEnum :: forall a. Enum a => Trivial a -> Int
toEnum :: Int -> Trivial a
$ctoEnum :: forall a. Enum a => Int -> Trivial a
pred :: Trivial a -> Trivial a
$cpred :: forall a. Enum a => Trivial a -> Trivial a
succ :: Trivial a -> Trivial a
$csucc :: forall a. Enum a => Trivial a -> Trivial a
Enum, Trivial a
Trivial a -> Trivial a -> Bounded (Trivial a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Trivial a
maxBound :: Trivial a
$cmaxBound :: forall a. Bounded a => Trivial a
minBound :: Trivial a
$cminBound :: forall a. Bounded a => Trivial a
Bounded, Trivial a -> ()
(Trivial a -> ()) -> NFData (Trivial a)
forall a. NFData a => Trivial a -> ()
forall a. (a -> ()) -> NFData a
rnf :: Trivial a -> ()
$crnf :: forall a. NFData a => Trivial a -> ()
NFData )
instance Semigroup s => Act s ( Trivial a ) where
act :: s -> Trivial a -> Trivial a
act s
_ = Trivial a -> Trivial a
forall a. a -> a
id
deriving via Any instance Act Any Bool
deriving via All instance Act All Bool
deriving via ( Sum a ) instance Num a => Act ( Sum a ) a
deriving via ( Product a ) instance Num a => Act ( Product a ) a
deriving via ( Max a ) instance Ord a => Act ( Max a ) a
deriving via ( Min a ) instance Ord a => Act ( Min a ) a
instance {-# OVERLAPPING #-} Act () x where
act :: () -> x -> x
act ()
_ = x -> x
forall a. a -> a
id
instance ( Act s1 x1, Act s2 x2 )
=> Act ( s1, s2 ) ( x1,x2 ) where
act :: (s1, s2) -> (x1, x2) -> (x1, x2)
act ( s1
s1, s2
s2 ) ( x1
x1, x2
x2 ) =
( s1 -> x1 -> x1
forall s x. Act s x => s -> x -> x
act s1
s1 x1
x1, s2 -> x2 -> x2
forall s x. Act s x => s -> x -> x
act s2
s2 x2
x2 )
instance ( Act s1 x1, Act s2 x2, Act s3 x3 )
=> Act ( s1, s2, s3 ) ( x1, x2, x3 ) where
act :: (s1, s2, s3) -> (x1, x2, x3) -> (x1, x2, x3)
act ( s1
s1, s2
s2, s3
s3 ) ( x1
x1, x2
x2, x3
x3 ) =
( s1 -> x1 -> x1
forall s x. Act s x => s -> x -> x
act s1
s1 x1
x1, s2 -> x2 -> x2
forall s x. Act s x => s -> x -> x
act s2
s2 x2
x2, s3 -> x3 -> x3
forall s x. Act s x => s -> x -> x
act s3
s3 x3
x3 )
instance ( Act s1 x1, Act s2 x2, Act s3 x3, Act s4 x4 )
=> Act ( s1, s2, s3, s4 ) ( x1, x2, x3, x4 ) where
act :: (s1, s2, s3, s4) -> (x1, x2, x3, x4) -> (x1, x2, x3, x4)
act ( s1
s1, s2
s2, s3
s3, s4
s4 ) ( x1
x1, x2
x2, x3
x3, x4
x4 ) =
( s1 -> x1 -> x1
forall s x. Act s x => s -> x -> x
act s1
s1 x1
x1, s2 -> x2 -> x2
forall s x. Act s x => s -> x -> x
act s2
s2 x2
x2, s3 -> x3 -> x3
forall s x. Act s x => s -> x -> x
act s3
s3 x3
x3, s4 -> x4 -> x4
forall s x. Act s x => s -> x -> x
act s4
s4 x4
x4 )
instance ( Act s1 x1, Act s2 x2, Act s3 x3, Act s4 x4, Act s5 x5 )
=> Act ( s1, s2, s3, s4, s5 ) ( x1, x2, x3, x4, x5 ) where
act :: (s1, s2, s3, s4, s5)
-> (x1, x2, x3, x4, x5) -> (x1, x2, x3, x4, x5)
act ( s1
s1, s2
s2, s3
s3, s4
s4, s5
s5 ) ( x1
x1, x2
x2, x3
x3, x4
x4, x5
x5 ) =
( s1 -> x1 -> x1
forall s x. Act s x => s -> x -> x
act s1
s1 x1
x1, s2 -> x2 -> x2
forall s x. Act s x => s -> x -> x
act s2
s2 x2
x2, s3 -> x3 -> x3
forall s x. Act s x => s -> x -> x
act s3
s3 x3
x3, s4 -> x4 -> x4
forall s x. Act s x => s -> x -> x
act s4
s4 x4
x4, s5 -> x5 -> x5
forall s x. Act s x => s -> x -> x
act s5
s5 x5
x5 )
deriving newtype instance Act s a => Act s ( Const a b )
instance ( Act s x, Functor f ) => Act s ( Ap f x ) where
act :: s -> Ap f x -> Ap f x
act s
s = (f x -> f x) -> Ap f x -> Ap f x
coerce ( (x -> x) -> f x -> f x
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ( s -> x -> x
forall s x. Act s x => s -> x -> x
act s
s ) :: f x -> f x )
instance ( Semigroup s, Act s a ) => Act ( Dual s ) ( Op b a ) where
act :: Dual s -> Op b a -> Op b a
act ( Dual s
s ) = ((a -> b) -> a -> b) -> Op b a -> Op b a
coerce ( ( (a -> b) -> (a -> a) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> a -> a
forall s x. Act s x => s -> x -> x
act s
s ) :: ( a -> b ) -> ( a -> b ) )
instance ( Semigroup s, Act s a, Act t b ) => Act ( Dual s, t ) ( a -> b ) where
act :: (Dual s, t) -> (a -> b) -> a -> b
act ( Dual s
s, t
t ) a -> b
p = t -> b -> b
forall s x. Act s x => s -> x -> x
act t
t (b -> b) -> (a -> b) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
p (a -> b) -> (a -> a) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> a -> a
forall s x. Act s x => s -> x -> x
act s
s
instance {-# OVERLAPPABLE #-} ( Act g x, Group g ) => Act ( Dual g ) x where
act :: Dual g -> x -> x
act ( Dual g
g ) = g -> x -> x
forall s x. Act s x => s -> x -> x
act ( g -> g
forall g. Group g => g -> g
inverse g
g )
instance ( Group g, Act g a ) => Act g ( Endo a ) where
act :: g -> Endo a -> Endo a
act g
g = ((a -> a) -> a -> a) -> Endo a -> Endo a
coerce ( (Dual g, g) -> (a -> a) -> a -> a
forall s x. Act s x => s -> x -> x
act ( g -> Dual g
forall a. a -> Dual a
Dual g
g, g
g ) :: ( a -> a ) -> ( a -> a ) )
class ( Group g, Act g x ) => Torsor g x where
{-# MINIMAL (-->) | (<--) #-}
(<--), (-->) :: x -> x -> g
(-->) = (x -> x -> g) -> x -> x -> g
forall a b c. (a -> b -> c) -> b -> a -> c
flip x -> x -> g
forall g x. Torsor g x => x -> x -> g
(<--)
(<--) = (x -> x -> g) -> x -> x -> g
forall a b c. (a -> b -> c) -> b -> a -> c
flip x -> x -> g
forall g x. Torsor g x => x -> x -> g
(-->)
infix 7 -->
infix 7 <--
instance Group g => Torsor g g where
g
h <-- :: g -> g -> g
<-- g
g = g
h g -> g -> g
forall s. Semigroup s => s -> s -> s
<> g -> g
forall g. Group g => g -> g
inverse g
g
deriving via ( Sum a ) instance Num a => Torsor ( Sum a ) a
intertwiner :: forall h g a b. ( Act g a, Torsor h b ) => g -> ( a -> b ) -> a -> h
intertwiner :: g -> (a -> b) -> a -> h
intertwiner g
g a -> b
p a
a = a -> b
p a
a b -> b -> h
forall g x. Torsor g x => x -> x -> g
--> a -> b
p ( g
g g -> a -> a
forall s x. Act s x => s -> x -> x
• a
a )