monoid-subclasses-1.2.6: Subclasses of Monoid

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Monoid.Instances.Measured

Description

This module defines the monoid transformer data type `Measured`.

Synopsis

- data Measured a
- measure :: Factorial a => a -> Measured a
- extract :: Measured a -> a

# Documentation

data Measured a Source #

``Measured` a` is a wrapper around the `FactorialMonoid` `a` that memoizes the monoid's `length` so it becomes a constant-time operation. The parameter is restricted to the `StableFactorial` class, which guarantees that ``length` (a <> b) == `length` a + `length` b`.

#### Instances

Instances details

(StableFactorial a, Monoid a) => Monoid (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods mempty :: Measured a Source # mappend :: Measured a -> Measured a -> Measured a Source # mconcat :: [Measured a] -> Measured a Source #
StableFactorial a => Semigroup (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods (<>) :: Measured a -> Measured a -> Measured a Source # sconcat :: NonEmpty (Measured a) -> Measured a Source # stimes :: Integral b => b -> Measured a -> Measured a Source #
Data a => Data (Measured a) Source # |

Instance details

Defined in Data.Monoid.Instances.Measured

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Measured a -> c (Measured a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Measured a) Source #

toConstr :: Measured a -> Constr Source #

dataTypeOf :: Measured a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Measured a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Measured a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Measured a -> Measured a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Measured a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Measured a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Measured a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Measured a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Measured a -> m (Measured a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Measured a -> m (Measured a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Measured a -> m (Measured a) Source #

(FactorialMonoid a, IsString a) => IsString (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods fromString :: String -> Measured a Source #
Show a => Show (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods showsPrec :: Int -> Measured a -> ShowS Source # show :: Measured a -> String Source # showList :: [Measured a] -> ShowS Source #
Eq a => Eq (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods (==) :: Measured a -> Measured a -> Bool Source # (/=) :: Measured a -> Measured a -> Bool Source #
Ord a => Ord (Measured a) Source # |

Instance details

Defined in Data.Monoid.Instances.Measured

Methods

compare :: Measured a -> Measured a -> Ordering Source #

(<) :: Measured a -> Measured a -> Bool Source #

(<=) :: Measured a -> Measured a -> Bool Source #

(>) :: Measured a -> Measured a -> Bool Source #

(>=) :: Measured a -> Measured a -> Bool Source #

max :: Measured a -> Measured a -> Measured a Source #

min :: Measured a -> Measured a -> Measured a Source #

(StableFactorial a, FactorialMonoid a) => FactorialMonoid (Measured a) Source # |

Instance details

Defined in Data.Monoid.Instances.Measured

Methods

splitPrimePrefix :: Measured a -> Maybe (Measured a, Measured a) Source #

splitPrimeSuffix :: Measured a -> Maybe (Measured a, Measured a) Source #

inits :: Measured a -> [Measured a] Source #

tails :: Measured a -> [Measured a] Source #

span :: (Measured a -> Bool) -> Measured a -> (Measured a, Measured a) Source #

break :: (Measured a -> Bool) -> Measured a -> (Measured a, Measured a) Source #

split :: (Measured a -> Bool) -> Measured a -> [Measured a] Source #

takeWhile :: (Measured a -> Bool) -> Measured a -> Measured a Source #

dropWhile :: (Measured a -> Bool) -> Measured a -> Measured a Source #

spanMaybe :: s -> (s -> Measured a -> Maybe s) -> Measured a -> (Measured a, Measured a, s) Source #

spanMaybe' :: s -> (s -> Measured a -> Maybe s) -> Measured a -> (Measured a, Measured a, s) Source #

splitAt :: Int -> Measured a -> (Measured a, Measured a) Source #

drop :: Int -> Measured a -> Measured a Source #

take :: Int -> Measured a -> Measured a Source #

(LeftGCDMonoid a, StableFactorial a) => LeftGCDMonoid (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods commonPrefix :: Measured a -> Measured a -> Measured a Source # stripCommonPrefix :: Measured a -> Measured a -> (Measured a, Measured a, Measured a) Source #
(RightGCDMonoid a, StableFactorial a) => RightGCDMonoid (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods commonSuffix :: Measured a -> Measured a -> Measured a Source # stripCommonSuffix :: Measured a -> Measured a -> (Measured a, Measured a, Measured a) Source #
(StableFactorial a, Monoid a) => MonoidNull (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods null :: Measured a -> Bool Source #
(StableFactorial a, Monoid a) => PositiveMonoid (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured
(Eq a, StableFactorial a, TextualMonoid a) => TextualMonoid (Measured a) Source # |

Instance details

Defined in Data.Monoid.Instances.Measured

Methods

fromText :: Text -> Measured a Source #

singleton :: Char -> Measured a Source #

splitCharacterPrefix :: Measured a -> Maybe (Char, Measured a) Source #

characterPrefix :: Measured a -> Maybe Char Source #

map :: (Char -> Char) -> Measured a -> Measured a Source #

concatMap :: (Char -> Measured a) -> Measured a -> Measured a Source #

toString :: (Measured a -> String) -> Measured a -> String Source #

toText :: (Measured a -> Text) -> Measured a -> Text Source #

any :: (Char -> Bool) -> Measured a -> Bool Source #

all :: (Char -> Bool) -> Measured a -> Bool Source #

foldl :: (a0 -> Measured a -> a0) -> (a0 -> Char -> a0) -> a0 -> Measured a -> a0 Source #

foldl' :: (a0 -> Measured a -> a0) -> (a0 -> Char -> a0) -> a0 -> Measured a -> a0 Source #

foldr :: (Measured a -> a0 -> a0) -> (Char -> a0 -> a0) -> a0 -> Measured a -> a0 Source #

scanl :: (Char -> Char -> Char) -> Char -> Measured a -> Measured a Source #

scanl1 :: (Char -> Char -> Char) -> Measured a -> Measured a Source #

scanr :: (Char -> Char -> Char) -> Char -> Measured a -> Measured a Source #

scanr1 :: (Char -> Char -> Char) -> Measured a -> Measured a Source #

mapAccumL :: (a0 -> Char -> (a0, Char)) -> a0 -> Measured a -> (a0, Measured a) Source #

mapAccumR :: (a0 -> Char -> (a0, Char)) -> a0 -> Measured a -> (a0, Measured a) Source #

takeWhile :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> Measured a Source #

dropWhile :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> Measured a Source #

break :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) Source #

span :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) Source #

spanMaybe :: s -> (s -> Measured a -> Maybe s) -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) Source #

spanMaybe' :: s -> (s -> Measured a -> Maybe s) -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) Source #

split :: (Char -> Bool) -> Measured a -> [Measured a] Source #

find :: (Char -> Bool) -> Measured a -> Maybe Char Source #

elem :: Char -> Measured a -> Bool Source #

foldl_ :: (a0 -> Char -> a0) -> a0 -> Measured a -> a0 Source #

foldl_' :: (a0 -> Char -> a0) -> a0 -> Measured a -> a0 Source #

foldr_ :: (Char -> a0 -> a0) -> a0 -> Measured a -> a0 Source #

takeWhile_ :: Bool -> (Char -> Bool) -> Measured a -> Measured a Source #

dropWhile_ :: Bool -> (Char -> Bool) -> Measured a -> Measured a Source #

break_ :: Bool -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) Source #

span_ :: Bool -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) Source #

spanMaybe_ :: s -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) Source #

spanMaybe_' :: s -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) Source #

(LeftReductive a, StableFactorial a) => LeftReductive (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods isPrefixOf :: Measured a -> Measured a -> Bool Source # stripPrefix :: Measured a -> Measured a -> Maybe (Measured a) Source #
(RightReductive a, StableFactorial a) => RightReductive (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured Methods isSuffixOf :: Measured a -> Measured a -> Bool Source # stripSuffix :: Measured a -> Measured a -> Maybe (Measured a) Source #
(StableFactorial a, MonoidNull a) => Factorial (Measured a) Source # |

Instance details

Defined in Data.Monoid.Instances.Measured

Methods

factors :: Measured a -> [Measured a] Source #

primePrefix :: Measured a -> Measured a Source #

primeSuffix :: Measured a -> Measured a Source #

foldl :: (a0 -> Measured a -> a0) -> a0 -> Measured a -> a0 Source #

foldl' :: (a0 -> Measured a -> a0) -> a0 -> Measured a -> a0 Source #

foldr :: (Measured a -> a0 -> a0) -> a0 -> Measured a -> a0 Source #

length :: Measured a -> Int Source #

foldMap :: Monoid n => (Measured a -> n) -> Measured a -> n Source #

reverse :: Measured a -> Measured a Source #

(StableFactorial a, MonoidNull a) => StableFactorial (Measured a) Source # |
Instance details Defined in Data.Monoid.Instances.Measured

measure :: Factorial a => a -> Measured a Source #

Create a new `Measured` value.

extract :: Measured a -> a Source #