descriptive-0.9.5: Self-describing consumers/parsers; forms, cmd-line args, JSON, etc.

Safe HaskellNone
LanguageHaskell98

Descriptive.JSON

Contents

Description

A JSON API which describes itself.

Synopsis

Consumers

parse Source #

Arguments

:: Monad m 
=> d

Description of what it expects.

-> (a -> StateT s m (Maybe b))

Attempt to parse the value.

-> Consumer s d m a

Consumer to add validation to.

-> Consumer s d m b

A new validating consumer.

Parse from a consumer.

object Source #

Arguments

:: Monad m 
=> Text

Description of what the object is.

-> Consumer Object (Doc d) m a

An object consumer.

-> Consumer Value (Doc d) m a 

Consume an object.

key Source #

Arguments

:: Monad m 
=> Text

The key to lookup.

-> Consumer Value (Doc d) m a

A value consumer of the object at the key.

-> Consumer Object (Doc d) m a 

Consume from object at the given key.

keyMaybe Source #

Arguments

:: Monad m 
=> Text

The key to lookup.

-> Consumer Value (Doc d) m a

A value consumer of the object at the key.

-> Consumer Object (Doc d) m (Maybe a) 

Optionally consume from object at the given key, only if it exists.

array Source #

Arguments

:: Monad m 
=> Text

Description of this array.

-> Consumer Value (Doc d) m a

Consumer for each element in the array.

-> Consumer Value (Doc d) m (Vector a) 

Consume an array.

string Source #

Arguments

:: Monad m 
=> Text

Description of what the string is for.

-> Consumer Value (Doc d) m Text 

Consume a string.

integer Source #

Arguments

:: Monad m 
=> Text

Description of what the integer is for.

-> Consumer Value (Doc d) m Integer 

Consume an integer.

double Source #

Arguments

:: Monad m 
=> Text

Description of what the double is for.

-> Consumer Value (Doc d) m Double 

Consume an double.

bool Source #

Arguments

:: Monad m 
=> Text

Description of what the bool is for.

-> Consumer Value (Doc d) m Bool 

Parse a boolean.

null Source #

Arguments

:: Monad m 
=> Text

What the null is for.

-> Consumer Value (Doc d) m () 

Expect null.

Annotations

label Source #

Arguments

:: Monad m 
=> d

Some label.

-> Consumer s (Doc d) m a

A value consumer.

-> Consumer s (Doc d) m a 

Wrap a consumer with a label e.g. a type tag.

Description

data Doc a Source #

Description of parseable things.

Instances
Eq a => Eq (Doc a) Source # 
Instance details

Defined in Descriptive.JSON

Methods

(==) :: Doc a -> Doc a -> Bool #

(/=) :: Doc a -> Doc a -> Bool #

Data a => Data (Doc a) Source # 
Instance details

Defined in Descriptive.JSON

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Doc a -> c (Doc a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Doc a) #

toConstr :: Doc a -> Constr #

dataTypeOf :: Doc a -> DataType #

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

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

gmapT :: (forall b. Data b => b -> b) -> Doc a -> Doc a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doc a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doc a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Doc a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Doc a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Doc a -> m (Doc a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Doc a -> m (Doc a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Doc a -> m (Doc a) #

Show a => Show (Doc a) Source # 
Instance details

Defined in Descriptive.JSON

Methods

showsPrec :: Int -> Doc a -> ShowS #

show :: Doc a -> String #

showList :: [Doc a] -> ShowS #