lr-acts: Left and right actions, semidirect products and torsors

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Please see the README on GitHub at https://github.com/AliceRixte/lr-acts/blob/main/README.md


[Skip to Readme]

Properties

Versions 0.0, 0.0, 0.0.1
Change log CHANGELOG.md
Dependencies base (>=4.18 && <5), data-default (>=0.7 && <0.9), groups (>=0.5 && <0.6) [details]
License BSD-3-Clause
Author Alice Rixte
Maintainer alice.rixte@u-bordeaux.fr
Category Algebra, Math, Data
Home page https://github.com/AliceRixte/lr-acts#readme
Bug tracker https://github.com/AliceRixte/lr-acts/issues
Source repo head: git clone https://github.com/AliceRixte/lr-acts
Uploaded by AliceRixte at 2025-05-22T13:29:54Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for lr-acts-0.0

[back to package description]

lr-acts

Haskell Hackage BSD3 License

Features

Fine-grained class hierarchy

Left and right actions with a fine-grained class hierarchy for action properties. For left actions, here are the provided classes :

class LAct               -- Set action
 => LActSg               -- Semigroup action
     => LActMn           -- Monoid action
          => LTorsor     -- Torsor
 => LActDistrib          -- Distributive action
 => LActNeutral          -- Neutral preserving action
 => LActGen              -- Action generated by a set
     => LActCyclic       -- Cyclic action (generated by a single element)

Derive most of you action instances

The acting type is always the second parameter. Use this with DerivingVia language extension to derive action instances :

import Data.Act
import Data.Semigroup

newtype Seconds = Seconds Float
newtype Duration = Duration Seconds
  deriving (Semigroup, Monoid) via (Sum Float)

  deriving (LAct Seconds, RAct Seconds) via (ActSelf' (Sum Float))
  -- derives LAct Second  Duration

  deriving (LAct [Seconds], RAct [Seconds]) via (ActMap (ActSelf' (Sum Float)))
   -- derives LAct [Second] Duration

newtype Durations = Durations [Duration]
  deriving (LAct Seconds, RAct Seconds) via (ActFold [Duration])
  -- derives LAct Second Durations

ghci> Duration 2 `lact` Seconds 3
Seconds 5.0

ghci> Duration 2 `lact` [Seconds 3, Seconds 4]
[Seconds 5.0,Seconds 6.0]

ghci> [Duration 2, Duration 3] `lact` Seconds 4
[Seconds 5.0,Seconds 6.0]

ghci> Durations [Duration 2, Duration 3] `lact` Seconds 4
Seconds 9.0

Semidirect products

This fine-grained hierarchy allows to check for associativity and existence of neutral elements using semidirect products.

>>> import Data.Semigroup
>>> LSemidirect (Sum 1) (Product 2) <> LSemidirect (Sum (3 :: Int)) (Product (4 :: Int))
LSemidirect {lactee = Sum {getSum = 7}, lactor = Product {getProduct = 8}}

GHC will complain when using a semigroup action that is not distributive :

>>> LSemidirect (Sum 1) (Sum 2) <> LSemidirect (Sum (3 :: Int)) (Sum (4 :: Int))
No instance for `LActDistrib (Sum Int) (Sum Int)'
  arising from a use of `<>'

Comparison with other action libraries

Here is a list of action libraries on hackage :

In comparison with these libraries, lr-actsis the only library that :

The main drawback of providing right actions and checking properties for semidirect products is that the number of instances can quickly be overwhelming. It can be a lot of boiler plate to declare them all, especially when the acting semigroup is commutative.