separated-0.3.2.1: A data type with elements separated by values

Safe HaskellNone
LanguageHaskell2010

Data.Separated

Contents

Synopsis

Data types

newtype Separated a b Source #

A list of pairs of separator and value. Separated by a in values b. There are an even number of separators as there are values.

Constructors

Separated [(a, b)] 

Instances

Bitraversable Separated Source # 

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Separated a b -> f (Separated c d) #

Bifoldable Separated Source # 

Methods

bifold :: Monoid m => Separated m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Separated a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Separated a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Separated a b -> c #

Bifunctor Separated Source # 

Methods

bimap :: (a -> b) -> (c -> d) -> Separated a c -> Separated b d #

first :: (a -> b) -> Separated a c -> Separated b c #

second :: (b -> c) -> Separated a b -> Separated a c #

Swapped Separated Source #

The isomorphism that swaps elements with their separators.

>>> swapped # emptySeparated
[]
>>> swapped # ('x' +: 6 +: emptySeparated)
[6,'x']
>>> emptySeparated ^. swapped
[]
>>> ('x' +: 6 +: emptySeparated) ^. swapped
[6,'x']

Methods

swapped :: (Profunctor p, Functor f) => p (Separated b a) (f (Separated d c)) -> p (Separated a b) (f (Separated c d)) #

Sprinkle Separated Source # 

Methods

sprinkle :: s -> [a] -> Separated s a Source #

Construct Separated Source #

One element and one separator.

>>> (7 +- "abc") :: Separated Int String
[7,"abc"]
>>> 7 +: "abc" +: (8 +- "def") :: Separated Int String
[7,"abc",8,"def"]

Methods

(+-) :: s -> a -> Separated s a Source #

(-+) :: s -> a -> Separated a s Source #

empty :: Separated s a Source #

SeparatedCons Separated1 Separated Source # 

Associated Types

type SeparatedConsF (Separated :: * -> * -> *) :: * -> * -> * Source #

type SeparatedConsG (Separated1 :: * -> * -> *) :: * -> * -> * Source #

Methods

(+:) :: a -> Separated1 b a -> Separated a b Source #

SeparatedCons Separated Separated1 Source # 

Associated Types

type SeparatedConsF (Separated1 :: * -> * -> *) :: * -> * -> * Source #

type SeparatedConsG (Separated :: * -> * -> *) :: * -> * -> * Source #

Methods

(+:) :: a -> Separated b a -> Separated1 a b Source #

Functor (Separated a) Source #

Map across a Separated on the element values.

fmap id (x :: Separated Int String) == x
\a b -> fmap (+1) (a +: b +: emptySeparated) == a +: (1+b) +: emptySeparated

Methods

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

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

Monoid a => Applicative (Separated a) Source #

Applies functions with element values, using a zipping operation, appending separators. The identity operation is an infinite list of the emptySeparated separator and the given element value.

>>> (emptySeparated :: Separated [Int] (String -> [String])) <*> emptySeparated
[]
>>> [1,2] +: (\s -> [s, reverse s, drop 1 s]) +: emptySeparated <*> [3,4,5] +: "abc" +: emptySeparated
[[1,2,3,4,5],["abc","cba","bc"]]

Methods

pure :: a -> Separated a a #

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

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

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

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

Foldable (Separated a) Source # 

Methods

fold :: Monoid m => Separated a m -> m #

foldMap :: Monoid m => (a -> m) -> Separated a a -> m #

foldr :: (a -> b -> b) -> b -> Separated a a -> b #

foldr' :: (a -> b -> b) -> b -> Separated a a -> b #

foldl :: (b -> a -> b) -> b -> Separated a a -> b #

foldl' :: (b -> a -> b) -> b -> Separated a a -> b #

foldr1 :: (a -> a -> a) -> Separated a a -> a #

foldl1 :: (a -> a -> a) -> Separated a a -> a #

toList :: Separated a a -> [a] #

null :: Separated a a -> Bool #

length :: Separated a a -> Int #

elem :: Eq a => a -> Separated a a -> Bool #

maximum :: Ord a => Separated a a -> a #

minimum :: Ord a => Separated a a -> a #

sum :: Num a => Separated a a -> a #

product :: Num a => Separated a a -> a #

Traversable (Separated a) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Separated a a -> f (Separated a b) #

sequenceA :: Applicative f => Separated a (f a) -> f (Separated a a) #

mapM :: Monad m => (a -> m b) -> Separated a a -> m (Separated a b) #

sequence :: Monad m => Separated a (m a) -> m (Separated a a) #

Semigroup a => Apply (Separated a) Source #

Applies functions with element values, using a zipping operation, appending separators.

>>> (emptySeparated :: Separated [Int] (String -> [String])) <.> emptySeparated
[]
>>> [1,2] +: (\s -> [s, reverse s, drop 1 s]) +: emptySeparated <.> [3,4,5] +: "abc" +: emptySeparated
[[1,2,3,4,5],["abc","cba","bc"]]

Methods

(<.>) :: Separated a (a -> b) -> Separated a a -> Separated a b #

(.>) :: Separated a a -> Separated a b -> Separated a b #

(<.) :: Separated a a -> Separated a b -> Separated a a #

liftF2 :: (a -> b -> c) -> Separated a a -> Separated a b -> Separated a c #

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

Methods

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

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

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

Methods

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

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

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

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

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

max :: Separated a b -> Separated a b -> Separated a b #

min :: Separated a b -> Separated a b -> Separated a b #

(Show a, Show b) => Show (Separated a b) Source #
>>> show (emptySeparated :: Separated () ())
"[]"
>>> show ('x' +: (6 :: Int) +: emptySeparated)
"['x',6]"

Methods

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

show :: Separated a b -> String #

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

Semigroup (Separated a b) Source #
>>> ('x' +: (6 :: Int) +: emptySeparated) <> ('y' +: 7 +: emptySeparated)
['x',6,'y',7]

Methods

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

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

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

Monoid (Separated a b) Source #
>>> ('x' +: (6 :: Int) +: emptySeparated) `mappend` ('y' +: 7 +: emptySeparated)
['x',6,'y',7]

Methods

mempty :: Separated a b #

mappend :: Separated a b -> Separated a b -> Separated a b #

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

Wrapped (Separated a b) Source # 

Associated Types

type Unwrapped (Separated a b) :: * #

Methods

_Wrapped' :: Iso' (Separated a b) (Unwrapped (Separated a b)) #

(~) * (Separated a1 b1) t => Rewrapped (Separated a2 b2) t Source # 
Appends (Separated1 a s) (Separated s a) (Separated1 a s) Source #

Append a list of pairs of separator and element values to element values interspersed with a separator.

>>> (singleSeparated 7 :: Separated1 Int Char) <++> (emptySeparated :: Separated Char Int)
[7]
>>> (singleSeparated 6 :: Separated1 Int Char) <++> 'x' +: 7 +: (emptySeparated :: Separated Char Int)
[6,'x',7]
>>> 'w' +: (singleSeparated 6 :: Separated1 Int Char) <++> 'x' +: 7 +: (emptySeparated :: Separated Char Int)
['w',6,'x',7]

Methods

(<++>) :: Separated1 a s -> Separated s a -> Separated1 a s Source #

Appends (Separated1 s a) (Separated1 a s) (Separated s a) Source #

Append two lists of separated values to produce a list of pairs of separator and element values.

>>> (singleSeparated 7 :: Separated1 Int Char) <++> (singleSeparated 'a' :: Separated1 Char Int)
[7,'a']

a +: (singleSeparated 7 :: Separated1 Int Char) ++ (singleSeparated b :: Separated1 Char Int) [a,7,b]

a +: (b :: Separated Int Int) == a +: b --  (a +: (b <++> c)) == ((a +: b) <++> c)

Methods

(<++>) :: Separated1 s a -> Separated1 a s -> Separated s a Source #

Appends (Separated s a) (Separated1 s a) (Separated1 s a) Source #

Append element values interspersed with a separator to a list of pairs of separator and element values.

>>> (emptySeparated :: Separated Int Char) <++> (singleSeparated 7 :: Separated1 Int Char)
[7]
>>> (emptySeparated :: Separated Int Char) <++> 6 +: 'x' +: (singleSeparated 7 :: Separated1 Int Char)
[6,'x',7]
>>> 'w' +: (emptySeparated :: Separated Int Char) <++> 6 +: 'x' +: (singleSeparated 7 :: Separated1 Int Char)
['w',6,'x',7]

Methods

(<++>) :: Separated s a -> Separated1 s a -> Separated1 s a Source #

HasTail (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) Source #

A lens on the tail.

(d +: e +: (singleSeparated x :: Separated1 Int Char)) ^. tailL == e +: x +: emptySeparated

Methods

tailL :: Lens (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) Source #

type SeparatedConsF Separated Source # 
type SeparatedConsG Separated Source # 
type Unwrapped (Separated a b) Source # 
type Unwrapped (Separated a b) = [(a, b)]

data Separated1 b a Source #

A list of pairs of separator and value. Separated by a in values b. There is one more value than there are separators.

Constructors

Separated1 b (Separated a b) 

Instances

Bitraversable Separated1 Source # 

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Separated1 a b -> f (Separated1 c d) #

Bifoldable Separated1 Source # 

Methods

bifold :: Monoid m => Separated1 m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Separated1 a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Separated1 a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Separated1 a b -> c #

Bifunctor Separated1 Source # 

Methods

bimap :: (a -> b) -> (c -> d) -> Separated1 a c -> Separated1 b d #

first :: (a -> b) -> Separated1 a c -> Separated1 b c #

second :: (b -> c) -> Separated1 a b -> Separated1 a c #

Sprinkle Separated1 Source # 

Methods

sprinkle :: s -> [a] -> Separated1 s a Source #

Separated1Single Separated1 Source #

Zero element values interspersed with one element.

>>> (singleSeparated 4 :: Separated1 Int Char)
[4]
(singleSeparated x  :: Separated1 Int Char) ^. tailL == emptySeparated

Methods

singleSeparated :: a -> Separated1 a s Source #

SeparatedCons Separated1 Separated Source # 

Associated Types

type SeparatedConsF (Separated :: * -> * -> *) :: * -> * -> * Source #

type SeparatedConsG (Separated1 :: * -> * -> *) :: * -> * -> * Source #

Methods

(+:) :: a -> Separated1 b a -> Separated a b Source #

SeparatedCons Separated Separated1 Source # 

Associated Types

type SeparatedConsF (Separated1 :: * -> * -> *) :: * -> * -> * Source #

type SeparatedConsG (Separated :: * -> * -> *) :: * -> * -> * Source #

Methods

(+:) :: a -> Separated b a -> Separated1 a b Source #

Functor (Separated1 b) Source #

Map across a Separated1 on the separator values.

>>> fmap (+1) (set tailL (1 +: 'b' +: 2 +: 'c' +: emptySeparated) (singleSeparated 'a' :: Separated1 Char Int))
['a',2,'b',3,'c']
fmap id (x :: Separated1 Int String) == x
fmap (+1) (singleSeparated x :: Separated1 Char Int) == singleSeparated x

Methods

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

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

Monoid b => Applicative (Separated1 b) Source #

Applies functions with separator values, using a zipping operation, appending elements. The identity operation is an infinite list of the emptySeparated element and the given separator value.

>>> [1,2] +: reverse +: [3,4] +: emptySeparated <*> [5,6,7] +: "abc" +: [8] +: emptySeparated
[[1,2,5,6,7],"cba",[3,4,8]]

Methods

pure :: a -> Separated1 b a #

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

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

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

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

Foldable (Separated1 b) Source # 

Methods

fold :: Monoid m => Separated1 b m -> m #

foldMap :: Monoid m => (a -> m) -> Separated1 b a -> m #

foldr :: (a -> b -> b) -> b -> Separated1 b a -> b #

foldr' :: (a -> b -> b) -> b -> Separated1 b a -> b #

foldl :: (b -> a -> b) -> b -> Separated1 b a -> b #

foldl' :: (b -> a -> b) -> b -> Separated1 b a -> b #

foldr1 :: (a -> a -> a) -> Separated1 b a -> a #

foldl1 :: (a -> a -> a) -> Separated1 b a -> a #

toList :: Separated1 b a -> [a] #

null :: Separated1 b a -> Bool #

length :: Separated1 b a -> Int #

elem :: Eq a => a -> Separated1 b a -> Bool #

maximum :: Ord a => Separated1 b a -> a #

minimum :: Ord a => Separated1 b a -> a #

sum :: Num a => Separated1 b a -> a #

product :: Num a => Separated1 b a -> a #

Traversable (Separated1 b) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Separated1 b a -> f (Separated1 b b) #

sequenceA :: Applicative f => Separated1 b (f a) -> f (Separated1 b a) #

mapM :: Monad m => (a -> m b) -> Separated1 b a -> m (Separated1 b b) #

sequence :: Monad m => Separated1 b (m a) -> m (Separated1 b a) #

Semigroup b => Apply (Separated1 b) Source #

Applies functions with separator values, using a zipping operation, appending elements.

>>> [1,2] +: reverse +: [3,4] +: emptySeparated <.> [5,6,7] +: "abc" +: [8] +: emptySeparated
[[1,2,5,6,7],"cba",[3,4,8]]

Methods

(<.>) :: Separated1 b (a -> b) -> Separated1 b a -> Separated1 b b #

(.>) :: Separated1 b a -> Separated1 b b -> Separated1 b b #

(<.) :: Separated1 b a -> Separated1 b b -> Separated1 b a #

liftF2 :: (a -> b -> c) -> Separated1 b a -> Separated1 b b -> Separated1 b c #

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

Methods

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

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

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

Methods

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

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

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

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

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

max :: Separated1 b a -> Separated1 b a -> Separated1 b a #

min :: Separated1 b a -> Separated1 b a -> Separated1 b a #

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

Methods

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

show :: Separated1 b a -> String #

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

HasHead (Separated1 a t) (Separated1 a t) a a Source #

A lens on the first element value.

>>> (singleSeparated 7 :: Separated1 Int Char) ^. headL
7
(singleSeparated x :: Separated1 Int Char) ^. headL == (x :: Int)

Methods

headL :: Lens (Separated1 a t) (Separated1 a t) a a Source #

Appends (Separated1 a s) (Separated s a) (Separated1 a s) Source #

Append a list of pairs of separator and element values to element values interspersed with a separator.

>>> (singleSeparated 7 :: Separated1 Int Char) <++> (emptySeparated :: Separated Char Int)
[7]
>>> (singleSeparated 6 :: Separated1 Int Char) <++> 'x' +: 7 +: (emptySeparated :: Separated Char Int)
[6,'x',7]
>>> 'w' +: (singleSeparated 6 :: Separated1 Int Char) <++> 'x' +: 7 +: (emptySeparated :: Separated Char Int)
['w',6,'x',7]

Methods

(<++>) :: Separated1 a s -> Separated s a -> Separated1 a s Source #

Appends (Separated1 s a) (Separated1 a s) (Separated s a) Source #

Append two lists of separated values to produce a list of pairs of separator and element values.

>>> (singleSeparated 7 :: Separated1 Int Char) <++> (singleSeparated 'a' :: Separated1 Char Int)
[7,'a']

a +: (singleSeparated 7 :: Separated1 Int Char) ++ (singleSeparated b :: Separated1 Char Int) [a,7,b]

a +: (b :: Separated Int Int) == a +: b --  (a +: (b <++> c)) == ((a +: b) <++> c)

Methods

(<++>) :: Separated1 s a -> Separated1 a s -> Separated s a Source #

Appends (Separated s a) (Separated1 s a) (Separated1 s a) Source #

Append element values interspersed with a separator to a list of pairs of separator and element values.

>>> (emptySeparated :: Separated Int Char) <++> (singleSeparated 7 :: Separated1 Int Char)
[7]
>>> (emptySeparated :: Separated Int Char) <++> 6 +: 'x' +: (singleSeparated 7 :: Separated1 Int Char)
[6,'x',7]
>>> 'w' +: (emptySeparated :: Separated Int Char) <++> 6 +: 'x' +: (singleSeparated 7 :: Separated1 Int Char)
['w',6,'x',7]

Methods

(<++>) :: Separated s a -> Separated1 s a -> Separated1 s a Source #

HasTail (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) Source #

A lens on the tail.

(d +: e +: (singleSeparated x :: Separated1 Int Char)) ^. tailL == e +: x +: emptySeparated

Methods

tailL :: Lens (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) Source #

type SeparatedConsF Separated1 Source # 
type SeparatedConsG Separated1 Source # 

newtype Pesarated b a Source #

The Separated type constructor, flipped.

Constructors

Pesarated (Separated a b) 

Instances

Bitraversable Pesarated Source # 

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Pesarated a b -> f (Pesarated c d) #

Bifoldable Pesarated Source # 

Methods

bifold :: Monoid m => Pesarated m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Pesarated a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Pesarated a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Pesarated a b -> c #

Bifunctor Pesarated Source # 

Methods

bimap :: (a -> b) -> (c -> d) -> Pesarated a c -> Pesarated b d #

first :: (a -> b) -> Pesarated a c -> Pesarated b c #

second :: (b -> c) -> Pesarated a b -> Pesarated a c #

Swapped Pesarated Source #

The isomorphism that swaps elements with their separators.

>>> swapped # emptyPesarated
[]
>>> swapped # ('x' -: 6 -: emptyPesarated)
[6,'x']
>>> emptyPesarated ^. swapped
[]
>>> ('x' -: 6 -: emptyPesarated) ^. swapped
[6,'x']

Methods

swapped :: (Profunctor p, Functor f) => p (Pesarated b a) (f (Pesarated d c)) -> p (Pesarated a b) (f (Pesarated c d)) #

Sprinkle Pesarated Source # 

Methods

sprinkle :: s -> [a] -> Pesarated s a Source #

Construct Pesarated Source #

One element and one separator.

>>> (7 -+ "abc") :: Pesarated String Int
[7,"abc"]
>>> 7 -: "abc" -: (8 -+ "def") :: Pesarated String Int
[7,"abc",8,"def"]

Methods

(+-) :: s -> a -> Pesarated s a Source #

(-+) :: s -> a -> Pesarated a s Source #

empty :: Pesarated s a Source #

PesaratedCons Pesarated1 Pesarated Source # 

Associated Types

type PesaratedConsF (Pesarated :: * -> * -> *) :: * -> * -> * Source #

type PesaratedConsG (Pesarated1 :: * -> * -> *) :: * -> * -> * Source #

Methods

(-:) :: b -> Pesarated1 b a -> Pesarated a b Source #

PesaratedCons Pesarated Pesarated1 Source # 

Associated Types

type PesaratedConsF (Pesarated1 :: * -> * -> *) :: * -> * -> * Source #

type PesaratedConsG (Pesarated :: * -> * -> *) :: * -> * -> * Source #

Methods

(-:) :: b -> Pesarated b a -> Pesarated1 a b Source #

Functor (Pesarated a) Source #

Map across a Pesarated on the element values.

fmap id (x :: Pesarated Int String) == x
\a b -> fmap (+1) (a -: b -: emptyPesarated) == (1+a) -: b -: emptyPesarated

Methods

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

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

Monoid a => Applicative (Pesarated a) Source #

Applies functions with element values, using a zipping operation, appending separators. The identity operation is an infinite list of the emptySeparated separator and the given element value.

>>> (emptySeparated :: Separated [Int] (String -> [String])) <*> emptySeparated
[]
>>> (\s -> [s, reverse s, drop 1 s]) -: [1,2] -: emptyPesarated <*> "abc" -: [3,4,5] -: emptyPesarated
[["abc","cba","bc"],[1,2,3,4,5]]

Methods

pure :: a -> Pesarated a a #

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

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

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

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

Foldable (Pesarated b) Source # 

Methods

fold :: Monoid m => Pesarated b m -> m #

foldMap :: Monoid m => (a -> m) -> Pesarated b a -> m #

foldr :: (a -> b -> b) -> b -> Pesarated b a -> b #

foldr' :: (a -> b -> b) -> b -> Pesarated b a -> b #

foldl :: (b -> a -> b) -> b -> Pesarated b a -> b #

foldl' :: (b -> a -> b) -> b -> Pesarated b a -> b #

foldr1 :: (a -> a -> a) -> Pesarated b a -> a #

foldl1 :: (a -> a -> a) -> Pesarated b a -> a #

toList :: Pesarated b a -> [a] #

null :: Pesarated b a -> Bool #

length :: Pesarated b a -> Int #

elem :: Eq a => a -> Pesarated b a -> Bool #

maximum :: Ord a => Pesarated b a -> a #

minimum :: Ord a => Pesarated b a -> a #

sum :: Num a => Pesarated b a -> a #

product :: Num a => Pesarated b a -> a #

Traversable (Pesarated b) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Pesarated b a -> f (Pesarated b b) #

sequenceA :: Applicative f => Pesarated b (f a) -> f (Pesarated b a) #

mapM :: Monad m => (a -> m b) -> Pesarated b a -> m (Pesarated b b) #

sequence :: Monad m => Pesarated b (m a) -> m (Pesarated b a) #

Semigroup a => Apply (Pesarated a) Source #

Applies functions with element values, using a zipping operation, appending separators.

>>> (emptyPesarated :: Pesarated [Int] (String -> [String])) <.> emptyPesarated
[]
>>> (\s -> [s, reverse s, drop 1 s]) -: [1,2] -: emptyPesarated <.> "abc" -: [3,4,5] -: emptyPesarated
[["abc","cba","bc"],[1,2,3,4,5]]

Methods

(<.>) :: Pesarated a (a -> b) -> Pesarated a a -> Pesarated a b #

(.>) :: Pesarated a a -> Pesarated a b -> Pesarated a b #

(<.) :: Pesarated a a -> Pesarated a b -> Pesarated a a #

liftF2 :: (a -> b -> c) -> Pesarated a a -> Pesarated a b -> Pesarated a c #

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

Methods

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

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

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

Methods

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

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

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

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

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

max :: Pesarated b a -> Pesarated b a -> Pesarated b a #

min :: Pesarated b a -> Pesarated b a -> Pesarated b a #

(Show a, Show b) => Show (Pesarated b a) Source #
>>> show (emptyPesarated :: Pesarated () ())
"[]"
>>> show ('x' -: (6 :: Int) -: emptyPesarated)
"['x',6]"

Methods

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

show :: Pesarated b a -> String #

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

Semigroup (Pesarated b a) Source #
>>> ('x' -: (6 :: Int) -: emptyPesarated) <> ('y' -: 7 -: emptyPesarated)
['x',6,'y',7]

Methods

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

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

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

Monoid (Pesarated b a) Source #
>>> ('x' -: (6 :: Int) -: emptyPesarated) `mappend` ('y' -: 7 -: emptyPesarated)
['x',6,'y',7]

Methods

mempty :: Pesarated b a #

mappend :: Pesarated b a -> Pesarated b a -> Pesarated b a #

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

Wrapped (Pesarated b a) Source # 

Associated Types

type Unwrapped (Pesarated b a) :: * #

Methods

_Wrapped' :: Iso' (Pesarated b a) (Unwrapped (Pesarated b a)) #

(~) * (Pesarated b1 a1) t => Rewrapped (Pesarated b2 a2) t Source # 
HasTail (Pesarated1 a s) (Pesarated1 b s) (Pesarated s a) (Pesarated s b) Source #

A lens on the tail.

(d -: e -: (singlePesarated x :: Pesarated1 Char Int)) ^. tailL == e -: x -: emptyPesarated

Methods

tailL :: Lens (Pesarated1 a s) (Pesarated1 b s) (Pesarated s a) (Pesarated s b) Source #

type PesaratedConsF Pesarated Source # 
type PesaratedConsG Pesarated Source # 
type Unwrapped (Pesarated b a) Source # 
type Unwrapped (Pesarated b a) = Separated a b

newtype Pesarated1 a b Source #

The Separated1 type constructor, flipped.

Constructors

Pesarated1 (Separated1 b a) 

Instances

Bitraversable Pesarated1 Source # 

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Pesarated1 a b -> f (Pesarated1 c d) #

Bifoldable Pesarated1 Source # 

Methods

bifold :: Monoid m => Pesarated1 m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Pesarated1 a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Pesarated1 a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Pesarated1 a b -> c #

Bifunctor Pesarated1 Source # 

Methods

bimap :: (a -> b) -> (c -> d) -> Pesarated1 a c -> Pesarated1 b d #

first :: (a -> b) -> Pesarated1 a c -> Pesarated1 b c #

second :: (b -> c) -> Pesarated1 a b -> Pesarated1 a c #

Pesarated1Single Pesarated1 Source #

Zero element values interspersed with one element.

>>> (singlePesarated 4 :: Pesarated1 Char Int)
[4]
(singlePesarated x  :: Pesarated1 Int Char) ^. tailL == emptyPesarated

Methods

singlePesarated :: a -> Pesarated1 s a Source #

PesaratedCons Pesarated1 Pesarated Source # 

Associated Types

type PesaratedConsF (Pesarated :: * -> * -> *) :: * -> * -> * Source #

type PesaratedConsG (Pesarated1 :: * -> * -> *) :: * -> * -> * Source #

Methods

(-:) :: b -> Pesarated1 b a -> Pesarated a b Source #

PesaratedCons Pesarated Pesarated1 Source # 

Associated Types

type PesaratedConsF (Pesarated1 :: * -> * -> *) :: * -> * -> * Source #

type PesaratedConsG (Pesarated :: * -> * -> *) :: * -> * -> * Source #

Methods

(-:) :: b -> Pesarated b a -> Pesarated1 a b Source #

Functor (Pesarated1 a) Source #

Map across a Pesarated1 on the separator values.

>>> fmap toUpper (set tailL (1 -: 'b' -: 2 -: 'c' -: empty) (singlePesarated 'z' :: Pesarated1 Int Char) :: Pesarated1 Int Char)
['Z',1,'B',2,'C']
fmap id (x :: Pesarated1 Int String) == x
fmap (+1) (singlePesarated x :: Pesarated1 Char Int) == singlePesarated (x + 1)

Methods

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

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

Monoid a => Applicative (Pesarated1 a) Source #

Applies functions with separator values, using a zipping operation, appending elements. The identity operation is an infinite list of the emptySeparated element and the given separator value.

>>> id -: [1,2] -: reverse -: [3,4] -: emptyPesarated <*> "def" -: [5,6,7] -: "abc" -: [8] -: emptyPesarated
["def",[1,2,5,6,7],"cba",[3,4,8]]

Methods

pure :: a -> Pesarated1 a a #

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

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

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

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

Foldable (Pesarated1 a) Source # 

Methods

fold :: Monoid m => Pesarated1 a m -> m #

foldMap :: Monoid m => (a -> m) -> Pesarated1 a a -> m #

foldr :: (a -> b -> b) -> b -> Pesarated1 a a -> b #

foldr' :: (a -> b -> b) -> b -> Pesarated1 a a -> b #

foldl :: (b -> a -> b) -> b -> Pesarated1 a a -> b #

foldl' :: (b -> a -> b) -> b -> Pesarated1 a a -> b #

foldr1 :: (a -> a -> a) -> Pesarated1 a a -> a #

foldl1 :: (a -> a -> a) -> Pesarated1 a a -> a #

toList :: Pesarated1 a a -> [a] #

null :: Pesarated1 a a -> Bool #

length :: Pesarated1 a a -> Int #

elem :: Eq a => a -> Pesarated1 a a -> Bool #

maximum :: Ord a => Pesarated1 a a -> a #

minimum :: Ord a => Pesarated1 a a -> a #

sum :: Num a => Pesarated1 a a -> a #

product :: Num a => Pesarated1 a a -> a #

Traversable (Pesarated1 a) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Pesarated1 a a -> f (Pesarated1 a b) #

sequenceA :: Applicative f => Pesarated1 a (f a) -> f (Pesarated1 a a) #

mapM :: Monad m => (a -> m b) -> Pesarated1 a a -> m (Pesarated1 a b) #

sequence :: Monad m => Pesarated1 a (m a) -> m (Pesarated1 a a) #

Semigroup a => Apply (Pesarated1 a) Source #

Applies functions with separator values, using a zipping operation, appending elements.

>>> id -: [1,2] -: reverse -: [3,4] -: emptyPesarated <.> "def" -: [5,6,7] -: "abc" -: [8] -: emptyPesarated
["def",[1,2,5,6,7],"cba",[3,4,8]]

Methods

(<.>) :: Pesarated1 a (a -> b) -> Pesarated1 a a -> Pesarated1 a b #

(.>) :: Pesarated1 a a -> Pesarated1 a b -> Pesarated1 a b #

(<.) :: Pesarated1 a a -> Pesarated1 a b -> Pesarated1 a a #

liftF2 :: (a -> b -> c) -> Pesarated1 a a -> Pesarated1 a b -> Pesarated1 a c #

Traversable1 (Pesarated1 a) Source # 

Methods

traverse1 :: Apply f => (a -> f b) -> Pesarated1 a a -> f (Pesarated1 a b) #

sequence1 :: Apply f => Pesarated1 a (f b) -> f (Pesarated1 a b) #

Foldable1 (Pesarated1 a) Source # 

Methods

fold1 :: Semigroup m => Pesarated1 a m -> m #

foldMap1 :: Semigroup m => (a -> m) -> Pesarated1 a a -> m #

toNonEmpty :: Pesarated1 a a -> NonEmpty a #

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

Methods

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

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

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

Methods

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

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

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

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

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

max :: Pesarated1 a b -> Pesarated1 a b -> Pesarated1 a b #

min :: Pesarated1 a b -> Pesarated1 a b -> Pesarated1 a b #

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

Methods

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

show :: Pesarated1 a b -> String #

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

Wrapped (Pesarated1 a b) Source # 

Associated Types

type Unwrapped (Pesarated1 a b) :: * #

Methods

_Wrapped' :: Iso' (Pesarated1 a b) (Unwrapped (Pesarated1 a b)) #

(~) * (Pesarated1 a1 b1) t => Rewrapped (Pesarated1 a2 b2) t Source # 
HasHead (Pesarated1 a t) (Pesarated1 a t) t t Source #

A lens on the first element value.

>>> (singlePesarated 7 :: Pesarated1 Char Int) ^. headL
7
(singlePesarated x :: Pesarated1 Char Int) ^. headL == (x :: Int)

Methods

headL :: Lens (Pesarated1 a t) (Pesarated1 a t) t t Source #

HasTail (Pesarated1 a s) (Pesarated1 b s) (Pesarated s a) (Pesarated s b) Source #

A lens on the tail.

(d -: e -: (singlePesarated x :: Pesarated1 Char Int)) ^. tailL == e -: x -: emptyPesarated

Methods

tailL :: Lens (Pesarated1 a s) (Pesarated1 b s) (Pesarated s a) (Pesarated s b) Source #

type PesaratedConsF Pesarated1 Source # 
type PesaratedConsG Pesarated1 Source # 
type Unwrapped (Pesarated1 a b) Source # 

Iso

separated :: Iso [(a, b)] [(c, d)] (Separated a b) (Separated c d) Source #

The isomorphism to a list of pairs of element and separator values.

>>> separated # emptySeparated
[]
>>> separated # ('x' +: 6 +: emptySeparated)
[('x',6)]
>>> [] ^. separated
[]
>>> [(6, [])] ^. separated
[6,[]]

separated1 :: Iso (a, Separated s a) (b, Separated t b) (Separated1 a s) (Separated1 b t) Source #

The isomorphism to element values interspersed with a separator.

>>> separated1 # (singleSeparated 6)
(6,[])
>>> separated1 # (5 +: 'x' +: singleSeparated 6)
(5,['x',6])
>>> (6, emptySeparated) ^. separated1
[6]
>>> (5, 'x' +- 6) ^. separated1
[5,'x',6]

pesarated :: Iso [(a, b)] [(c, d)] (Pesarated b a) (Pesarated d c) Source #

The isomorphism to element values interspersed with a separator.

>>> pesarated # emptyPesarated
[]
>>> ('a', 'x' +- 6) ^. pesarated1
['a',6,'x']
>>> ('x' -: 6 -: emptyPesarated)
['x',6]

pesarated1 :: Iso (a, Pesarated a s) (b, Pesarated b t) (Pesarated1 s a) (Pesarated1 t b) Source #

The isomorphism to element values interspersed with a separator.

>>> pesarated1 # singlePesarated 6
(6,[])
>>> pesarated1 # (8 -: 'x' -: singlePesarated 6)
(8,['x',6])
>>> (6, empty) ^. pesarated1
[6]
>>> (5, 'x' -+ 6) ^. pesarated1
[5,'x',6]

Viewing

class HasHead s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #

Structures that have a head element.

Minimal complete definition

headL

Methods

headL :: Lens s t a b Source #

Instances

HasHead (Pesarated1 a t) (Pesarated1 a t) t t Source #

A lens on the first element value.

>>> (singlePesarated 7 :: Pesarated1 Char Int) ^. headL
7
(singlePesarated x :: Pesarated1 Char Int) ^. headL == (x :: Int)

Methods

headL :: Lens (Pesarated1 a t) (Pesarated1 a t) t t Source #

HasHead (Separated1 a t) (Separated1 a t) a a Source #

A lens on the first element value.

>>> (singleSeparated 7 :: Separated1 Int Char) ^. headL
7
(singleSeparated x :: Separated1 Int Char) ^. headL == (x :: Int)

Methods

headL :: Lens (Separated1 a t) (Separated1 a t) a a Source #

class HasTail s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #

Structures that have a tail.

Minimal complete definition

tailL

Methods

tailL :: Lens s t a b Source #

Instances

HasTail (Pesarated1 a s) (Pesarated1 b s) (Pesarated s a) (Pesarated s b) Source #

A lens on the tail.

(d -: e -: (singlePesarated x :: Pesarated1 Char Int)) ^. tailL == e -: x -: emptyPesarated

Methods

tailL :: Lens (Pesarated1 a s) (Pesarated1 b s) (Pesarated s a) (Pesarated s b) Source #

HasTail (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) Source #

A lens on the tail.

(d +: e +: (singleSeparated x :: Separated1 Int Char)) ^. tailL == e +: x +: emptySeparated

Methods

tailL :: Lens (Separated1 a s) (Separated1 a t) (Separated s a) (Separated t a) Source #

Constructing

class Separated1Single f where Source #

Construct a single separated value.

Minimal complete definition

singleSeparated

Methods

singleSeparated :: a -> f a s Source #

Instances

Separated1Single Separated1 Source #

Zero element values interspersed with one element.

>>> (singleSeparated 4 :: Separated1 Int Char)
[4]
(singleSeparated x  :: Separated1 Int Char) ^. tailL == emptySeparated

Methods

singleSeparated :: a -> Separated1 a s Source #

class Pesarated1Single f where Source #

Minimal complete definition

singlePesarated

Methods

singlePesarated :: a -> f s a Source #

Instances

Pesarated1Single Pesarated1 Source #

Zero element values interspersed with one element.

>>> (singlePesarated 4 :: Pesarated1 Char Int)
[4]
(singlePesarated x  :: Pesarated1 Int Char) ^. tailL == emptyPesarated

Methods

singlePesarated :: a -> Pesarated1 s a Source #

class Construct f where Source #

Construction of separated values.

Minimal complete definition

(+-), (-+), empty

Methods

(+-) :: s -> a -> f s a infixl 9 Source #

(-+) :: s -> a -> f a s Source #

empty :: f s a Source #

Instances

Construct Pesarated Source #

One element and one separator.

>>> (7 -+ "abc") :: Pesarated String Int
[7,"abc"]
>>> 7 -: "abc" -: (8 -+ "def") :: Pesarated String Int
[7,"abc",8,"def"]

Methods

(+-) :: s -> a -> Pesarated s a Source #

(-+) :: s -> a -> Pesarated a s Source #

empty :: Pesarated s a Source #

Construct Separated Source #

One element and one separator.

>>> (7 +- "abc") :: Separated Int String
[7,"abc"]
>>> 7 +: "abc" +: (8 +- "def") :: Separated Int String
[7,"abc",8,"def"]

Methods

(+-) :: s -> a -> Separated s a Source #

(-+) :: s -> a -> Separated a s Source #

empty :: Separated s a Source #

class Sprinkle f where Source #

Generalised interspersion

Minimal complete definition

sprinkle

Methods

sprinkle :: s -> [a] -> f s a Source #

Instances

Sprinkle Pesarated Source # 

Methods

sprinkle :: s -> [a] -> Pesarated s a Source #

Sprinkle Separated1 Source # 

Methods

sprinkle :: s -> [a] -> Separated1 s a Source #

Sprinkle Separated Source # 

Methods

sprinkle :: s -> [a] -> Separated s a Source #

skrinpleMay :: s -> [a] -> Maybe (Pesarated1 s a) Source #

class (f ~ SeparatedConsF g, g ~ SeparatedConsG f) => SeparatedCons f g where Source #

Prepend a value to a separated-like structure.

Minimal complete definition

(+:)

Associated Types

type SeparatedConsF g :: * -> * -> * Source #

type SeparatedConsG f :: * -> * -> * Source #

Methods

(+:) :: a -> f b a -> g a b infixr 5 Source #

Instances

SeparatedCons Separated1 Separated Source # 

Associated Types

type SeparatedConsF (Separated :: * -> * -> *) :: * -> * -> * Source #

type SeparatedConsG (Separated1 :: * -> * -> *) :: * -> * -> * Source #

Methods

(+:) :: a -> Separated1 b a -> Separated a b Source #

SeparatedCons Separated Separated1 Source # 

Associated Types

type SeparatedConsF (Separated1 :: * -> * -> *) :: * -> * -> * Source #

type SeparatedConsG (Separated :: * -> * -> *) :: * -> * -> * Source #

Methods

(+:) :: a -> Separated b a -> Separated1 a b Source #

class (f ~ PesaratedConsF g, g ~ PesaratedConsG f) => PesaratedCons f g where Source #

Prepend a value to a separated-like structure.

Minimal complete definition

(-:)

Associated Types

type PesaratedConsF g :: * -> * -> * Source #

type PesaratedConsG f :: * -> * -> * Source #

Methods

(-:) :: b -> f b a -> g a b infixr 5 Source #

Instances

PesaratedCons Pesarated1 Pesarated Source # 

Associated Types

type PesaratedConsF (Pesarated :: * -> * -> *) :: * -> * -> * Source #

type PesaratedConsG (Pesarated1 :: * -> * -> *) :: * -> * -> * Source #

Methods

(-:) :: b -> Pesarated1 b a -> Pesarated a b Source #

PesaratedCons Pesarated Pesarated1 Source # 

Associated Types

type PesaratedConsF (Pesarated1 :: * -> * -> *) :: * -> * -> * Source #

type PesaratedConsG (Pesarated :: * -> * -> *) :: * -> * -> * Source #

Methods

(-:) :: b -> Pesarated b a -> Pesarated1 a b Source #

Appending

class Appends a b c | a b -> c where Source #

Append two to make one.

Minimal complete definition

(<++>)

Methods

(<++>) :: a -> b -> c infixr 5 Source #

Instances

Appends (Separated1 a s) (Separated s a) (Separated1 a s) Source #

Append a list of pairs of separator and element values to element values interspersed with a separator.

>>> (singleSeparated 7 :: Separated1 Int Char) <++> (emptySeparated :: Separated Char Int)
[7]
>>> (singleSeparated 6 :: Separated1 Int Char) <++> 'x' +: 7 +: (emptySeparated :: Separated Char Int)
[6,'x',7]
>>> 'w' +: (singleSeparated 6 :: Separated1 Int Char) <++> 'x' +: 7 +: (emptySeparated :: Separated Char Int)
['w',6,'x',7]

Methods

(<++>) :: Separated1 a s -> Separated s a -> Separated1 a s Source #

Appends (Separated1 s a) (Separated1 a s) (Separated s a) Source #

Append two lists of separated values to produce a list of pairs of separator and element values.

>>> (singleSeparated 7 :: Separated1 Int Char) <++> (singleSeparated 'a' :: Separated1 Char Int)
[7,'a']

a +: (singleSeparated 7 :: Separated1 Int Char) ++ (singleSeparated b :: Separated1 Char Int) [a,7,b]

a +: (b :: Separated Int Int) == a +: b --  (a +: (b <++> c)) == ((a +: b) <++> c)

Methods

(<++>) :: Separated1 s a -> Separated1 a s -> Separated s a Source #

Appends (Separated s a) (Separated1 s a) (Separated1 s a) Source #

Append element values interspersed with a separator to a list of pairs of separator and element values.

>>> (emptySeparated :: Separated Int Char) <++> (singleSeparated 7 :: Separated1 Int Char)
[7]
>>> (emptySeparated :: Separated Int Char) <++> 6 +: 'x' +: (singleSeparated 7 :: Separated1 Int Char)
[6,'x',7]
>>> 'w' +: (emptySeparated :: Separated Int Char) <++> 6 +: 'x' +: (singleSeparated 7 :: Separated1 Int Char)
['w',6,'x',7]

Methods

(<++>) :: Separated s a -> Separated1 s a -> Separated1 s a Source #

Alternating

separatedBy :: Alternative f => f a -> f b -> f (Separated a b) Source #

Alternate separated values e.g. `f ~ Parser`.

>>> parse (separatedBy (char ',') digit) "test" ""
Right []
>>> isLeft (parse (separatedBy (char ',') digit) "test" ",")
True
>>> parse (separatedBy (char ',') digit) "test" ",1"
Right [',','1']
>>> isLeft (parse (separatedBy (char ',') digit) "test" ",1,")
True
>>> parse (separatedBy (char ',') digit) "test" ",1,2,3,4,5"
Right [',','1',',','2',',','3',',','4',',','5']

separatedBy1 :: Alternative f => f b -> f a -> f (Separated1 b a) Source #

Alternate separated values e.g. `f ~ Parser`.

>>> isLeft (parse (separatedBy1 (char ',') digit) "test" "")
True
>>> parse (separatedBy1 (char ',') digit) "test" ","
Right [',']
>>> isLeft (parse (separatedBy1 (char ',') digit) "test" ",1")
True
>>> parse (separatedBy1 (char ',') digit) "test" ",1,"
Right [',','1',',']
>>> parse (separatedBy1 (char ',') digit) "test" ",1,2,3,4,5,"
Right [',','1',',','2',',','3',',','4',',','5',',']

pesaratedBy :: Alternative f => f a -> f b -> f (Pesarated b a) Source #

Alternate separated values e.g. `f ~ Parser`.

>>> parse (pesaratedBy (char ',') digit) "test" ""
Right []
>>> isLeft (parse (pesaratedBy (char ',') digit) "test" ",")
True
>>> parse (separatedBy (char ',') digit) "test" ",1"
Right [',','1']
>>> isLeft (parse (pesaratedBy (char ',') digit) "test" ",1,")
True
>>> parse (pesaratedBy (char ',') digit) "test" ",1,2,3,4,5"
Right [',','1',',','2',',','3',',','4',',','5']

pesaratedBy1 :: Alternative f => f b -> f a -> f (Pesarated1 a b) Source #

Alternate separated values e.g. `f ~ Parser`.

>>> isLeft (parse (pesaratedBy1 (char ',') digit) "test" "")
True
>>> parse (pesaratedBy1 (char ',') digit) "test" ","
Right [',']
>>> isLeft (parse (pesaratedBy1 (char ',') digit) "test" ",1")
True
>>> parse (pesaratedBy1 (char ',') digit) "test" ",1,"
Right [',','1',',']
>>> parse (pesaratedBy1 (char ',') digit) "test" ",1,2,3,4,5,"
Right [',','1',',','2',',','3',',','4',',','5',',']