monoid-subclasses-1.2.4.1: Subclasses of Monoid
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Monoid.Instances.Positioned

Description

This module defines two monoid transformer data types, OffsetPositioned and LinePositioned. Both data types add a notion of the current position to their base monoid. In case of OffsetPositioned, the current position is a simple integer offset from the beginning of the monoid, and it can be applied to any StableFactorial. The base monoid of LinePositioned must be a TextualMonoid, but for the price it will keep track of the current line and column numbers as well.

Line number is zero-based, column one-based:

> let p = pure "abcd\nefgh\nijkl\nmnop\n" :: LinePositioned String
> p
"abcd\nefgh\nijkl\nmnop\n"
> Data.Monoid.Factorial.drop 13 p
Line 2, column 4: "l\nmnop\n"
Synopsis

Documentation

data OffsetPositioned m Source #

Instances

Instances details
Applicative OffsetPositioned Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Functor OffsetPositioned Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Methods

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

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

Data m => Data (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OffsetPositioned m -> c (OffsetPositioned m) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (OffsetPositioned m) #

toConstr :: OffsetPositioned m -> Constr #

dataTypeOf :: OffsetPositioned m -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (OffsetPositioned m)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OffsetPositioned m)) #

gmapT :: (forall b. Data b => b -> b) -> OffsetPositioned m -> OffsetPositioned m #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OffsetPositioned m -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OffsetPositioned m -> r #

gmapQ :: (forall d. Data d => d -> u) -> OffsetPositioned m -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OffsetPositioned m -> u #

gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> OffsetPositioned m -> m0 (OffsetPositioned m) #

gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> OffsetPositioned m -> m0 (OffsetPositioned m) #

gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> OffsetPositioned m -> m0 (OffsetPositioned m) #

IsString m => IsString (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(FactorialMonoid m, StableFactorial m) => Monoid (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

StableFactorial m => Semigroup (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Show m => Show (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Eq m => Eq (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Ord m => Ord (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, FactorialMonoid m) => FactorialMonoid (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, FactorialMonoid m, LeftGCDMonoid m) => LeftGCDMonoid (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, FactorialMonoid m, RightGCDMonoid m) => RightGCDMonoid (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, FactorialMonoid m) => MonoidNull (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, FactorialMonoid m) => PositiveMonoid (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => TextualMonoid (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Methods

fromText :: Text -> OffsetPositioned m Source #

singleton :: Char -> OffsetPositioned m Source #

splitCharacterPrefix :: OffsetPositioned m -> Maybe (Char, OffsetPositioned m) Source #

characterPrefix :: OffsetPositioned m -> Maybe Char Source #

map :: (Char -> Char) -> OffsetPositioned m -> OffsetPositioned m Source #

concatMap :: (Char -> OffsetPositioned m) -> OffsetPositioned m -> OffsetPositioned m Source #

toString :: (OffsetPositioned m -> String) -> OffsetPositioned m -> String Source #

toText :: (OffsetPositioned m -> Text) -> OffsetPositioned m -> Text Source #

any :: (Char -> Bool) -> OffsetPositioned m -> Bool Source #

all :: (Char -> Bool) -> OffsetPositioned m -> Bool Source #

foldl :: (a -> OffsetPositioned m -> a) -> (a -> Char -> a) -> a -> OffsetPositioned m -> a Source #

foldl' :: (a -> OffsetPositioned m -> a) -> (a -> Char -> a) -> a -> OffsetPositioned m -> a Source #

foldr :: (OffsetPositioned m -> a -> a) -> (Char -> a -> a) -> a -> OffsetPositioned m -> a Source #

scanl :: (Char -> Char -> Char) -> Char -> OffsetPositioned m -> OffsetPositioned m Source #

scanl1 :: (Char -> Char -> Char) -> OffsetPositioned m -> OffsetPositioned m Source #

scanr :: (Char -> Char -> Char) -> Char -> OffsetPositioned m -> OffsetPositioned m Source #

scanr1 :: (Char -> Char -> Char) -> OffsetPositioned m -> OffsetPositioned m Source #

mapAccumL :: (a -> Char -> (a, Char)) -> a -> OffsetPositioned m -> (a, OffsetPositioned m) Source #

mapAccumR :: (a -> Char -> (a, Char)) -> a -> OffsetPositioned m -> (a, OffsetPositioned m) Source #

takeWhile :: (OffsetPositioned m -> Bool) -> (Char -> Bool) -> OffsetPositioned m -> OffsetPositioned m Source #

dropWhile :: (OffsetPositioned m -> Bool) -> (Char -> Bool) -> OffsetPositioned m -> OffsetPositioned m Source #

break :: (OffsetPositioned m -> Bool) -> (Char -> Bool) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m) Source #

span :: (OffsetPositioned m -> Bool) -> (Char -> Bool) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m) Source #

spanMaybe :: s -> (s -> OffsetPositioned m -> Maybe s) -> (s -> Char -> Maybe s) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m, s) Source #

spanMaybe' :: s -> (s -> OffsetPositioned m -> Maybe s) -> (s -> Char -> Maybe s) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m, s) Source #

split :: (Char -> Bool) -> OffsetPositioned m -> [OffsetPositioned m] Source #

find :: (Char -> Bool) -> OffsetPositioned m -> Maybe Char Source #

elem :: Char -> OffsetPositioned m -> Bool Source #

foldl_ :: (a -> Char -> a) -> a -> OffsetPositioned m -> a Source #

foldl_' :: (a -> Char -> a) -> a -> OffsetPositioned m -> a Source #

foldr_ :: (Char -> a -> a) -> a -> OffsetPositioned m -> a Source #

takeWhile_ :: Bool -> (Char -> Bool) -> OffsetPositioned m -> OffsetPositioned m Source #

dropWhile_ :: Bool -> (Char -> Bool) -> OffsetPositioned m -> OffsetPositioned m Source #

break_ :: Bool -> (Char -> Bool) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m) Source #

span_ :: Bool -> (Char -> Bool) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m) Source #

spanMaybe_ :: s -> (s -> Char -> Maybe s) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m, s) Source #

spanMaybe_' :: s -> (s -> Char -> Maybe s) -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m, s) Source #

(StableFactorial m, LeftReductive m) => LeftReductive (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, FactorialMonoid m, RightReductive m) => RightReductive (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

StableFactorial m => Factorial (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

StableFactorial m => StableFactorial (OffsetPositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

data LinePositioned m Source #

Instances

Instances details
Applicative LinePositioned Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Functor LinePositioned Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Methods

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

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

Data m => Data (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LinePositioned m -> c (LinePositioned m) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LinePositioned m) #

toConstr :: LinePositioned m -> Constr #

dataTypeOf :: LinePositioned m -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (LinePositioned m)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LinePositioned m)) #

gmapT :: (forall b. Data b => b -> b) -> LinePositioned m -> LinePositioned m #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LinePositioned m -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LinePositioned m -> r #

gmapQ :: (forall d. Data d => d -> u) -> LinePositioned m -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> LinePositioned m -> u #

gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> LinePositioned m -> m0 (LinePositioned m) #

gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> LinePositioned m -> m0 (LinePositioned m) #

gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> LinePositioned m -> m0 (LinePositioned m) #

IsString m => IsString (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => Monoid (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => Semigroup (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Show m => Show (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Eq m => Eq (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Ord m => Ord (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => FactorialMonoid (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m, LeftGCDMonoid m) => LeftGCDMonoid (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m, RightGCDMonoid m) => RightGCDMonoid (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m, MonoidNull m) => MonoidNull (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => PositiveMonoid (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => TextualMonoid (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

Methods

fromText :: Text -> LinePositioned m Source #

singleton :: Char -> LinePositioned m Source #

splitCharacterPrefix :: LinePositioned m -> Maybe (Char, LinePositioned m) Source #

characterPrefix :: LinePositioned m -> Maybe Char Source #

map :: (Char -> Char) -> LinePositioned m -> LinePositioned m Source #

concatMap :: (Char -> LinePositioned m) -> LinePositioned m -> LinePositioned m Source #

toString :: (LinePositioned m -> String) -> LinePositioned m -> String Source #

toText :: (LinePositioned m -> Text) -> LinePositioned m -> Text Source #

any :: (Char -> Bool) -> LinePositioned m -> Bool Source #

all :: (Char -> Bool) -> LinePositioned m -> Bool Source #

foldl :: (a -> LinePositioned m -> a) -> (a -> Char -> a) -> a -> LinePositioned m -> a Source #

foldl' :: (a -> LinePositioned m -> a) -> (a -> Char -> a) -> a -> LinePositioned m -> a Source #

foldr :: (LinePositioned m -> a -> a) -> (Char -> a -> a) -> a -> LinePositioned m -> a Source #

scanl :: (Char -> Char -> Char) -> Char -> LinePositioned m -> LinePositioned m Source #

scanl1 :: (Char -> Char -> Char) -> LinePositioned m -> LinePositioned m Source #

scanr :: (Char -> Char -> Char) -> Char -> LinePositioned m -> LinePositioned m Source #

scanr1 :: (Char -> Char -> Char) -> LinePositioned m -> LinePositioned m Source #

mapAccumL :: (a -> Char -> (a, Char)) -> a -> LinePositioned m -> (a, LinePositioned m) Source #

mapAccumR :: (a -> Char -> (a, Char)) -> a -> LinePositioned m -> (a, LinePositioned m) Source #

takeWhile :: (LinePositioned m -> Bool) -> (Char -> Bool) -> LinePositioned m -> LinePositioned m Source #

dropWhile :: (LinePositioned m -> Bool) -> (Char -> Bool) -> LinePositioned m -> LinePositioned m Source #

break :: (LinePositioned m -> Bool) -> (Char -> Bool) -> LinePositioned m -> (LinePositioned m, LinePositioned m) Source #

span :: (LinePositioned m -> Bool) -> (Char -> Bool) -> LinePositioned m -> (LinePositioned m, LinePositioned m) Source #

spanMaybe :: s -> (s -> LinePositioned m -> Maybe s) -> (s -> Char -> Maybe s) -> LinePositioned m -> (LinePositioned m, LinePositioned m, s) Source #

spanMaybe' :: s -> (s -> LinePositioned m -> Maybe s) -> (s -> Char -> Maybe s) -> LinePositioned m -> (LinePositioned m, LinePositioned m, s) Source #

split :: (Char -> Bool) -> LinePositioned m -> [LinePositioned m] Source #

find :: (Char -> Bool) -> LinePositioned m -> Maybe Char Source #

elem :: Char -> LinePositioned m -> Bool Source #

foldl_ :: (a -> Char -> a) -> a -> LinePositioned m -> a Source #

foldl_' :: (a -> Char -> a) -> a -> LinePositioned m -> a Source #

foldr_ :: (Char -> a -> a) -> a -> LinePositioned m -> a Source #

takeWhile_ :: Bool -> (Char -> Bool) -> LinePositioned m -> LinePositioned m Source #

dropWhile_ :: Bool -> (Char -> Bool) -> LinePositioned m -> LinePositioned m Source #

break_ :: Bool -> (Char -> Bool) -> LinePositioned m -> (LinePositioned m, LinePositioned m) Source #

span_ :: Bool -> (Char -> Bool) -> LinePositioned m -> (LinePositioned m, LinePositioned m) Source #

spanMaybe_ :: s -> (s -> Char -> Maybe s) -> LinePositioned m -> (LinePositioned m, LinePositioned m, s) Source #

spanMaybe_' :: s -> (s -> Char -> Maybe s) -> LinePositioned m -> (LinePositioned m, LinePositioned m, s) Source #

(StableFactorial m, TextualMonoid m) => LeftReductive (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m, RightReductive m) => RightReductive (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => Factorial (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

(StableFactorial m, TextualMonoid m) => StableFactorial (LinePositioned m) Source # 
Instance details

Defined in Data.Monoid.Instances.Positioned

extract :: Positioned p => p a -> a Source #

position :: Positioned p => p a -> Int Source #

line :: LinePositioned m -> Int Source #

the current line

column :: LinePositioned m -> Int Source #

the current column