{-# LANGUAGE
DeriveGeneric
, DeriveDataTypeable
, DerivingVia
, FlexibleInstances
, GeneralizedNewtypeDeriving
, MultiParamTypeClasses
, ScopedTypeVariables
, StandaloneDeriving
, TypeFamilies
, UndecidableInstances
#-}
module Data.Act
( Act(..)
, transportAction
, Trivial(..)
, Torsor(..)
, anti
, intertwiner
, Finitely(..)
)
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
( Dual(..) )
import GHC.Generics
( Generic, Generic1 )
import Control.DeepSeq
( NFData )
import Data.Finitary
( Finitary(..) )
import Data.Finite
( Finite )
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 to :: a -> b
to from :: b -> a
from actBy :: g -> b -> b
actBy g :: 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 _ = Trivial a -> Trivial a
forall a. a -> a
id
deriving via Any instance Act Any Bool
deriving via All instance Act All Bool
instance Num a => Act ( Sum a ) a where
act :: Sum a -> a -> a
act s :: Sum a
s = (Sum a -> Sum a) -> a -> a
forall a b. Coercible a b => a -> b
coerce ( Sum a -> Sum a -> Sum a
forall s x. Act s x => s -> x -> x
act Sum a
s :: Sum a -> Sum a )
instance Num a => Act ( Product a ) a where
act :: Product a -> a -> a
act s :: Product a
s = (Product a -> Product a) -> a -> a
forall a b. Coercible a b => a -> b
coerce ( Product a -> Product a -> Product a
forall s x. Act s x => s -> x -> x
act Product a
s :: Product a -> Product 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
s1, s2 :: s2
s2 ) ( x1 :: x1
x1, x2 :: 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
s1, s2 :: s2
s2, s3 :: s3
s3 ) ( x1 :: x1
x1, x2 :: x2
x2, x3 :: 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
s1, s2 :: s2
s2, s3 :: s3
s3, s4 :: s4
s4 ) ( x1 :: x1
x1, x2 :: x2
x2, x3 :: x3
x3, x4 :: 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
s1, s2 :: s2
s2, s3 :: s3
s3, s4 :: s4
s4, s5 :: s5
s5 ) ( x1 :: x1
x1, x2 :: x2
x2, x3 :: x3
x3, x4 :: x4
x4, x5 :: 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
s = (f x -> f x) -> Ap f x -> Ap f x
forall a b. Coercible a b => a -> b
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
s ) = ((a -> b) -> a -> b) -> Op b a -> Op b a
forall a b. Coercible a b => a -> b
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
s, t :: t
t ) p :: 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 ( Group g, Act g a ) => Act g ( Endo a ) where
act :: g -> Endo a -> Endo a
act g :: g
g = ((a -> a) -> a -> a) -> Endo a -> Endo a
forall a b. Coercible a b => a -> b
coerce ( (Dual g, g) -> (a -> a) -> a -> a
forall s x. Act s x => s -> x -> x
act ( g -> Dual g
forall g. Group g => g -> Dual g
anti g
g, g
g ) :: ( a -> a ) -> ( a -> a ) )
newtype Finitely a = Finitely { Finitely a -> a
getFinitely :: a }
deriving stock ( Int -> Finitely a -> ShowS
[Finitely a] -> ShowS
Finitely a -> String
(Int -> Finitely a -> ShowS)
-> (Finitely a -> String)
-> ([Finitely a] -> ShowS)
-> Show (Finitely a)
forall a. Show a => Int -> Finitely a -> ShowS
forall a. Show a => [Finitely a] -> ShowS
forall a. Show a => Finitely a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Finitely a] -> ShowS
$cshowList :: forall a. Show a => [Finitely a] -> ShowS
show :: Finitely a -> String
$cshow :: forall a. Show a => Finitely a -> String
showsPrec :: Int -> Finitely a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Finitely a -> ShowS
Show, ReadPrec [Finitely a]
ReadPrec (Finitely a)
Int -> ReadS (Finitely a)
ReadS [Finitely a]
(Int -> ReadS (Finitely a))
-> ReadS [Finitely a]
-> ReadPrec (Finitely a)
-> ReadPrec [Finitely a]
-> Read (Finitely a)
forall a. Read a => ReadPrec [Finitely a]
forall a. Read a => ReadPrec (Finitely a)
forall a. Read a => Int -> ReadS (Finitely a)
forall a. Read a => ReadS [Finitely a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Finitely a]
$creadListPrec :: forall a. Read a => ReadPrec [Finitely a]
readPrec :: ReadPrec (Finitely a)
$creadPrec :: forall a. Read a => ReadPrec (Finitely a)
readList :: ReadS [Finitely a]
$creadList :: forall a. Read a => ReadS [Finitely a]
readsPrec :: Int -> ReadS (Finitely a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Finitely a)
Read, Typeable (Finitely a)
DataType
Constr
Typeable (Finitely a) =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Finitely a -> c (Finitely a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Finitely a))
-> (Finitely a -> Constr)
-> (Finitely a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Finitely a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Finitely a)))
-> ((forall b. Data b => b -> b) -> Finitely a -> Finitely a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Finitely a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Finitely a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a))
-> Data (Finitely a)
Finitely a -> DataType
Finitely a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Finitely a))
(forall b. Data b => b -> b) -> Finitely a -> Finitely a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Finitely a -> c (Finitely a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Finitely a)
forall a. Data a => Typeable (Finitely a)
forall a. Data a => Finitely a -> DataType
forall a. Data a => Finitely a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Finitely a -> Finitely a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Finitely a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Finitely a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Finitely a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Finitely a -> c (Finitely a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Finitely a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Finitely 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) -> Finitely a -> u
forall u. (forall d. Data d => d -> u) -> Finitely a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Finitely a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Finitely a -> c (Finitely a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Finitely a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Finitely a))
$cFinitely :: Constr
$tFinitely :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
gmapMp :: (forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
gmapM :: (forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Finitely a -> m (Finitely a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Finitely a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Finitely a -> u
gmapQ :: (forall d. Data d => d -> u) -> Finitely a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Finitely a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Finitely a -> r
gmapT :: (forall b. Data b => b -> b) -> Finitely a -> Finitely a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Finitely a -> Finitely a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Finitely a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Finitely a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Finitely a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Finitely a))
dataTypeOf :: Finitely a -> DataType
$cdataTypeOf :: forall a. Data a => Finitely a -> DataType
toConstr :: Finitely a -> Constr
$ctoConstr :: forall a. Data a => Finitely a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Finitely a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Finitely a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Finitely a -> c (Finitely a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Finitely a -> c (Finitely a)
$cp1Data :: forall a. Data a => Typeable (Finitely a)
Data, (forall x. Finitely a -> Rep (Finitely a) x)
-> (forall x. Rep (Finitely a) x -> Finitely a)
-> Generic (Finitely a)
forall x. Rep (Finitely a) x -> Finitely a
forall x. Finitely a -> Rep (Finitely a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Finitely a) x -> Finitely a
forall a x. Finitely a -> Rep (Finitely a) x
$cto :: forall a x. Rep (Finitely a) x -> Finitely a
$cfrom :: forall a x. Finitely a -> Rep (Finitely a) x
Generic, (forall a. Finitely a -> Rep1 Finitely a)
-> (forall a. Rep1 Finitely a -> Finitely a) -> Generic1 Finitely
forall a. Rep1 Finitely a -> Finitely a
forall a. Finitely a -> Rep1 Finitely 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 Finitely a -> Finitely a
$cfrom1 :: forall a. Finitely a -> Rep1 Finitely a
Generic1 )
deriving newtype ( Finitely a -> Finitely a -> Bool
(Finitely a -> Finitely a -> Bool)
-> (Finitely a -> Finitely a -> Bool) -> Eq (Finitely a)
forall a. Eq a => Finitely a -> Finitely a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Finitely a -> Finitely a -> Bool
$c/= :: forall a. Eq a => Finitely a -> Finitely a -> Bool
== :: Finitely a -> Finitely a -> Bool
$c== :: forall a. Eq a => Finitely a -> Finitely a -> Bool
Eq, Eq (Finitely a)
Eq (Finitely a) =>
(Finitely a -> Finitely a -> Ordering)
-> (Finitely a -> Finitely a -> Bool)
-> (Finitely a -> Finitely a -> Bool)
-> (Finitely a -> Finitely a -> Bool)
-> (Finitely a -> Finitely a -> Bool)
-> (Finitely a -> Finitely a -> Finitely a)
-> (Finitely a -> Finitely a -> Finitely a)
-> Ord (Finitely a)
Finitely a -> Finitely a -> Bool
Finitely a -> Finitely a -> Ordering
Finitely a -> Finitely a -> Finitely 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 (Finitely a)
forall a. Ord a => Finitely a -> Finitely a -> Bool
forall a. Ord a => Finitely a -> Finitely a -> Ordering
forall a. Ord a => Finitely a -> Finitely a -> Finitely a
min :: Finitely a -> Finitely a -> Finitely a
$cmin :: forall a. Ord a => Finitely a -> Finitely a -> Finitely a
max :: Finitely a -> Finitely a -> Finitely a
$cmax :: forall a. Ord a => Finitely a -> Finitely a -> Finitely a
>= :: Finitely a -> Finitely a -> Bool
$c>= :: forall a. Ord a => Finitely a -> Finitely a -> Bool
> :: Finitely a -> Finitely a -> Bool
$c> :: forall a. Ord a => Finitely a -> Finitely a -> Bool
<= :: Finitely a -> Finitely a -> Bool
$c<= :: forall a. Ord a => Finitely a -> Finitely a -> Bool
< :: Finitely a -> Finitely a -> Bool
$c< :: forall a. Ord a => Finitely a -> Finitely a -> Bool
compare :: Finitely a -> Finitely a -> Ordering
$ccompare :: forall a. Ord a => Finitely a -> Finitely a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Finitely a)
Ord, Finitely a -> ()
(Finitely a -> ()) -> NFData (Finitely a)
forall a. NFData a => Finitely a -> ()
forall a. (a -> ()) -> NFData a
rnf :: Finitely a -> ()
$crnf :: forall a. NFData a => Finitely a -> ()
NFData )
instance ( Semigroup s, Act s ( Finite n ), Finitary a, n ~ Cardinality a )
=> Act s ( Finitely a ) where
act :: s -> Finitely a -> Finitely a
act s :: s
s = a -> Finitely a
forall a. a -> Finitely a
Finitely (a -> Finitely a) -> (Finitely a -> a) -> Finitely a -> Finitely a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Finite n -> a
forall a. Finitary a => Finite (Cardinality a) -> a
fromFinite (Finite n -> a) -> (Finitely a -> Finite n) -> Finitely a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> Finite n -> Finite n
forall s x. Act s x => s -> x -> x
act s
s (Finite n -> Finite n)
-> (Finitely a -> Finite n) -> Finitely a -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Finite n
forall a. Finitary a => a -> Finite (Cardinality a)
toFinite (a -> Finite n) -> (Finitely a -> a) -> Finitely a -> Finite n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Finitely a -> a
forall a. Finitely a -> a
getFinitely
instance ( Group g, Torsor g ( Finite n ), Finitary a, n ~ Cardinality a )
=> Torsor g ( Finitely a ) where
Finitely x :: a
x --> :: Finitely a -> Finitely a -> g
--> Finitely y :: a
y = a -> Finite (Cardinality a)
forall a. Finitary a => a -> Finite (Cardinality a)
toFinite a
x Finite n -> Finite n -> g
forall g x. Torsor g x => x -> x -> g
--> a -> Finite (Cardinality a)
forall a. Finitary a => a -> Finite (Cardinality a)
toFinite a
y
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 <--
anti :: Group g => g -> Dual g
anti :: g -> Dual g
anti g :: g
g = g -> Dual g
forall a. a -> Dual a
Dual ( g -> g
forall m. Group m => m -> m
invert g
g )
instance Group g => Torsor g g where
h :: g
h <-- :: g -> g -> g
<-- g :: g
g = g
h g -> g -> g
forall s. Semigroup s => s -> s -> s
<> g -> g
forall m. Group m => m -> m
invert g
g
instance Num a => Torsor ( Sum a ) a where
<-- :: a -> a -> Sum a
(<--) = (Sum a -> Sum a -> Sum a) -> a -> a -> Sum a
forall a b. Coercible a b => a -> b
coerce ( Sum a -> Sum a -> Sum a
forall g x. Torsor g x => x -> x -> g
(<--) :: Sum a -> Sum a -> Sum 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
g p :: a -> b
p a :: 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 )