-- | Make the right hand side dependent if it's flat, otherwise
-- newline it.
dependOrNewline
  :: Pretty ast
  => Printer t ()
  -> ast NodeInfo
  -> (ast NodeInfo -> Printer t ())
  -> Printer t ()
dependOrNewline left right f =
  do (fits,st) <- fitsOnOneLine (depend left (f right))
     if fits
        then put st
        else do left
                newline
                (f right)
dependOrNewline
  :: Pretty ast
  => Printer t ()
  -> ast NodeInfo
  -> (ast NodeInfo -> Printer t ())
  -> Printer t ()
dependOrNewline left right f =
  do (fits,st) <- fitsOnOneLine (depend left (f right))
     if fits
        then put st
        else do left
                newline
                (f right)
dependOrNewline left right f =
  do (fits,st) <- fitsOnOneLine (depend left (f right))
     if fits
        then put st
        else do left
                newline
                (f right)