I discovered monads after writing a parser for org-mode and thinking there must be a better way.
It will have wonderful documentation at some point, once the Org Parser is complete so I know it quite well. For now, how a look at syntax.org in that project.
(def (HEADLINE (min-depth 1))
(.let* ((s (STARS min-depth)) (k TODO-KEYWORD) (p PRIORITY)
(c COMMENT)
(title TITLE) (tags (.or (.begin0 TAGS (skip WS) EOL)
(.begin EOL #f))))
['headline (list stars: s todo-keyword: k priority: p
title: (list->string title) tags: tags
commented?2: c footnote-section?: (footnote-section? title)
archived?: (archived? tags))]))
(defun smug-gerbil-syntax ()
(interactive)
(gerbil-put-indent '(.begin .or .any) 0)
(gerbil-put-indent '(.let* .begin0) 1)
(gerbil-fontlock-add
(cons
(concat
"(" (regexp-opt '(".let*" ".begin" ".begin0" ".or" ".any" ".not")
t)
"\\>")
'(1 'font-lock-keyword-face ))))
(add-hook 'gerbil-mode-hook 'smug-gerbil-syntax)