Skip to content

Commit

Permalink
Add Action instances for Sum and Product
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Bärenz committed Dec 12, 2022
1 parent 6ae1f0c commit 6901977
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Data/Monoid/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ instance Action m s => Action (Maybe m) s where
instance Action (Endo a) a where
act = appEndo

instance Num a => Action Integer (Sum a) where
n `act` a = fromInteger n <> a

instance Num a => Action Integer (Product a) where
n `act` a = fromInteger n <> a

instance Fractional a => Action Rational (Sum a) where
n `act` a = Sum (fromRational n) <> a

instance Fractional a => Action Rational (Product a) where
n `act` a = Product (fromRational n) <> a

-- | An action of a group is "free transitive", "regular", or a "torsor"
-- iff it is invertible.
--
Expand Down

0 comments on commit 6901977

Please sign in to comment.