> One solution to this might be to parameterise the Doc type over
> the type of the elements it is describing the layout of. (Doing this
> has other benefits than just solving the above.)

That's a good idea but it has some consequences: currently <+> and $$
fall back on TextDetails, because they silently insert spaces. So one
cannot simply abstract TextDetails away. Either one introduces a class
along

        class Text text where
                spaces :: Int -> text
                ...

or one takes provisions for intra-line spacing extending fullRender'
type signature

        fullRender :: Mode
                   -> Int                       -- Line length
                   -> Float                     -- Ribbons per line
                   -> (text -> a -> a)          -- What to do with text
                   -> (Int -> a -> a)           -- What to do with spaces
                   -> a                         -- What to do at the end
                   -> Doc text
                   -> a                         -- Result

Cheers, Ralf

Reply via email to