Data.Monoid.Instances.Measured

monoid-subclasses-0.4.3.1: Subclasses of Monoid

Safe Haskell | Safe
Language | Haskell2010

Data.Monoid.Instances.Measured

Description

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

Synopsis

- data Measured a
- measure :: FactorialMonoid 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 `StableFactorialMonoid` class, which guarantees that ``length` (a <> b) == `length` a + `length` b`.

Instances

Eq a => Eq (Measured a) # |
Methods (==) :: Measured a -> Measured a -> Bool # (/=) :: Measured a -> Measured a -> Bool #
Ord a => Ord (Measured a) # |
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 #
Show a => Show (Measured a) # |
Methods showsPrec :: Int -> Measured a -> ShowS # show :: Measured a -> String # showList :: [Measured a] -> ShowS #
(FactorialMonoid a, IsString a) => IsString (Measured a) # |
Methods fromString :: String -> Measured a #
StableFactorialMonoid a => Monoid (Measured a) # |
Methods mempty :: Measured a # mappend :: Measured a -> Measured a -> Measured a # mconcat :: [Measured a] -> Measured a #
StableFactorialMonoid a => PositiveMonoid (Measured a) # |
StableFactorialMonoid a => MonoidNull (Measured a) # |
Methods null :: Measured a -> Bool #
StableFactorialMonoid a => StableFactorialMonoid (Measured a) # |
StableFactorialMonoid a => FactorialMonoid (Measured a) # |
Methods factors :: Measured a -> [Measured a] # primePrefix :: Measured a -> Measured a # primeSuffix :: Measured a -> Measured a # 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] # foldl :: (a -> Measured a -> a) -> a -> Measured a -> a # foldl' :: (a -> Measured a -> a) -> a -> Measured a -> a # foldr :: (Measured a -> a -> a) -> a -> Measured a -> a # length :: Measured a -> Int # foldMap :: Monoid n => (Measured a -> n) -> Measured a -> n # 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 # reverse :: Measured a -> Measured a #
(RightGCDMonoid a, StableFactorialMonoid a) => RightGCDMonoid (Measured a) # |
Methods commonSuffix :: Measured a -> Measured a -> Measured a # stripCommonSuffix :: Measured a -> Measured a -> (Measured a, Measured a, Measured a) #
(LeftGCDMonoid a, StableFactorialMonoid a) => LeftGCDMonoid (Measured a) # |
Methods commonPrefix :: Measured a -> Measured a -> Measured a # stripCommonPrefix :: Measured a -> Measured a -> (Measured a, Measured a, Measured a) #
(RightReductiveMonoid a, StableFactorialMonoid a) => RightReductiveMonoid (Measured a) # |
Methods isSuffixOf :: Measured a -> Measured a -> Bool # stripSuffix :: Measured a -> Measured a -> Maybe (Measured a) #
(LeftReductiveMonoid a, StableFactorialMonoid a) => LeftReductiveMonoid (Measured a) # |
Methods isPrefixOf :: Measured a -> Measured a -> Bool # stripPrefix :: Measured a -> Measured a -> Maybe (Measured a) #
(Eq a, TextualMonoid a, StableFactorialMonoid a) => TextualMonoid (Measured a) # |
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 # any :: (Char -> Bool) -> Measured a -> Bool # all :: (Char -> Bool) -> Measured a -> Bool # foldl :: (a -> Measured a -> a) -> (a -> Char -> a) -> a -> Measured a -> a # foldl' :: (a -> Measured a -> a) -> (a -> Char -> a) -> a -> Measured a -> a # foldr :: (Measured a -> a -> a) -> (Char -> a -> a) -> a -> Measured a -> a # 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 :: (a -> Char -> (a, Char)) -> a -> Measured a -> (a, Measured a) # mapAccumR :: (a -> Char -> (a, Char)) -> a -> Measured a -> (a, 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_ :: (a -> Char -> a) -> a -> Measured a -> a # foldl_' :: (a -> Char -> a) -> a -> Measured a -> a # foldr_ :: (Char -> a -> a) -> a -> Measured a -> a # 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) #

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

Create a new `Measured` value.

extract :: Measured a -> a #