Solves a very common issue of formatting values that can be shown:
ghci> import Text.Printf
ghci> newtype Issue = Issue Int deriving Show
ghci> printf "%s is valid: %s\n" (show (Issue 17)) (show True)
Issue 17 is valid: True
Using this you can write:
ghci> fprint (toText % " is valid: " % toText % "\n") (Issue 17) True
Issue 17 is valid: True
ghci> fprint (tt % " is valid: " % tt % "\n") (Issue 17) True
Issue 17 is valid: True
I chose the name toText since show is obviously taken, I thought about using repr for the long formatter as Python does but r is already taken as a short formatter. Alternatives welcome. It is included in text-format which chooses the name shown for the formatter which is also valid but a short form is not as obvious.
Solves a very common issue of formatting values that can be shown:
Using this you can write:
I chose the name
toText
sinceshow
is obviously taken, I thought about usingrepr
for the long formatter as Python does butr
is already taken as a short formatter. Alternatives welcome. It is included in text-format which chooses the nameshown
for the formatter which is also valid but a short form is not as obvious.