Copyright | (c) Alice Rixte 2025 |
---|---|
License | BSD 3 |
Maintainer | alice.rixte@u-bordeaux.fr |
Stability | unstable |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Data.Act.Torsor
Description
Presentation
Torsors are sets for which the differences between elements form a group. One good example is time : it does not make sense to add two dates together so we should model these dates as a set (we keep this simple by using only days):
>>>
newtype Days = Days Int
deriving Show
But subtracting two dates together does makes sense. This is where LTorsor can become useful :
newtype Duration = Duration Days deriving Show deriving (Semigroup, Monoid, Group) via Sum Int deriving (LAct Days, LActSg Days, LActMn Days, LTorsor Days) via (ActSelf' (Sum Int))
Now only Duration
can be added or subtracted together and not dates.
>>>
(Days 5 .-. Days 3 :: Duration) + (Days 7 .-. Days 5)
Duration (Days 4)
For a more details and examples see this article
Documentation
class LActGp x g => LTorsor x g where Source #
A left group torsor.
The most well known example of a torsor is the particular case of an affine
space where the group is the additive group of the vector space and the set
is a set of points. Torsors are more general than affine spaces since they
don't enforce linearity. Notice that LActDistrib
may correspond to a
linearity condition if you need one.
See this nLab article for more information : https://ncatlab.org/nlab/show/torsor
- In algebraic terms :
A left group action is a torsor if and only if for every pair (x,y) :: (x,
x)
, there exists a unique group element g :: g
such that g <>$ x = y
.
- In Haskell terms :
Instances must satisfy the following law :
y .-. x <>$ x ==
y
- if
g <>$ x == y
theng == y .-. x
Methods
ldiff :: x -> x -> g infix 6 Source #
ldiff y x
is the only group element such that
.ldiff
y x <>$ x = y
(.-.) :: x -> x -> g infix 6 Source #
Infix synonym for ldiff
.
This represents a point minus a point.
Instances
LTorsor x () Source # | |
Group g => LTorsor g (ActSelf g) Source # | |
LTorsor x g => LTorsor x (Identity g) Source # | |
RTorsor x g => LTorsor x (Dual g) Source # | |
Fractional x => LTorsor x (Product x) Source # | |
Num x => LTorsor x (Sum x) Source # | |
(Group g, Coercible x g) => LTorsor x (ActSelf' g) Source # | |
LTorsor x g => LTorsor (Identity x) (Identity g) Source # | |
(LTorsor x g, LTorsor y h) => LTorsor (x, y) (g, h) Source # | |
class RActGp x g => RTorsor x g where Source #
A right group torsor.
- In algebraic terms :
A left group action is a torsor if and only if for every pair (x,y) :: (x,
x)
, there exists a unique group element g :: g
such that g <>$ x = y
.
- In Haskell terms :
Instances must satisfy the following law :
x $<> y .~. x ==
y
- if
x $<> g == y
theng == y .~. x
Methods
rdiff :: x -> x -> g infix 6 Source #
rdiff y x
is the only group element such that
.rdiff
y x $<> x = y
(.~.) :: x -> x -> g infix 6 Source #
Infix synonym for rdiff
.
This represents a point minus a point.
Instances
RTorsor x () Source # | |
Group g => RTorsor g (ActSelf g) Source # | |
RTorsor x g => RTorsor x (Identity g) Source # | |
LTorsor x g => RTorsor x (Dual g) Source # | |
Fractional x => RTorsor x (Product x) Source # | |
Num x => RTorsor x (Sum x) Source # | |
(Group g, Coercible x g) => RTorsor x (ActSelf' g) Source # | |
RTorsor x g => RTorsor (Identity x) (Identity g) Source # | |
(RTorsor x g, RTorsor y h) => RTorsor (x, y) (g, h) Source # | |