monoid-subclasses-1.2.5.1: Subclasses of Monoid

Safe Haskell | Trustworthy
Language | Haskell2010

Data.Semigroup.Cancellative

Contents

- Symmetric, commutative semigroup classes
- Asymmetric semigroup classes

Description

This module defines the `Semigroup` => `Reductive` => `Cancellative` class hierarchy.

The `Reductive` class introduces operation `</>` which is the inverse of `<>`. For the `Sum` semigroup, this operation is subtraction; for `Product` it is division and for `Set` it's the set difference. A `Reductive` semigroup is not a full group because `</>` may return `Nothing`.

The `Cancellative` subclass does not add any operation but it provides the additional guarantee that `<>` can always be undone with `</>`. Thus `Sum` is `Cancellative` but `Product` is not because `(0*n)/0` is not defined.

All semigroup subclasses listed above are for Abelian, i.e., commutative or symmetric semigroups. Since most practical semigroups in Haskell are not Abelian, each of the these classes has two symmetric superclasses:

- `LeftReductive`
- `LeftCancellative`
- `RightReductive`
- `RightCancellative`

Since: 1.0

Synopsis

- class Semigroup g => Commutative g
- class (Commutative m, LeftReductive m, RightReductive m) => Reductive m where
  - (</>) :: m -> m -> Maybe m
- class (LeftCancellative m, RightCancellative m, Reductive m) => Cancellative m
- class Num a => SumCancellative a where
  - cancelAddition :: a -> a -> Maybe a
- class Semigroup m => LeftReductive m where
  - isPrefixOf :: m -> m -> Bool
  - stripPrefix :: m -> m -> Maybe m
- class Semigroup m => RightReductive m where
  - isSuffixOf :: m -> m -> Bool
  - stripSuffix :: m -> m -> Maybe m
- class LeftReductive m => LeftCancellative m
- class RightReductive m => RightCancellative m

# Symmetric, commutative semigroup classes

class Semigroup g => Commutative g #

A `Commutative` semigroup is a `Semigroup` that follows the rule:

    a <> b == b <> a

#### Instances

Instances details

Commutative IntSet | Since: commutative-semigroups-0.0.2.0
Instance details Defined in Data.Semigroup.Commutative
Commutative Void |
Instance details Defined in Data.Semigroup.Commutative
Commutative All |
Instance details Defined in Data.Semigroup.Commutative
Commutative Any |
Instance details Defined in Data.Semigroup.Commutative
Commutative () | Trivial commutative semigroup.
Instance details Defined in Data.Semigroup.Commutative
Ord a => Commutative (Max a) |
Instance details Defined in Data.Semigroup.Commutative
Ord a => Commutative (Min a) |
Instance details Defined in Data.Semigroup.Commutative
(Commutative a, Monoid a) => Commutative (WrappedMonoid a) |
Instance details Defined in Data.Semigroup.Commutative
Ord a => Commutative (Set a) | Since: commutative-semigroups-0.0.2.0
Instance details Defined in Data.Semigroup.Commutative
Commutative a => Commutative (Identity a) | `Identity` lifts commutative semigroups pointwise (at only one point).
Instance details Defined in Data.Semigroup.Commutative
Commutative a => Commutative (Down a) |
Instance details Defined in Data.Semigroup.Commutative
Commutative a => Commutative (Dual a) |
Instance details Defined in Data.Semigroup.Commutative
CommutativeProduct a => Commutative (Product a) |
Instance details Defined in Data.Semigroup.Commutative
Num a => Commutative (Sum a) |
Instance details Defined in Data.Semigroup.Commutative
Commutative a => Commutative (Maybe a) | Since: commutative-semigroups-0.0.1.0
Instance details Defined in Data.Semigroup.Commutative
Commutative a => Commutative (Op a b) |
Instance details Defined in Data.Semigroup.Commutative
Commutative (Proxy x) | Trivial commutative semigroup, Functor style.
Instance details Defined in Data.Semigroup.Commutative
(Commutative a, Commutative b) => Commutative (a, b) | Product commutative semigroup. A Pair of commutative semigroups gives rise to a commutative semigroup
Instance details Defined in Data.Semigroup.Commutative
Commutative b => Commutative (a -> b) | Functions lift commutative semigroups pointwise.
Instance details Defined in Data.Semigroup.Commutative
Commutative a => Commutative (Const a x) | `Const` lifts commutative semigroups into a functor.
Instance details Defined in Data.Semigroup.Commutative
(Commutative a, Commutative b, Commutative c) => Commutative (a, b, c) |
Instance details Defined in Data.Semigroup.Commutative
(Commutative (f a), Commutative (g a)) => Commutative ((f :*: g) a) | Product of commutative semigroups, Functor style.
Instance details Defined in Data.Semigroup.Commutative
(Commutative a, Commutative b, Commutative c, Commutative d) => Commutative (a, b, c, d) |
Instance details Defined in Data.Semigroup.Commutative
Commutative (f (g a)) => Commutative ((f :.: g) a) |
Instance details Defined in Data.Semigroup.Commutative
(Commutative a, Commutative b, Commutative c, Commutative d, Commutative e) => Commutative (a, b, c, d, e) |
Instance details Defined in Data.Semigroup.Commutative

class (Commutative m, LeftReductive m, RightReductive m) => Reductive m where #

Class of Abelian semigroups with a partial inverse for the Semigroup `<>` operation. The inverse operation `</>` must satisfy the following laws:

    maybe a (b <>) (a </> b) == a
    maybe a (<> b) (a </> b) == a

The `</>` operator is a synonym for both `stripPrefix` and `stripSuffix`, which must be equivalent as `<>` is both associative and commutative.

    (</>) = flip stripPrefix
    (</>) = flip stripSuffix

Methods

(</>) :: m -> m -> Maybe m infix 5 #

#### Instances

Instances details

Reductive IntSet # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: IntSet -> IntSet -> Maybe IntSet #
Reductive All # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: All -> All -> Maybe All #
Reductive Any # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Any -> Any -> Maybe Any #
Reductive () # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: () -> () -> Maybe () #
Ord a => Reductive (Max a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Max a -> Max a -> Maybe (Max a) #
Ord a => Reductive (Min a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Min a -> Min a -> Maybe (Min a) #
Ord a => Reductive (Set a) # | O(m*log(nm + 1)), m <= n/
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Set a -> Set a -> Maybe (Set a) #
Reductive a => Reductive (Identity a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Identity a -> Identity a -> Maybe (Identity a) #
Reductive a => Reductive (Dual a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Dual a -> Dual a -> Maybe (Dual a) #
(CommutativeProduct a, Integral a) => Reductive (Product a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Product a -> Product a -> Maybe (Product a) #
SumCancellative a => Reductive (Sum a) # | O(1)
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Sum a -> Sum a -> Maybe (Sum a) #
Reductive x => Reductive (Maybe x) # | Since: 1.0
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Maybe x -> Maybe x -> Maybe (Maybe x) #
(Reductive a, Reductive b) => Reductive (a, b) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: (a, b) -> (a, b) -> Maybe (a, b) #
Reductive a => Reductive (Const a x) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: Const a x -> Const a x -> Maybe (Const a x) #
(Reductive a, Reductive b, Reductive c) => Reductive (a, b, c) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: (a, b, c) -> (a, b, c) -> Maybe (a, b, c) #
(Reductive a, Reductive b, Reductive c, Reductive d) => Reductive (a, b, c, d) # |
Instance details Defined in Data.Semigroup.Cancellative Methods (</>) :: (a, b, c, d) -> (a, b, c, d) -> Maybe (a, b, c, d) #

class (LeftCancellative m, RightCancellative m, Reductive m) => Cancellative m #

Subclass of `Reductive` where `</>` is a complete inverse of the Semigroup `<>` operation. The class instances must satisfy the following additional laws:

    (a <> b) </> a == Just b
    (a <> b) </> b == Just a

#### Instances

Instances details

Cancellative () # |
Instance details Defined in Data.Semigroup.Cancellative
Cancellative a => Cancellative (Identity a) # |
Instance details Defined in Data.Semigroup.Cancellative
Cancellative a => Cancellative (Dual a) # |
Instance details Defined in Data.Semigroup.Cancellative
SumCancellative a => Cancellative (Sum a) # |
Instance details Defined in Data.Semigroup.Cancellative
(Cancellative a, Cancellative b) => Cancellative (a, b) # |
Instance details Defined in Data.Semigroup.Cancellative
Cancellative a => Cancellative (Const a x) # |
Instance details Defined in Data.Semigroup.Cancellative
(Cancellative a, Cancellative b, Cancellative c) => Cancellative (a, b, c) # |
Instance details Defined in Data.Semigroup.Cancellative
(Cancellative a, Cancellative b, Cancellative c, Cancellative d) => Cancellative (a, b, c, d) # |
Instance details Defined in Data.Semigroup.Cancellative

class Num a => SumCancellative a where #

Helper class to avoid `FlexibleInstances`

Minimal complete definition

Nothing

Methods

cancelAddition :: a -> a -> Maybe a #

#### Instances

Instances details

SumCancellative Rational # |
Instance details Defined in Data.Semigroup.Cancellative Methods cancelAddition :: Rational -> Rational -> Maybe Rational #
SumCancellative Integer # |
Instance details Defined in Data.Semigroup.Cancellative Methods cancelAddition :: Integer -> Integer -> Maybe Integer #
SumCancellative Natural # |
Instance details Defined in Data.Semigroup.Cancellative Methods cancelAddition :: Natural -> Natural -> Maybe Natural #
SumCancellative Int # |
Instance details Defined in Data.Semigroup.Cancellative Methods cancelAddition :: Int -> Int -> Maybe Int #

# Asymmetric semigroup classes

class Semigroup m => LeftReductive m where #

Class of semigroups with a left inverse of `<>`, satisfying the following law:

    isPrefixOf a b == isJust (stripPrefix a b)
    maybe b (a <>) (stripPrefix a b) == b
    a `isPrefixOf` (a <> b)

Every instance definition has to implement at least the `stripPrefix` method.

Minimal complete definition

stripPrefix

Methods

isPrefixOf :: m -> m -> Bool #

stripPrefix :: m -> m -> Maybe m #

#### Instances

Instances details

LeftReductive ByteString # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: ByteString -> ByteString -> Bool # stripPrefix :: ByteString -> ByteString -> Maybe ByteString #
LeftReductive ByteString # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: ByteString -> ByteString -> Bool # stripPrefix :: ByteString -> ByteString -> Maybe ByteString #
LeftReductive IntSet # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: IntSet -> IntSet -> Bool # stripPrefix :: IntSet -> IntSet -> Maybe IntSet #
LeftReductive All # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: All -> All -> Bool # stripPrefix :: All -> All -> Maybe All #
LeftReductive Any # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Any -> Any -> Bool # stripPrefix :: Any -> Any -> Maybe Any #
LeftReductive ByteStringUTF8 # | O(n)
Instance details Defined in Data.Monoid.Instances.ByteString.UTF8 Methods isPrefixOf :: ByteStringUTF8 -> ByteStringUTF8 -> Bool # stripPrefix :: ByteStringUTF8 -> ByteStringUTF8 -> Maybe ByteStringUTF8 #
LeftReductive Text # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Text -> Text -> Bool # stripPrefix :: Text -> Text -> Maybe Text #
LeftReductive Text # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Text -> Text -> Bool # stripPrefix :: Text -> Text -> Maybe Text #
LeftReductive () # | O(1)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: () -> () -> Bool # stripPrefix :: () -> () -> Maybe () #
Ord a => LeftReductive (Max a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Max a -> Max a -> Bool # stripPrefix :: Max a -> Max a -> Maybe (Max a) #
Ord a => LeftReductive (Min a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Min a -> Min a -> Bool # stripPrefix :: Min a -> Min a -> Maybe (Min a) #
Eq a => LeftReductive (IntMap a) # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: IntMap a -> IntMap a -> Bool # stripPrefix :: IntMap a -> IntMap a -> Maybe (IntMap a) #
Eq a => LeftReductive (Seq a) # | O(log(min(m,n−m)) + prefixLength)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Seq a -> Seq a -> Bool # stripPrefix :: Seq a -> Seq a -> Maybe (Seq a) #
Ord a => LeftReductive (Set a) # | O(m*log(nm + 1)), m <= n/
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Set a -> Set a -> Bool # stripPrefix :: Set a -> Set a -> Maybe (Set a) #
LeftReductive a => LeftReductive (Identity a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Identity a -> Identity a -> Bool # stripPrefix :: Identity a -> Identity a -> Maybe (Identity a) #
RightReductive a => LeftReductive (Dual a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Dual a -> Dual a -> Bool # stripPrefix :: Dual a -> Dual a -> Maybe (Dual a) #
(CommutativeProduct a, Integral a) => LeftReductive (Product a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Product a -> Product a -> Bool # stripPrefix :: Product a -> Product a -> Maybe (Product a) #
SumCancellative a => LeftReductive (Sum a) # | O(1)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Sum a -> Sum a -> Bool # stripPrefix :: Sum a -> Sum a -> Maybe (Sum a) #
(LeftReductive a, StableFactorial a, PositiveMonoid a) => LeftReductive (Concat a) # |
Instance details Defined in Data.Monoid.Instances.Concat Methods isPrefixOf :: Concat a -> Concat a -> Bool # stripPrefix :: Concat a -> Concat a -> Maybe (Concat a) #
(LeftReductive a, StableFactorial a) => LeftReductive (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods isPrefixOf :: Measured a -> Measured a -> Bool # stripPrefix :: Measured a -> Measured a -> Maybe (Measured a) #
(StableFactorial m, TextualMonoid m) => LeftReductive (LinePositioned m) # |
Instance details Defined in Data.Monoid.Instances.Positioned Methods isPrefixOf :: LinePositioned m -> LinePositioned m -> Bool # stripPrefix :: LinePositioned m -> LinePositioned m -> Maybe (LinePositioned m) #
(StableFactorial m, LeftReductive m) => LeftReductive (OffsetPositioned m) # |
Instance details Defined in Data.Monoid.Instances.Positioned Methods isPrefixOf :: OffsetPositioned m -> OffsetPositioned m -> Bool # stripPrefix :: OffsetPositioned m -> OffsetPositioned m -> Maybe (OffsetPositioned m) #
(MonoidNull m, StableFactorial m, LeftReductive m) => LeftReductive (Shadowed m) # |
Instance details Defined in Data.Monoid.Instances.PrefixMemory Methods isPrefixOf :: Shadowed m -> Shadowed m -> Bool # stripPrefix :: Shadowed m -> Shadowed m -> Maybe (Shadowed m) #
Eq a => LeftReductive (Vector a) # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Vector a -> Vector a -> Bool # stripPrefix :: Vector a -> Vector a -> Maybe (Vector a) #
LeftReductive x => LeftReductive (Maybe x) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Maybe x -> Maybe x -> Bool # stripPrefix :: Maybe x -> Maybe x -> Maybe (Maybe x) #
Eq x => LeftReductive [x] # | O(prefixLength)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: [x] -> [x] -> Bool # stripPrefix :: [x] -> [x] -> Maybe [x] #
(Ord k, Eq a) => LeftReductive (Map k a) # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Map k a -> Map k a -> Bool # stripPrefix :: Map k a -> Map k a -> Maybe (Map k a) #
(LeftReductive a, LeftReductive b) => LeftReductive (Stateful a b) # |
Instance details Defined in Data.Monoid.Instances.Stateful Methods isPrefixOf :: Stateful a b -> Stateful a b -> Bool # stripPrefix :: Stateful a b -> Stateful a b -> Maybe (Stateful a b) #
(LeftReductive a, LeftReductive b) => LeftReductive (a, b) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: (a, b) -> (a, b) -> Bool # stripPrefix :: (a, b) -> (a, b) -> Maybe (a, b) #
LeftReductive a => LeftReductive (Const a x) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: Const a x -> Const a x -> Bool # stripPrefix :: Const a x -> Const a x -> Maybe (Const a x) #
(LeftReductive a, LeftReductive b, LeftReductive c) => LeftReductive (a, b, c) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: (a, b, c) -> (a, b, c) -> Bool # stripPrefix :: (a, b, c) -> (a, b, c) -> Maybe (a, b, c) #
(LeftReductive a, LeftReductive b, LeftReductive c, LeftReductive d) => LeftReductive (a, b, c, d) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isPrefixOf :: (a, b, c, d) -> (a, b, c, d) -> Bool # stripPrefix :: (a, b, c, d) -> (a, b, c, d) -> Maybe (a, b, c, d) #

class Semigroup m => RightReductive m where #

Class of semigroups with a right inverse of `<>`, satisfying the following law:

    isSuffixOf a b == isJust (stripSuffix a b)
    maybe b (<> a) (stripSuffix a b) == b
    b `isSuffixOf` (a <> b)

Every instance definition has to implement at least the `stripSuffix` method.

Minimal complete definition

stripSuffix

Methods

isSuffixOf :: m -> m -> Bool #

stripSuffix :: m -> m -> Maybe m #

#### Instances

Instances details

RightReductive ByteString # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: ByteString -> ByteString -> Bool # stripSuffix :: ByteString -> ByteString -> Maybe ByteString #
RightReductive ByteString # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: ByteString -> ByteString -> Bool # stripSuffix :: ByteString -> ByteString -> Maybe ByteString #
RightReductive IntSet # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: IntSet -> IntSet -> Bool # stripSuffix :: IntSet -> IntSet -> Maybe IntSet #
RightReductive All # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: All -> All -> Bool # stripSuffix :: All -> All -> Maybe All #
RightReductive Any # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Any -> Any -> Bool # stripSuffix :: Any -> Any -> Maybe Any #
RightReductive Text # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Text -> Text -> Bool # stripSuffix :: Text -> Text -> Maybe Text #
RightReductive Text # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Text -> Text -> Bool # stripSuffix :: Text -> Text -> Maybe Text #
RightReductive () # | O(1)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: () -> () -> Bool # stripSuffix :: () -> () -> Maybe () #
Ord a => RightReductive (Max a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Max a -> Max a -> Bool # stripSuffix :: Max a -> Max a -> Maybe (Max a) #
Ord a => RightReductive (Min a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Min a -> Min a -> Bool # stripSuffix :: Min a -> Min a -> Maybe (Min a) #
Eq a => RightReductive (IntMap a) # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: IntMap a -> IntMap a -> Bool # stripSuffix :: IntMap a -> IntMap a -> Maybe (IntMap a) #
Eq a => RightReductive (Seq a) # | O(log(min(m,n−m)) + suffixLength)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Seq a -> Seq a -> Bool # stripSuffix :: Seq a -> Seq a -> Maybe (Seq a) #
Ord a => RightReductive (Set a) # | O(m*log(nm + 1)), m <= n/
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Set a -> Set a -> Bool # stripSuffix :: Set a -> Set a -> Maybe (Set a) #
RightReductive a => RightReductive (Identity a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Identity a -> Identity a -> Bool # stripSuffix :: Identity a -> Identity a -> Maybe (Identity a) #
LeftReductive a => RightReductive (Dual a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Dual a -> Dual a -> Bool # stripSuffix :: Dual a -> Dual a -> Maybe (Dual a) #
(CommutativeProduct a, Integral a) => RightReductive (Product a) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Product a -> Product a -> Bool # stripSuffix :: Product a -> Product a -> Maybe (Product a) #
SumCancellative a => RightReductive (Sum a) # | O(1)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Sum a -> Sum a -> Bool # stripSuffix :: Sum a -> Sum a -> Maybe (Sum a) #
(RightReductive a, StableFactorial a, PositiveMonoid a) => RightReductive (Concat a) # |
Instance details Defined in Data.Monoid.Instances.Concat Methods isSuffixOf :: Concat a -> Concat a -> Bool # stripSuffix :: Concat a -> Concat a -> Maybe (Concat a) #
(RightReductive a, StableFactorial a) => RightReductive (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods isSuffixOf :: Measured a -> Measured a -> Bool # stripSuffix :: Measured a -> Measured a -> Maybe (Measured a) #
(StableFactorial m, TextualMonoid m, RightReductive m) => RightReductive (LinePositioned m) # |
Instance details Defined in Data.Monoid.Instances.Positioned Methods isSuffixOf :: LinePositioned m -> LinePositioned m -> Bool # stripSuffix :: LinePositioned m -> LinePositioned m -> Maybe (LinePositioned m) #
(StableFactorial m, FactorialMonoid m, RightReductive m) => RightReductive (OffsetPositioned m) # |
Instance details Defined in Data.Monoid.Instances.Positioned Methods isSuffixOf :: OffsetPositioned m -> OffsetPositioned m -> Bool # stripSuffix :: OffsetPositioned m -> OffsetPositioned m -> Maybe (OffsetPositioned m) #
(StableFactorial m, FactorialMonoid m, RightReductive m) => RightReductive (Shadowed m) # |
Instance details Defined in Data.Monoid.Instances.PrefixMemory Methods isSuffixOf :: Shadowed m -> Shadowed m -> Bool # stripSuffix :: Shadowed m -> Shadowed m -> Maybe (Shadowed m) #
Eq a => RightReductive (Vector a) # | O(n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Vector a -> Vector a -> Bool # stripSuffix :: Vector a -> Vector a -> Maybe (Vector a) #
RightReductive x => RightReductive (Maybe x) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Maybe x -> Maybe x -> Bool # stripSuffix :: Maybe x -> Maybe x -> Maybe (Maybe x) #
Eq x => RightReductive [x] # | O(m+n) Since: 1.0
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: [x] -> [x] -> Bool # stripSuffix :: [x] -> [x] -> Maybe [x] #
(Ord k, Eq a) => RightReductive (Map k a) # | O(m+n)
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Map k a -> Map k a -> Bool # stripSuffix :: Map k a -> Map k a -> Maybe (Map k a) #
(RightReductive a, RightReductive b) => RightReductive (Stateful a b) # |
Instance details Defined in Data.Monoid.Instances.Stateful Methods isSuffixOf :: Stateful a b -> Stateful a b -> Bool # stripSuffix :: Stateful a b -> Stateful a b -> Maybe (Stateful a b) #
(RightReductive a, RightReductive b) => RightReductive (a, b) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: (a, b) -> (a, b) -> Bool # stripSuffix :: (a, b) -> (a, b) -> Maybe (a, b) #
RightReductive a => RightReductive (Const a x) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: Const a x -> Const a x -> Bool # stripSuffix :: Const a x -> Const a x -> Maybe (Const a x) #
(RightReductive a, RightReductive b, RightReductive c) => RightReductive (a, b, c) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: (a, b, c) -> (a, b, c) -> Bool # stripSuffix :: (a, b, c) -> (a, b, c) -> Maybe (a, b, c) #
(RightReductive a, RightReductive b, RightReductive c, RightReductive d) => RightReductive (a, b, c, d) # |
Instance details Defined in Data.Semigroup.Cancellative Methods isSuffixOf :: (a, b, c, d) -> (a, b, c, d) -> Bool # stripSuffix :: (a, b, c, d) -> (a, b, c, d) -> Maybe (a, b, c, d) #

class LeftReductive m => LeftCancellative m #

Subclass of `LeftReductive` where `stripPrefix` is a complete inverse of `<>`, satisfying the following additional law:

    stripPrefix a (a <> b) == Just b

#### Instances

Instances details

LeftCancellative ByteString # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative ByteString # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative ByteStringUTF8 # |
Instance details Defined in Data.Monoid.Instances.ByteString.UTF8
LeftCancellative Text # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative Text # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative () # |
Instance details Defined in Data.Semigroup.Cancellative
Eq a => LeftCancellative (Seq a) # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative a => LeftCancellative (Identity a) # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative a => LeftCancellative (Dual a) # |
Instance details Defined in Data.Semigroup.Cancellative
SumCancellative a => LeftCancellative (Sum a) # |
Instance details Defined in Data.Semigroup.Cancellative
Eq a => LeftCancellative (Vector a) # |
Instance details Defined in Data.Semigroup.Cancellative
Eq x => LeftCancellative [x] # |
Instance details Defined in Data.Semigroup.Cancellative
(LeftCancellative a, LeftCancellative b) => LeftCancellative (a, b) # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative a => LeftCancellative (Const a x) # |
Instance details Defined in Data.Semigroup.Cancellative
(LeftCancellative a, LeftCancellative b, LeftCancellative c) => LeftCancellative (a, b, c) # |
Instance details Defined in Data.Semigroup.Cancellative
(LeftCancellative a, LeftCancellative b, LeftCancellative c, LeftCancellative d) => LeftCancellative (a, b, c, d) # |
Instance details Defined in Data.Semigroup.Cancellative

class RightReductive m => RightCancellative m #

Subclass of `LeftReductive` where `stripPrefix` is a complete inverse of `<>`, satisfying the following additional law:

    stripSuffix b (a <> b) == Just a

#### Instances

Instances details

RightCancellative ByteString # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative ByteString # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative Text # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative Text # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative () # |
Instance details Defined in Data.Semigroup.Cancellative
Eq a => RightCancellative (Seq a) # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative a => RightCancellative (Identity a) # |
Instance details Defined in Data.Semigroup.Cancellative
LeftCancellative a => RightCancellative (Dual a) # |
Instance details Defined in Data.Semigroup.Cancellative
SumCancellative a => RightCancellative (Sum a) # |
Instance details Defined in Data.Semigroup.Cancellative
Eq a => RightCancellative (Vector a) # |
Instance details Defined in Data.Semigroup.Cancellative
Eq x => RightCancellative [x] # | Since: 1.0
Instance details Defined in Data.Semigroup.Cancellative
(RightCancellative a, RightCancellative b) => RightCancellative (a, b) # |
Instance details Defined in Data.Semigroup.Cancellative
RightCancellative a => RightCancellative (Const a x) # |
Instance details Defined in Data.Semigroup.Cancellative
(RightCancellative a, RightCancellative b, RightCancellative c) => RightCancellative (a, b, c) # |
Instance details Defined in Data.Semigroup.Cancellative
(RightCancellative a, RightCancellative b, RightCancellative c, RightCancellative d) => RightCancellative (a, b, c, d) # |
Instance details Defined in Data.Semigroup.Cancellative