sexpr-0.2.0: S-expression printer and parserSource codeContentsIndex
Hinted Atoms
Character predicates to support encoding
String printers
ShowS printers
Doc pretty printers
Put binary printers
A Sexpr is an S-expressionin the style of Rivest's Canonical S-expressions. Atoms may be of any type, but String and ByteString have special support. Rivest's implementation of S-expressions is unusual in supporting MIME type hints for each atom. See
data Sexpr s
isAtom :: Sexpr a -> Bool
isList :: Sexpr a -> Bool
atom :: a -> Sexpr a
list :: [Sexpr a] -> Sexpr a
unAtom :: Sexpr s -> s
unList :: Sexpr s -> [Sexpr s]
hintedAtom :: String -> a -> Sexpr a
hint :: Sexpr a -> Maybe String
defaultHint :: String
isTokenChar :: Char -> Bool
isInitialTokenChar :: Char -> Bool
isQuoteableChar :: Char -> Bool
fold :: (Sexpr t -> Sexpr t) -> Sexpr t -> Sexpr t
canonicalString :: Sexpr String -> String
basicString :: Sexpr String -> String
advancedString :: Sexpr String -> String
canonical :: Sexpr String -> ShowS
basic :: Sexpr String -> Doc
advanced :: Sexpr String -> Doc
putCanonical :: Sexpr String -> Put
putCanonicalBS :: Sexpr ByteString -> Put
readSexpr :: Read a => String -> Sexpr a
readSexprString :: String -> Sexpr String
readCanonicalSexprString :: String -> Sexpr String
advancedSexpr :: ReadP (Sexpr String)
canonicalSexpr :: ReadP (Sexpr String)
data Sexpr s Source
show/hide Instances
isAtom :: Sexpr a -> BoolSource
A predicate for identifying atoms, whether or not they have explicit hints.
isList :: Sexpr a -> BoolSource
A predicate for recognizing lists.
atom :: a -> Sexpr aSource
Construct an atom.
list :: [Sexpr a] -> Sexpr aSource
Construct a list.
unAtom :: Sexpr s -> sSource
Extract the content of an atom, discarding any MIME type hint.
unList :: Sexpr s -> [Sexpr s]Source
Extract the sub-S-expressions of a List. If all you intend to do is traverse or map over that list, the Functor instance of S-expressions may work just fine.
Hinted Atoms
hintedAtom :: String -> a -> Sexpr aSource
Construct an atom with a MIME type hint. hintedAtom defaultHint == atom
hint :: Sexpr a -> Maybe StringSource
Extract the hint of an atom. Lists do not have hints, but all atoms have hints.
defaultHint :: StringSource
Any atom whose hint is not specified is assumed to be text/plain; charset=iso-8859-1. This is that default value.
Character predicates to support encoding
isTokenChar :: Char -> BoolSource
Tokens may internally contain any of the characters legitimate to begin tokens, or any numeral.
isInitialTokenChar :: Char -> BoolSource
Tokens may begin with any alphabetic character or the characters in -./_:*+= ;
isQuoteableChar :: Char -> BoolSource
Only token characters and spaces don't need to be escaped when shown in the quoted syntax.
fold :: (Sexpr t -> Sexpr t) -> Sexpr t -> Sexpr tSource
fold f s applies f to each sub-S-expression of s, from each leaf to the root. f need not preserve the shape of s, in contrast to the shape-preserving Traversable instance.
String printers
canonicalString :: Sexpr String -> StringSource
basicString :: Sexpr String -> StringSource
advancedString :: Sexpr String -> StringSource
ShowS printers
canonical :: Sexpr String -> ShowSSource
Doc pretty printers
basic :: Sexpr String -> DocSource
advanced :: Sexpr String -> DocSource
Put binary printers
putCanonical :: Sexpr String -> PutSource
putCanonicalBS :: Sexpr ByteString -> PutSource
readSexpr :: Read a => String -> Sexpr aSource
Read a Sexpr a using the Read instance for a. The Sexpr may be in any encoding: Canonical, Basic, or Advanced.
readSexprString :: String -> Sexpr StringSource
Read a Sexpr String in any encoding: Canonical, Basic, or Advanced.
readCanonicalSexprString :: String -> Sexpr StringSource
Read a Sexpr String in canonical encoding.
advancedSexpr :: ReadP (Sexpr String)Source
canonicalSexpr :: ReadP (Sexpr String)Source
For some applications it is wise to accept only very carefully specified input. This is useful when you know you are receiving exactly a Canonical S-Expression. It will read only a Canonical S-expression (and optional terminating NUL), but not the Basic or Advanced encodings.
Produced by Haddock version 2.4.2