[Haskell-cafe] Unicode pretty-printing

Don Stewart dons at galois.com
Sat Aug 28 18:33:21 EDT 2010


gromopetr:
> Hi all,
> 
> 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.

How about a "Pretty" class for unicode text:
http://hackage.haskell.org/package/text

That might be easy to write.
  
> 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?

Via a new pretty class, similar to Show, but rendering Text values.


More information about the Haskell-Cafe mailing list