Преглед на файлове

Explanatory haddocks for Atom helpers

Getty Ritter преди 8 години
родител
ревизия
7e6b6269da
променени са 1 файла, в които са добавени 21 реда и са изтрити 1 реда
  1. 21 1
      Data/SCargot/Atom.hs

+ 21 - 1
Data/SCargot/Atom.hs

@@ -1,5 +1,7 @@
 module Data.SCargot.Atom
-  ( atom
+  ( -- $intro
+
+    atom
   , mkAtomParser
   ) where
 
@@ -18,3 +20,21 @@ atom = fmap
 --   possible atom parsers, which will be tried in sequence before failing.
 mkAtomParser :: [Parser atom] -> SExprParser atom (SExpr atom)
 mkAtomParser = mkParser . choice
+
+{- $intro
+
+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
+>   ]
+
+-}