monoid-subclasses-0.4.3.1: Subclasses of Monoid

Safe HaskellSafe
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 StableFactorialMonoid. 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.

All positions are zero-based:

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

Synopsis

Documentation

data OffsetPositioned m Source #

Instances

Functor OffsetPositioned Source # 

Methods

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

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

Applicative OffsetPositioned Source # 
Eq m => Eq (OffsetPositioned m) Source # 
Ord m => Ord (OffsetPositioned m) Source # 
Show m => Show (OffsetPositioned m) Source # 
IsString m => IsString (OffsetPositioned m) Source # 
StableFactorialMonoid m => Monoid (OffsetPositioned m) Source # 
StableFactorialMonoid m => PositiveMonoid (OffsetPositioned m) Source # 
(StableFactorialMonoid m, MonoidNull m) => MonoidNull (OffsetPositioned m) Source # 
StableFactorialMonoid m => StableFactorialMonoid (OffsetPositioned m) Source # 
StableFactorialMonoid m => FactorialMonoid (OffsetPositioned m) Source # 

Methods

factors :: OffsetPositioned m -> [OffsetPositioned m] Source #

primePrefix :: OffsetPositioned m -> OffsetPositioned m Source #

primeSuffix :: OffsetPositioned m -> OffsetPositioned m Source #

splitPrimePrefix :: OffsetPositioned m -> Maybe (OffsetPositioned m, OffsetPositioned m) Source #

splitPrimeSuffix :: OffsetPositioned m -> Maybe (OffsetPositioned m, OffsetPositioned m) Source #

inits :: OffsetPositioned m -> [OffsetPositioned m] Source #

tails :: OffsetPositioned m -> [OffsetPositioned m] Source #

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

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

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

length :: OffsetPositioned m -> Int Source #

foldMap :: Monoid n => (OffsetPositioned m -> n) -> OffsetPositioned m -> n Source #

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

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

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

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

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

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

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

splitAt :: Int -> OffsetPositioned m -> (OffsetPositioned m, OffsetPositioned m) Source #

drop :: Int -> OffsetPositioned m -> OffsetPositioned m Source #

take :: Int -> OffsetPositioned m -> OffsetPositioned m Source #

reverse :: OffsetPositioned m -> OffsetPositioned m Source #

(StableFactorialMonoid m, RightGCDMonoid m) => RightGCDMonoid (OffsetPositioned m) Source # 
(StableFactorialMonoid m, LeftGCDMonoid m) => LeftGCDMonoid (OffsetPositioned m) Source # 
(StableFactorialMonoid m, RightReductiveMonoid m) => RightReductiveMonoid (OffsetPositioned m) Source # 
(StableFactorialMonoid m, LeftReductiveMonoid m) => LeftReductiveMonoid (OffsetPositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m) => TextualMonoid (OffsetPositioned m) Source # 

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 #

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 #

data LinePositioned m Source #

Instances

Functor LinePositioned Source # 

Methods

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

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

Applicative LinePositioned Source # 
Eq m => Eq (LinePositioned m) Source # 
Ord m => Ord (LinePositioned m) Source # 
Show m => Show (LinePositioned m) Source # 
IsString m => IsString (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m) => Monoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m) => PositiveMonoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m, MonoidNull m) => MonoidNull (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m) => StableFactorialMonoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m) => FactorialMonoid (LinePositioned m) Source # 

Methods

factors :: LinePositioned m -> [LinePositioned m] Source #

primePrefix :: LinePositioned m -> LinePositioned m Source #

primeSuffix :: LinePositioned m -> LinePositioned m Source #

splitPrimePrefix :: LinePositioned m -> Maybe (LinePositioned m, LinePositioned m) Source #

splitPrimeSuffix :: LinePositioned m -> Maybe (LinePositioned m, LinePositioned m) Source #

inits :: LinePositioned m -> [LinePositioned m] Source #

tails :: LinePositioned m -> [LinePositioned m] Source #

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

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

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

length :: LinePositioned m -> Int Source #

foldMap :: Monoid n => (LinePositioned m -> n) -> LinePositioned m -> n Source #

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

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

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

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

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

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

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

splitAt :: Int -> LinePositioned m -> (LinePositioned m, LinePositioned m) Source #

drop :: Int -> LinePositioned m -> LinePositioned m Source #

take :: Int -> LinePositioned m -> LinePositioned m Source #

reverse :: LinePositioned m -> LinePositioned m Source #

(StableFactorialMonoid m, TextualMonoid m, RightGCDMonoid m) => RightGCDMonoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m, LeftGCDMonoid m) => LeftGCDMonoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m, RightReductiveMonoid m) => RightReductiveMonoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m, LeftReductiveMonoid m) => LeftReductiveMonoid (LinePositioned m) Source # 
(StableFactorialMonoid m, TextualMonoid m) => TextualMonoid (LinePositioned m) Source # 

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 #

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 #

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