descriptive-0.9.0: 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) 
Data a => Data (Doc a) 
Show a => Show (Doc a) 
Typeable (* -> *) Doc