-- | Render an document to a string suitable for inclusion in HTML.
-- The HTML should use a monospaced font for the code.
render :: forall ann . (ann -> Text -> Text) -> POut Int ann -> Text
render renderAnnotation out = render' out
  where render' :: POut Int ann -> Text
        render' pout = case pout of
          PNull -> T.pack ""
          PAtom a -> renderAtom a
          PSeq o1 o2 -> render' o1 `T.append` render' o2
          PAnn a o -> renderAnnotation a $ render' o
render :: forall ann . (ann -> Text -> Text) -> POut Int ann -> Text
render renderAnnotation out = render' out
  where render' :: POut Int ann -> Text
        render' pout = case pout of
          PNull -> T.pack ""
          PAtom a -> renderAtom a
          PSeq o1 o2 -> render' o1 `T.append` render' o2
          PAnn a o -> renderAnnotation a $ render' o
render renderAnnotation out = render' out
  where render' :: POut Int ann -> Text
        render' pout = case pout of
          PNull -> T.pack ""
          PAtom a -> renderAtom a
          PSeq o1 o2 -> render' o1 `T.append` render' o2
          PAnn a o -> renderAnnotation a $ render' o