s-cargot-0.1.3.0: A flexible, extensible s-expression library.

Safe HaskellNone
LanguageHaskell2010

Data.SCargot.Atom

Synopsis

Documentation

This module defines small convenience functions for building an atom type from several individual parsers. This is easy to do without these functions, but these functions communicate intent more directly:

data Atom
  = Ident Text
  | Num Integer

myParser :: SExprParser Atom (SExpr Atom)
myParser = mkAtomParser
  [ atom Ident parseR7RSIdent
  , atom Num   signedDecNumber
  ]

atom :: (t -> atom) -> Parser t -> Parser atom Source #

A convenience function for defining an atom parser from a wrapper function and a parser. This is identical to fmap specialized to operate over Parser values, and is provided as sugar.

mkAtomParser :: [Parser atom] -> SExprParser atom (SExpr atom) Source #

A convenience function for defining a SExprSpec from a list of possible atom parsers, which will be tried in sequence before failing.