monoid-subclasses-0.4.6: Subclasses of Monoid

Safe HaskellSafe
LanguageHaskell2010

Data.Monoid.Instances.Stateful

Description

This module defines the monoid transformer data type Stateful.

> let s = setState [4] $ pure "data" :: Stateful [Int] String
> s
Stateful ("data",[4])
> factors s
[Stateful ("d",[]),Stateful ("a",[]),Stateful ("t",[]),Stateful ("a",[]),Stateful ("",[4])]

Synopsis

Documentation

newtype Stateful a b Source #

Stateful a b is a wrapper around the Monoid b that carries the state a along. The state type a must be a monoid as well if Stateful is to be of any use. In the FactorialMonoid and TextualMonoid class instances, the monoid b has the priority and the state a is left for the end.

Constructors

Stateful (b, a) 

Instances

Functor (Stateful a) Source # 

Methods

fmap :: (a -> b) -> Stateful a a -> Stateful a b #

(<$) :: a -> Stateful a b -> Stateful a a #

Monoid a => Applicative (Stateful a) Source # 

Methods

pure :: a -> Stateful a a #

(<*>) :: Stateful a (a -> b) -> Stateful a a -> Stateful a b #

liftA2 :: (a -> b -> c) -> Stateful a a -> Stateful a b -> Stateful a c #

(*>) :: Stateful a a -> Stateful a b -> Stateful a b #

(<*) :: Stateful a a -> Stateful a b -> Stateful a a #

(Eq a, Eq b) => Eq (Stateful a b) Source # 

Methods

(==) :: Stateful a b -> Stateful a b -> Bool #

(/=) :: Stateful a b -> Stateful a b -> Bool #

(Ord a, Ord b) => Ord (Stateful a b) Source # 

Methods

compare :: Stateful a b -> Stateful a b -> Ordering #

(<) :: Stateful a b -> Stateful a b -> Bool #

(<=) :: Stateful a b -> Stateful a b -> Bool #

(>) :: Stateful a b -> Stateful a b -> Bool #

(>=) :: Stateful a b -> Stateful a b -> Bool #

max :: Stateful a b -> Stateful a b -> Stateful a b #

min :: Stateful a b -> Stateful a b -> Stateful a b #

(Show a, Show b) => Show (Stateful a b) Source # 

Methods

showsPrec :: Int -> Stateful a b -> ShowS #

show :: Stateful a b -> String #

showList :: [Stateful a b] -> ShowS #

(Monoid a, IsString b) => IsString (Stateful a b) Source # 

Methods

fromString :: String -> Stateful a b #

(Semigroup a, Semigroup b) => Semigroup (Stateful a b) Source # 

Methods

(<>) :: Stateful a b -> Stateful a b -> Stateful a b #

sconcat :: NonEmpty (Stateful a b) -> Stateful a b #

stimes :: Integral b => b -> Stateful a b -> Stateful a b #

(Monoid a, Monoid b) => Monoid (Stateful a b) Source # 

Methods

mempty :: Stateful a b #

mappend :: Stateful a b -> Stateful a b -> Stateful a b #

mconcat :: [Stateful a b] -> Stateful a b #

(RightGCDMonoid a, RightGCDMonoid b) => RightGCDMonoid (Stateful a b) Source # 

Methods

commonSuffix :: Stateful a b -> Stateful a b -> Stateful a b Source #

stripCommonSuffix :: Stateful a b -> Stateful a b -> (Stateful a b, Stateful a b, Stateful a b) Source #

(LeftGCDMonoid a, LeftGCDMonoid b) => LeftGCDMonoid (Stateful a b) Source # 

Methods

commonPrefix :: Stateful a b -> Stateful a b -> Stateful a b Source #

stripCommonPrefix :: Stateful a b -> Stateful a b -> (Stateful a b, Stateful a b, Stateful a b) Source #

(RightReductiveMonoid a, RightReductiveMonoid b) => RightReductiveMonoid (Stateful a b) Source # 

Methods

isSuffixOf :: Stateful a b -> Stateful a b -> Bool Source #

stripSuffix :: Stateful a b -> Stateful a b -> Maybe (Stateful a b) Source #

(LeftReductiveMonoid a, LeftReductiveMonoid b) => LeftReductiveMonoid (Stateful a b) Source # 

Methods

isPrefixOf :: Stateful a b -> Stateful a b -> Bool Source #

stripPrefix :: Stateful a b -> Stateful a b -> Maybe (Stateful a b) Source #

(PositiveMonoid a, PositiveMonoid b) => PositiveMonoid (Stateful a b) Source # 
(MonoidNull a, MonoidNull b) => MonoidNull (Stateful a b) Source # 

Methods

null :: Stateful a b -> Bool Source #

(StableFactorialMonoid a, StableFactorialMonoid b) => StableFactorialMonoid (Stateful a b) Source # 
(FactorialMonoid a, FactorialMonoid b) => FactorialMonoid (Stateful a b) Source # 

Methods

factors :: Stateful a b -> [Stateful a b] Source #

primePrefix :: Stateful a b -> Stateful a b Source #

primeSuffix :: Stateful a b -> Stateful a b Source #

splitPrimePrefix :: Stateful a b -> Maybe (Stateful a b, Stateful a b) Source #

splitPrimeSuffix :: Stateful a b -> Maybe (Stateful a b, Stateful a b) Source #

inits :: Stateful a b -> [Stateful a b] Source #

tails :: Stateful a b -> [Stateful a b] Source #

foldl :: (a -> Stateful a b -> a) -> a -> Stateful a b -> a Source #

foldl' :: (a -> Stateful a b -> a) -> a -> Stateful a b -> a Source #

foldr :: (Stateful a b -> a -> a) -> a -> Stateful a b -> a Source #

length :: Stateful a b -> Int Source #

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

span :: (Stateful a b -> Bool) -> Stateful a b -> (Stateful a b, Stateful a b) Source #

break :: (Stateful a b -> Bool) -> Stateful a b -> (Stateful a b, Stateful a b) Source #

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

takeWhile :: (Stateful a b -> Bool) -> Stateful a b -> Stateful a b Source #

dropWhile :: (Stateful a b -> Bool) -> Stateful a b -> Stateful a b Source #

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

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

splitAt :: Int -> Stateful a b -> (Stateful a b, Stateful a b) Source #

drop :: Int -> Stateful a b -> Stateful a b Source #

take :: Int -> Stateful a b -> Stateful a b Source #

reverse :: Stateful a b -> Stateful a b Source #

(LeftGCDMonoid a, FactorialMonoid a, TextualMonoid b) => TextualMonoid (Stateful a b) Source # 

Methods

fromText :: Text -> Stateful a b Source #

singleton :: Char -> Stateful a b Source #

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

characterPrefix :: Stateful a b -> Maybe Char Source #

map :: (Char -> Char) -> Stateful a b -> Stateful a b Source #

concatMap :: (Char -> Stateful a b) -> Stateful a b -> Stateful a b Source #

toString :: (Stateful a b -> String) -> Stateful a b -> String Source #

any :: (Char -> Bool) -> Stateful a b -> Bool Source #

all :: (Char -> Bool) -> Stateful a b -> Bool Source #

foldl :: (a -> Stateful a b -> a) -> (a -> Char -> a) -> a -> Stateful a b -> a Source #

foldl' :: (a -> Stateful a b -> a) -> (a -> Char -> a) -> a -> Stateful a b -> a Source #

foldr :: (Stateful a b -> a -> a) -> (Char -> a -> a) -> a -> Stateful a b -> a Source #

scanl :: (Char -> Char -> Char) -> Char -> Stateful a b -> Stateful a b Source #

scanl1 :: (Char -> Char -> Char) -> Stateful a b -> Stateful a b Source #

scanr :: (Char -> Char -> Char) -> Char -> Stateful a b -> Stateful a b Source #

scanr1 :: (Char -> Char -> Char) -> Stateful a b -> Stateful a b Source #

mapAccumL :: (a -> Char -> (a, Char)) -> a -> Stateful a b -> (a, Stateful a b) Source #

mapAccumR :: (a -> Char -> (a, Char)) -> a -> Stateful a b -> (a, Stateful a b) Source #

takeWhile :: (Stateful a b -> Bool) -> (Char -> Bool) -> Stateful a b -> Stateful a b Source #

dropWhile :: (Stateful a b -> Bool) -> (Char -> Bool) -> Stateful a b -> Stateful a b Source #

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

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

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

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

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

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

elem :: Char -> Stateful a b -> Bool Source #

foldl_ :: (a -> Char -> a) -> a -> Stateful a b -> a Source #

foldl_' :: (a -> Char -> a) -> a -> Stateful a b -> a Source #

foldr_ :: (Char -> a -> a) -> a -> Stateful a b -> a Source #

takeWhile_ :: Bool -> (Char -> Bool) -> Stateful a b -> Stateful a b Source #

dropWhile_ :: Bool -> (Char -> Bool) -> Stateful a b -> Stateful a b Source #

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

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

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

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

extract :: Stateful a b -> b Source #

state :: Stateful a b -> a Source #

setState :: a -> Stateful a b -> Stateful a b Source #