module JSONIncrementalDecoder.SupplementedParsers
where
import JSONIncrementalDecoder.Prelude
import JSONIncrementalDecoder.Parsers as Parsers
import Data.Attoparsec.ByteString.Char8
object :: Supplemented Parser a -> Supplemented Parser a
object body =
essence openingParser *> body <* supplement closingParser
where
openingParser =
char '{' *> skipSpace
closingParser =
skipSpace <* char '}'
array :: Supplemented Parser a -> Supplemented Parser a
array body =
essence (char '[' *> skipSpace) *> body <* supplement (skipSpace <* char ']')
row :: (a -> b -> c) -> Supplemented Parser a -> Supplemented Parser b -> Supplemented Parser c
row fn field value =
fn <$> (field <* supplement Parsers.colon) <*> value
comma :: Supplemented Parser ()
comma =
supplement Parsers.comma
null :: Supplemented Parser ()
null =
essence Parsers.null
stringLit :: Supplemented Parser Text
stringLit =
essence Parsers.stringLitAsText
anyValue :: Supplemented Parser ()
anyValue =
supplement skipJSONLit
anyRow :: Supplemented Parser ()
anyRow =
supplement skipObjectRow
anyRows :: Supplemented Parser ()
anyRows =
supplement $
skipSepBy Parsers.skipObjectRow Parsers.comma