acts-0.1.0.0: Semigroup actions, groups, and torsors.
Safe HaskellNone
LanguageHaskell2010

Data.Act

Description

An Act of a semigroup \( S \) on a type \( X \) gives a way to transform terms of type \( X \) by terms of type \( S \), in a way that is compatible with the semigroup operation on \( S \).

In the special case that there is a unique way of going from one term of type \( X \) to another through a transformation by a term of type \( S \), we say that \( X \) is a torsor under \( S \).

For example, the plane has an action by translations. Given any two points, there is a unique translation that takes the first point to the second. Note that an unmarked plane (like a blank piece of paper) has no designated origin or reference point, whereas the set of translations is a plane with a given origin (the zero translation). This is the distinction between an affine space (an unmarked plane) and a vector space. Enforcing this distinction in the types can help to avoid confusing absolute points with translation vectors.

Simple Act and Torsor instances can be derived through self-actions:

> newtype Seconds   = Seconds { getSeconds :: Double }
>   deriving ( Act TimeDelta, Torsor TimeDelta )
>     via TimeDelta
> newtype TimeDelta = TimeDelta { timeDeltaInSeconds :: Seconds }
>   deriving ( Semigroup, Monoid, Group )
>     via Sum Double
Synopsis

Documentation

class Semigroup s => Act s x where Source #

A left act (or left semigroup action) of a semigroup s on x consists of an operation

(•) :: s -> x -> x

such that:

a • ( b • x ) = ( a <> b ) • x

In case s is also a Monoid, we additionally require:

mempty • x = x

The synonym act = (•) is also provided.

Minimal complete definition

(•) | act

Methods

(•) :: s -> x -> x infixr 5 Source #

Left action of a semigroup.

act :: s -> x -> x infixr 5 Source #

Left action of a semigroup.

Instances

Instances details
Act () x Source # 
Instance details

Defined in Data.Act

Methods

(•) :: () -> x -> x Source #

act :: () -> x -> x Source #

Semigroup s => Act s s Source #

Natural left action of a semigroup on itself.

Instance details

Defined in Data.Act

Methods

(•) :: s -> s -> s Source #

act :: s -> s -> s Source #

Act All Bool Source # 
Instance details

Defined in Data.Act

Methods

(•) :: All -> Bool -> Bool Source #

act :: All -> Bool -> Bool Source #

Act Any Bool Source # 
Instance details

Defined in Data.Act

Methods

(•) :: Any -> Bool -> Bool Source #

act :: Any -> Bool -> Bool Source #

(Group g, Act g a) => Act g (Endo a) Source #

Action of a group on endomorphisms.

Instance details

Defined in Data.Act

Methods

(•) :: g -> Endo a -> Endo a Source #

act :: g -> Endo a -> Endo a Source #

Semigroup s => Act s (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: s -> Trivial a -> Trivial a Source #

act :: s -> Trivial a -> Trivial a Source #

(Act s x, Functor f) => Act s (Ap f x) Source #

Acting through a functor using fmap.

Instance details

Defined in Data.Act

Methods

(•) :: s -> Ap f x -> Ap f x Source #

act :: s -> Ap f x -> Ap f x Source #

Act s a => Act s (Const a b) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: s -> Const a b -> Const a b Source #

act :: s -> Const a b -> Const a b Source #

Ord a => Act (Min a) a Source # 
Instance details

Defined in Data.Act

Methods

(•) :: Min a -> a -> a Source #

act :: Min a -> a -> a Source #

Ord a => Act (Max a) a Source # 
Instance details

Defined in Data.Act

Methods

(•) :: Max a -> a -> a Source #

act :: Max a -> a -> a Source #

(Act g x, Group g) => Act (Dual g) x Source #

Action of an opposite group using inverses.

Instance details

Defined in Data.Act

Methods

(•) :: Dual g -> x -> x Source #

act :: Dual g -> x -> x Source #

Num a => Act (Sum a) a Source # 
Instance details

Defined in Data.Act

Methods

(•) :: Sum a -> a -> a Source #

act :: Sum a -> a -> a Source #

Num a => Act (Product a) a Source # 
Instance details

Defined in Data.Act

Methods

(•) :: Product a -> a -> a Source #

act :: Product a -> a -> a Source #

KnownNat n => Act (Cyclic n) Int Source # 
Instance details

Defined in Data.Group.Cyclic

Methods

(•) :: Cyclic n -> Int -> Int Source #

act :: Cyclic n -> Int -> Int Source #

Act (Cyclic 2) Bool Source # 
Instance details

Defined in Data.Group.Cyclic

Methods

(•) :: Cyclic 2 -> Bool -> Bool Source #

act :: Cyclic 2 -> Bool -> Bool Source #

(Enum a, Bounded a, KnownNat n) => Act (Cyclic n) (CyclicEnum a) Source # 
Instance details

Defined in Data.Group.Cyclic

Num a => Act (Cyclic 2) (Complex a) Source # 
Instance details

Defined in Data.Group.Cyclic

Methods

(•) :: Cyclic 2 -> Complex a -> Complex a Source #

act :: Cyclic 2 -> Complex a -> Complex a Source #

Num i => Act (Cyclic 2) (Sum i) Source # 
Instance details

Defined in Data.Group.Cyclic

Methods

(•) :: Cyclic 2 -> Sum i -> Sum i Source #

act :: Cyclic 2 -> Sum i -> Sum i Source #

Fractional i => Act (Cyclic 2) (Product i) Source # 
Instance details

Defined in Data.Group.Cyclic

Methods

(•) :: Cyclic 2 -> Product i -> Product i Source #

act :: Cyclic 2 -> Product i -> Product i Source #

(Semigroup s, Act s a) => Act (Dual s) (Op b a) Source #

Acting through the contravariant function arrow functor.

Instance details

Defined in Data.Act

Methods

(•) :: Dual s -> Op b a -> Op b a Source #

act :: Dual s -> Op b a -> Op b a Source #

(Act s1 x1, Act s2 x2) => Act (s1, s2) (x1, x2) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: (s1, s2) -> (x1, x2) -> (x1, x2) Source #

act :: (s1, s2) -> (x1, x2) -> (x1, x2) Source #

(Semigroup s, Act s a, Act t b) => Act (Dual s, t) (a -> b) Source #

Acting through a function arrow: both covariant and contravariant actions.

Instance details

Defined in Data.Act

Methods

(•) :: (Dual s, t) -> (a -> b) -> a -> b Source #

act :: (Dual s, t) -> (a -> b) -> a -> b Source #

(Act s1 x1, Act s2 x2, Act s3 x3) => Act (s1, s2, s3) (x1, x2, x3) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: (s1, s2, s3) -> (x1, x2, x3) -> (x1, x2, x3) Source #

act :: (s1, s2, s3) -> (x1, x2, x3) -> (x1, x2, x3) Source #

(Act s1 x1, Act s2 x2, Act s3 x3, Act s4 x4) => Act (s1, s2, s3, s4) (x1, x2, x3, x4) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: (s1, s2, s3, s4) -> (x1, x2, x3, x4) -> (x1, x2, x3, x4) Source #

act :: (s1, s2, s3, s4) -> (x1, x2, x3, x4) -> (x1, x2, x3, x4) Source #

(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) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: (s1, s2, s3, s4, s5) -> (x1, x2, x3, x4, x5) -> (x1, x2, x3, x4, x5) Source #

act :: (s1, s2, s3, s4, s5) -> (x1, x2, x3, x4, x5) -> (x1, x2, x3, x4, x5) Source #

transportAction :: (a -> b) -> (b -> a) -> (g -> b -> b) -> g -> a -> a Source #

Transport an act:

newtype Trivial a Source #

Trivial act of a semigroup on any type (acting by the identity).

Constructors

Trivial 

Fields

Instances

Instances details
Semigroup s => Act s (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

(•) :: s -> Trivial a -> Trivial a Source #

act :: s -> Trivial a -> Trivial a Source #

Bounded a => Bounded (Trivial a) Source # 
Instance details

Defined in Data.Act

Enum a => Enum (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

succ :: Trivial a -> Trivial a #

pred :: Trivial a -> Trivial a #

toEnum :: Int -> Trivial a #

fromEnum :: Trivial a -> Int #

enumFrom :: Trivial a -> [Trivial a] #

enumFromThen :: Trivial a -> Trivial a -> [Trivial a] #

enumFromTo :: Trivial a -> Trivial a -> [Trivial a] #

enumFromThenTo :: Trivial a -> Trivial a -> Trivial a -> [Trivial a] #

Eq a => Eq (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

(==) :: Trivial a -> Trivial a -> Bool #

(/=) :: Trivial a -> Trivial a -> Bool #

Data a => Data (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Trivial a -> c (Trivial a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Trivial a) #

toConstr :: Trivial a -> Constr #

dataTypeOf :: Trivial a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Trivial a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Trivial a)) #

gmapT :: (forall b. Data b => b -> b) -> Trivial a -> Trivial a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Trivial a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Trivial a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Trivial a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Trivial a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Trivial a -> m (Trivial a) #

Ord a => Ord (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

compare :: 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 #

max :: Trivial a -> Trivial a -> Trivial a #

min :: Trivial a -> Trivial a -> Trivial a #

Read a => Read (Trivial a) Source # 
Instance details

Defined in Data.Act

Show a => Show (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

showsPrec :: Int -> Trivial a -> ShowS #

show :: Trivial a -> String #

showList :: [Trivial a] -> ShowS #

Generic (Trivial a) Source # 
Instance details

Defined in Data.Act

Associated Types

type Rep (Trivial a) :: Type -> Type #

Methods

from :: Trivial a -> Rep (Trivial a) x #

to :: Rep (Trivial a) x -> Trivial a #

NFData a => NFData (Trivial a) Source # 
Instance details

Defined in Data.Act

Methods

rnf :: Trivial a -> () #

Generic1 Trivial Source # 
Instance details

Defined in Data.Act

Associated Types

type Rep1 Trivial :: k -> Type #

Methods

from1 :: forall (a :: k). Trivial a -> Rep1 Trivial a #

to1 :: forall (a :: k). Rep1 Trivial a -> Trivial a #

type Rep (Trivial a) Source # 
Instance details

Defined in Data.Act

type Rep (Trivial a) = D1 ('MetaData "Trivial" "Data.Act" "acts-0.1.0.0-inplace" 'True) (C1 ('MetaCons "Trivial" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTrivial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type Rep1 Trivial Source # 
Instance details

Defined in Data.Act

type Rep1 Trivial = D1 ('MetaData "Trivial" "Data.Act" "acts-0.1.0.0-inplace" 'True) (C1 ('MetaCons "Trivial" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTrivial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

class (Group g, Act g x) => Torsor g x where Source #

A left torsor consists of a free and transitive left action of a group on an inhabited type.

This precisely means that for any two terms x, y, there exists a unique group element g taking x to y, which is denoted y <-- x (or x --> y , but the left-pointing arrow is more natural when working with left actions).

That is y <-- x is the unique element satisfying:

( y <-- x ) • x = y

Note the order of composition of <-- and --> with respect to <>:

( z <-- y ) <> ( y <-- x ) = z <-- x
( y --> z ) <> ( x --> y ) = x --> z

Minimal complete definition

(-->) | (<--)

Methods

(<--) :: x -> x -> g infix 7 Source #

Unique group element effecting the given transition

(-->) :: x -> x -> g infix 7 Source #

Unique group element effecting the given transition

Instances

Instances details
Group g => Torsor g g Source #

Any group is a torsor under its own natural left action.

Instance details

Defined in Data.Act

Methods

(<--) :: g -> g -> g Source #

(-->) :: g -> g -> g Source #

Num a => Torsor (Sum a) a Source # 
Instance details

Defined in Data.Act

Methods

(<--) :: a -> a -> Sum a Source #

(-->) :: a -> a -> Sum a Source #

(Enum a, Bounded a, KnownNat n, 1 <= n) => Torsor (Cyclic n) (CyclicEnum a) Source # 
Instance details

Defined in Data.Group.Cyclic

intertwiner :: forall h g a b. (Act g a, Torsor h b) => g -> (a -> b) -> a -> h Source #

Given

  • \( g \in G \) acting on \( A \),
  • \( B \) a torsor under \( H \),
  • a map \( p \colon A \to B \),

this function returns the unique element \( h \in H \) making the following diagram commute: