Data.Monoid.Instances.Measured

monoid-subclasses-1.2.5.1: 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 #

``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) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods mempty :: Measured a # mappend :: Measured a -> Measured a -> Measured a # mconcat :: [Measured a] -> Measured a #
StableFactorial a => Semigroup (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods (<>) :: Measured a -> Measured a -> Measured a # sconcat :: NonEmpty (Measured a) -> Measured a # stimes :: Integral b => b -> Measured a -> Measured a #
Data a => Data (Measured a) # |
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) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Measured a) # toConstr :: Measured a -> Constr # dataTypeOf :: Measured a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Measured a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Measured a)) # gmapT :: (forall b. Data b => b -> b) -> Measured a -> Measured a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Measured a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Measured a -> r # gmapQ :: (forall d. Data d => d -> u) -> Measured a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Measured a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Measured a -> m (Measured a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Measured a -> m (Measured a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Measured a -> m (Measured a) #
(FactorialMonoid a, IsString a) => IsString (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods fromString :: String -> Measured a #
Show a => Show (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods showsPrec :: Int -> Measured a -> ShowS # show :: Measured a -> String # showList :: [Measured a] -> ShowS #
Eq a => Eq (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods (==) :: Measured a -> Measured a -> Bool # (/=) :: Measured a -> Measured a -> Bool #
Ord a => Ord (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods compare :: Measured a -> Measured a -> Ordering # (<) :: Measured a -> Measured a -> Bool # (<=) :: Measured a -> Measured a -> Bool # (>) :: Measured a -> Measured a -> Bool # (>=) :: Measured a -> Measured a -> Bool # max :: Measured a -> Measured a -> Measured a # min :: Measured a -> Measured a -> Measured a #
(StableFactorial a, FactorialMonoid a) => FactorialMonoid (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods splitPrimePrefix :: Measured a -> Maybe (Measured a, Measured a) # splitPrimeSuffix :: Measured a -> Maybe (Measured a, Measured a) # inits :: Measured a -> [Measured a] # tails :: Measured a -> [Measured a] # span :: (Measured a -> Bool) -> Measured a -> (Measured a, Measured a) # break :: (Measured a -> Bool) -> Measured a -> (Measured a, Measured a) # split :: (Measured a -> Bool) -> Measured a -> [Measured a] # takeWhile :: (Measured a -> Bool) -> Measured a -> Measured a # dropWhile :: (Measured a -> Bool) -> Measured a -> Measured a # spanMaybe :: s -> (s -> Measured a -> Maybe s) -> Measured a -> (Measured a, Measured a, s) # spanMaybe' :: s -> (s -> Measured a -> Maybe s) -> Measured a -> (Measured a, Measured a, s) # splitAt :: Int -> Measured a -> (Measured a, Measured a) # drop :: Int -> Measured a -> Measured a # take :: Int -> Measured a -> Measured a #
(LeftGCDMonoid a, StableFactorial a) => LeftGCDMonoid (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods commonPrefix :: Measured a -> Measured a -> Measured a # stripCommonPrefix :: Measured a -> Measured a -> (Measured a, Measured a, Measured a) #
(RightGCDMonoid a, StableFactorial a) => RightGCDMonoid (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods commonSuffix :: Measured a -> Measured a -> Measured a # stripCommonSuffix :: Measured a -> Measured a -> (Measured a, Measured a, Measured a) #
(StableFactorial a, Monoid a) => MonoidNull (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods null :: Measured a -> Bool #
(StableFactorial a, Monoid a) => PositiveMonoid (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured
(Eq a, StableFactorial a, TextualMonoid a) => TextualMonoid (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods fromText :: Text -> Measured a # singleton :: Char -> Measured a # splitCharacterPrefix :: Measured a -> Maybe (Char, Measured a) # characterPrefix :: Measured a -> Maybe Char # map :: (Char -> Char) -> Measured a -> Measured a # concatMap :: (Char -> Measured a) -> Measured a -> Measured a # toString :: (Measured a -> String) -> Measured a -> String # toText :: (Measured a -> Text) -> Measured a -> Text # any :: (Char -> Bool) -> Measured a -> Bool # all :: (Char -> Bool) -> Measured a -> Bool # foldl :: (a0 -> Measured a -> a0) -> (a0 -> Char -> a0) -> a0 -> Measured a -> a0 # foldl' :: (a0 -> Measured a -> a0) -> (a0 -> Char -> a0) -> a0 -> Measured a -> a0 # foldr :: (Measured a -> a0 -> a0) -> (Char -> a0 -> a0) -> a0 -> Measured a -> a0 # scanl :: (Char -> Char -> Char) -> Char -> Measured a -> Measured a # scanl1 :: (Char -> Char -> Char) -> Measured a -> Measured a # scanr :: (Char -> Char -> Char) -> Char -> Measured a -> Measured a # scanr1 :: (Char -> Char -> Char) -> Measured a -> Measured a # mapAccumL :: (a0 -> Char -> (a0, Char)) -> a0 -> Measured a -> (a0, Measured a) # mapAccumR :: (a0 -> Char -> (a0, Char)) -> a0 -> Measured a -> (a0, Measured a) # takeWhile :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> Measured a # dropWhile :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> Measured a # break :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) # span :: (Measured a -> Bool) -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) # spanMaybe :: s -> (s -> Measured a -> Maybe s) -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) # spanMaybe' :: s -> (s -> Measured a -> Maybe s) -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) # split :: (Char -> Bool) -> Measured a -> [Measured a] # find :: (Char -> Bool) -> Measured a -> Maybe Char # elem :: Char -> Measured a -> Bool # foldl_ :: (a0 -> Char -> a0) -> a0 -> Measured a -> a0 # foldl_' :: (a0 -> Char -> a0) -> a0 -> Measured a -> a0 # foldr_ :: (Char -> a0 -> a0) -> a0 -> Measured a -> a0 # takeWhile_ :: Bool -> (Char -> Bool) -> Measured a -> Measured a # dropWhile_ :: Bool -> (Char -> Bool) -> Measured a -> Measured a # break_ :: Bool -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) # span_ :: Bool -> (Char -> Bool) -> Measured a -> (Measured a, Measured a) # spanMaybe_ :: s -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) # spanMaybe_' :: s -> (s -> Char -> Maybe s) -> Measured a -> (Measured a, Measured a, s) #
(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) #
(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 a, MonoidNull a) => Factorial (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured Methods factors :: Measured a -> [Measured a] # primePrefix :: Measured a -> Measured a # primeSuffix :: Measured a -> Measured a # foldl :: (a0 -> Measured a -> a0) -> a0 -> Measured a -> a0 # foldl' :: (a0 -> Measured a -> a0) -> a0 -> Measured a -> a0 # foldr :: (Measured a -> a0 -> a0) -> a0 -> Measured a -> a0 # length :: Measured a -> Int # foldMap :: Monoid n => (Measured a -> n) -> Measured a -> n # reverse :: Measured a -> Measured a #
(StableFactorial a, MonoidNull a) => StableFactorial (Measured a) # |
Instance details Defined in Data.Monoid.Instances.Measured

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

Create a new `Measured` value.

extract :: Measured a -> a #