groups 0.5.1 → 0.5.2
raw patch · 2 files changed
+31/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Group: generated' :: (Eq a, Cyclic a) => [a]
+ Data.Group: instance Data.Group.Abelian a => Data.Group.Abelian (Data.Ord.Down a)
+ Data.Group: instance Data.Group.Cyclic a => Data.Group.Cyclic (Data.Ord.Down a)
+ Data.Group: instance Data.Group.Group a => Data.Group.Group (Data.Ord.Down a)
Files
- groups.cabal +1/−1
- src/Data/Group.hs +30/−0
groups.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: groups-version: 0.5.1+version: 0.5.2 synopsis: Groups description: A group is a monoid with invertibility.
src/Data/Group.hs view
@@ -6,6 +6,8 @@ module Data.Group where import Data.Monoid+import Data.Ord+import Data.List (unfoldr) #if MIN_VERSION_base(4,7,0) import Data.Proxy #endif@@ -91,6 +93,10 @@ invert (a, b, c, d, e) = (invert a, invert b, invert c, invert d, invert e) pow (a, b, c, d, e) n = (pow a n, pow b n, pow c n, pow d n, pow e n) +#if MIN_VERSION_base(4,11,0)+instance Group a => Group (Down a) where+ invert (Down a) = Down (invert a)+#endif -- |An 'Abelian' group is a 'Group' that follows the rule: --@@ -115,17 +121,36 @@ instance (Abelian a, Abelian b, Abelian c, Abelian d, Abelian e) => Abelian (a, b, c, d, e) +#if MIN_VERSION_base(4,11,0)+instance Abelian a => Abelian (Down a)+#endif -- | A 'Group' G is 'Cyclic' if there exists an element x of G such that for all y in G, there exists an n, such that -- -- @y = pow x n@ class Group a => Cyclic a where+ -- | The generator of the 'Cyclic' group. generator :: a +-- | Generate all elements of a 'Cyclic' group using its 'generator'.+--+-- /Note:/ Fuses, does not terminate even for finite groups.+-- generated :: Cyclic a => [a] generated = iterate (mappend generator) mempty +-- | Lazily generate all elements of a 'Cyclic' group using its 'generator'.+--+-- /Note:/ Fuses, terminates if the underlying group is finite.+--+generated' :: (Eq a, Cyclic a) => [a]+generated' = unfoldr go (generator, 0 :: Integer)+ where+ go (a, n)+ | a == mempty, n > 0 = Nothing+ | otherwise = Just (a, (a <> generator, succ n))+ instance Cyclic () where generator = () @@ -194,4 +219,9 @@ pow (Op f) n = Op (\e -> pow (f e) n) instance Abelian a => Abelian (Op a b)+#endif++#if MIN_VERSION_base(4,11,0)+instance Cyclic a => Cyclic (Down a) where+ generator = Down generator #endif