waargonaut-0.8.0.2: JSON wrangling
Safe HaskellNone
LanguageHaskell2010

Waargonaut.Types.CommaSep.Elem

Contents

Description

Data structures and functions for managing a single element in a CommaSeparated structure.

Synopsis

Types

data Elem f ws a Source #

Data type to represent a single element in a CommaSeparated list. Carries information about it's own trailing whitespace. Denoted by the f.

Constructors

Elem 

Fields

Instances

Instances details
Traversable f => Bitraversable (Elem f) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

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

Foldable f => Bifoldable (Elem f) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

bifold :: Monoid m => Elem f m m -> m #

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

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Elem f a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Elem f a b -> c #

Functor f => Bifunctor (Elem f) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

bimap :: (a -> b) -> (c -> d) -> Elem f a c -> Elem f b d #

first :: (a -> b) -> Elem f a c -> Elem f b c #

second :: (b -> c) -> Elem f a b -> Elem f a c #

Functor (Elem f ws) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

fmap :: (a -> b) -> Elem f ws a -> Elem f ws b #

(<$) :: a -> Elem f ws b -> Elem f ws a #

(Monoid ws, Applicative f) => Applicative (Elem f ws) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

pure :: a -> Elem f ws a #

(<*>) :: Elem f ws (a -> b) -> Elem f ws a -> Elem f ws b #

liftA2 :: (a -> b -> c) -> Elem f ws a -> Elem f ws b -> Elem f ws c #

(*>) :: Elem f ws a -> Elem f ws b -> Elem f ws b #

(<*) :: Elem f ws a -> Elem f ws b -> Elem f ws a #

Foldable (Elem f ws) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

fold :: Monoid m => Elem f ws m -> m #

foldMap :: Monoid m => (a -> m) -> Elem f ws a -> m #

foldMap' :: Monoid m => (a -> m) -> Elem f ws a -> m #

foldr :: (a -> b -> b) -> b -> Elem f ws a -> b #

foldr' :: (a -> b -> b) -> b -> Elem f ws a -> b #

foldl :: (b -> a -> b) -> b -> Elem f ws a -> b #

foldl' :: (b -> a -> b) -> b -> Elem f ws a -> b #

foldr1 :: (a -> a -> a) -> Elem f ws a -> a #

foldl1 :: (a -> a -> a) -> Elem f ws a -> a #

toList :: Elem f ws a -> [a] #

null :: Elem f ws a -> Bool #

length :: Elem f ws a -> Int #

elem :: Eq a => a -> Elem f ws a -> Bool #

maximum :: Ord a => Elem f ws a -> a #

minimum :: Ord a => Elem f ws a -> a #

sum :: Num a => Elem f ws a -> a #

product :: Num a => Elem f ws a -> a #

Traversable (Elem f ws) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Elem f ws a -> f0 (Elem f ws b) #

sequenceA :: Applicative f0 => Elem f ws (f0 a) -> f0 (Elem f ws a) #

mapM :: Monad m => (a -> m b) -> Elem f ws a -> m (Elem f ws b) #

sequence :: Monad m => Elem f ws (m a) -> m (Elem f ws a) #

(Eq1 f, Eq ws, Eq a) => Eq (Elem f ws a) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

(==) :: Elem f ws a -> Elem f ws a -> Bool #

(/=) :: Elem f ws a -> Elem f ws a -> Bool #

(Show1 f, Show ws, Show a) => Show (Elem f ws a) Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

showsPrec :: Int -> Elem f ws a -> ShowS #

show :: Elem f ws a -> String #

showList :: [Elem f ws a] -> ShowS #

HasElem (Elem f ws a) f ws a Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

elem :: Lens' (Elem f ws a) (Elem f ws a) Source #

elemTrailing :: Lens' (Elem f ws a) (f (Comma, ws)) Source #

elemVal :: Lens' (Elem f ws a) a Source #

class HasElem c f ws a | c -> f ws a where Source #

Typeclass for things that contain a single Elem structure.

Minimal complete definition

elem

Methods

elem :: Lens' c (Elem f ws a) Source #

elemTrailing :: Lens' c (f (Comma, ws)) Source #

elemVal :: Lens' c a Source #

Instances

Instances details
HasElem (Elem f ws a) f ws a Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

elem :: Lens' (Elem f ws a) (Elem f ws a) Source #

elemTrailing :: Lens' (Elem f ws a) (f (Comma, ws)) Source #

elemVal :: Lens' (Elem f ws a) a Source #

data Comma Source #

Unary type to represent a comma.

Constructors

Comma 

Instances

Instances details
Eq Comma Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

(==) :: Comma -> Comma -> Bool #

(/=) :: Comma -> Comma -> Bool #

Show Comma Source # 
Instance details

Defined in Waargonaut.Types.CommaSep.Elem

Methods

showsPrec :: Int -> Comma -> ShowS #

show :: Comma -> String #

showList :: [Comma] -> ShowS #

_ElemTrailingIso :: (Monoid ws, Monoid ws') => Iso (Elem Identity ws a) (Elem Identity ws' a') (Elem Maybe ws a) (Elem Maybe ws' a') Source #

Iso between an Elem that is not on the trailing element and one that is.

Parse

parseComma :: CharParsing f => f Comma Source #

Parse a single comma (,)

parseCommaTrailingMaybe :: CharParsing f => f ws -> f (Maybe (Comma, ws)) Source #

Parse an optional comma and its trailing whitespace.

>>> testparse (parseCommaTrailingMaybe parseWhitespace) ", "
Right (Just (Comma,WS [Space]))
>>> testparse (parseCommaTrailingMaybe parseWhitespace) " , "
Right Nothing
>>> testparse (parseCommaTrailingMaybe parseWhitespace) ",, "
Right (Just (Comma,WS []))