GenI-0.24.2: A natural language generator (specifically, an FB-LTAG surface realiser)

Safe HaskellNone



This is not a proper pretty printer. I aim is to replace this with a (de-facto) standard library if one should appear



class Pretty a whereSource

An alternative Show instance (the idea being that we should reserve Show for outputting actual Haskell)

Minimal implementation is pretty or prettyStr


pretty :: a -> TextSource

prettyStr :: a -> StringSource


Pretty Int 
Pretty Integer 
Pretty String 
Pretty Text 
Pretty PolarityKey 
Pretty GeniVal 
Pretty SemInput 
Pretty Sem 
Pretty LexCombineError2 
Pretty LexCombineError 
Pretty LexEntry 
Pretty GenStatus 
Pretty RankedOtConstraint 
Pretty OtConstraint 
Pretty GeniError 
Pretty [TagSite] 
Pretty (FeatStruct GeniVal) 
Pretty (AvPair GeniVal) 
Pretty (Flist GeniVal) 
Pretty (Literal GeniVal) 
Pretty (GNode GeniVal)

The default show for GNode tries to be very compact; it only shows the value for cat attribute and any flags which are marked on that node.

This is one the places where the pretty representation of a GenI object is different from its GenI-format one

GeniShow sem => Pretty (TestCase sem) 

(<>) :: Monoid m => m -> m -> m

An infix synonym for mappend.

(<+>) :: Text -> Text -> TextSource

Separated by space unless one of them is empty (in which case just the non-empty one)

above :: Text -> Text -> TextSource

I think I want ($+$) here but I'm not sure I understand the documentation from the pretty package.

t1 above t2 separates the two by a newline, unless one of them is empty. The vertical equivalent to '(+)'

between :: Text -> Text -> Text -> TextSource

between l r t == l  t  r

parens :: Text -> TextSource

parens t puts t between parentheses (())

squares :: Text -> TextSource

squares t puts t between square brackets ([])

squeezed :: Int -> [Text] -> TextSource

Puts list items on the same line if they are smaller than a certain width otherwise, puts a newline in between them

prettyCount :: (a -> Text) -> Text -> (a, Int) -> TextSource

 prettyCount toBlah ""     (x,1) == "blah"
 prettyCount toBlah "foos" (x,1) == "blah"
 prettyCount toBlah ""     (x,4) == "blah ×4"
 prettyCount toBlah "foos" (x,4) == "blah ×4 foos"