json-incremental-decoder-0.1.0.3: Incremental JSON parser with early termination and a declarative DSL

Safe HaskellNone
LanguageHaskell2010

JSONIncrementalDecoder

Contents

Description

A DSL for specification of a single-pass incremental and possibly partial parser of JSON.

Synopsis

Execution

valueToSupplementedParser :: Value a -> Supplemented Parser a Source

Converts the Value specification into a Supplemented Attoparsec Parser.

valueToParser :: Value a -> Parser (a, Parser ()) Source

Essentially just a helper, which is the same as

runSupplemented . valueToSupplementedParser

valueToByteStringToEither :: Value a -> ByteString -> Either Text a Source

Converts the Value specification into a function, which decodes a strict ByteString.

valueToLazyByteStringToEither :: Value a -> ByteString -> Either Text a Source

Converts the Value specification into a function, which decodes a strict LazyByteString.

Value

data Value a Source

Instances

Functor Value Source 
Monoid (Value a) Source

Provides support for alternatives.

E.g,

fmap Left bool <> fmap Right string

will succeed for either a Boolean or String value.

ObjectRows

row :: (a -> b -> c) -> Matcher Text a -> Value b -> ObjectRows c Source

ObjectLookup

ArrayElements

Matcher

data Matcher a b :: * -> * -> *

A composable abstraction for checking or converting a context value.

equals :: Eq a => a -> Matcher a ()

Tests the matched value on equality with the provided value.

satisfies :: (a -> Bool) -> Matcher a ()

Checks whether the matched value satisfies the provided predicate.

converts :: (a -> Either Text b) -> Matcher a b

Tries to convert the matched value to an output value, with Either encoding the success or failure of the conversion.

whatever :: Matcher a ()

The matcher, which is always satisfied.