[Haskell-cafe] Unicode pretty-printing
gromopetr at gmail.com
Sat Aug 28 18:07:55 EDT 2010
I've been considering using Haskell for my natural language processing
project. Due to its nature, it has much to do with Unicode.
Unfortunately, Haskell escapes UTF8 characters. I've been able to
output these strings via System.IO.UTF8.putStrLn (though I wish it was
less painful), but still there are two problems.
First, I want to pretty-print not only strings, but any structures
made of lists and algebraic data types. Their 'show' calls string's
'show' which escapes all UTF8 symbols.
The second problem is that I'm not the only one who wants to output
the structures. For example, I want to have tests which check that
certain operations produce certain natural language strings. So, I
considered using HUnit for that. When its assertEqual fails, it
displays the expected versus actual data, which is fine. But, of
course, it doesn't know anything about Unicode, and I can't read
escaped strings very well to understand what exactly has failed. I
really don't want to write yet another unit test framework only for
the sake of UTF8. Is there any way to make Haskell display values
containing Unicode strings in a readable way?
More information about the Haskell-Cafe