From 6901977c5ba7f6deb33c68f3eba0c5560f9bebb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Wed, 7 Dec 2022 09:56:53 +0100 Subject: [PATCH] Add Action instances for Sum and Product --- src/Data/Monoid/Action.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Data/Monoid/Action.hs b/src/Data/Monoid/Action.hs index 2603f11..ebbd5bf 100644 --- a/src/Data/Monoid/Action.hs +++ b/src/Data/Monoid/Action.hs @@ -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. --