[Haskell-cafe] Can we improve Show instance for non-ascii charcters?

Christopher Allen cma at bitemyapp.com
Thu Feb 4 04:45:53 UTC 2016


Can be useful in debugging, such as when dealing with visually identical
characters with different byte values. Having principally western
characters be rendered is a bit chauvinistic. This use case could be
addressed with a function that takes a list of byte ranges to be rendered
literally, others being the byte version. That would at least dispose if
one reason for opposing changing this.

On Wed, Feb 3, 2016 at 10:39 PM, Gershom B <gershomb at gmail.com> wrote:

> Backwards compatibility is important, but not an absolute. I’d be curious
> if anyone can point to instances where software might _rely_ on the show
> instance for strings not displaying unicode characters?
>
> —Gershom
>
>
> On February 3, 2016 at 5:03:58 PM, David Feuer (david.feuer at gmail.com)
> wrote:
> > There's one open now. thomie commented (
> > https://ghc.haskell.org/trac/ghc/ticket/11529#comment:4 ) that it's
> > possible to hook up your choice of showing function as the one GHCi
> should
> > use to display values. This strikes me as the best available approach
> > preserving backwards compatibility. Adding a GHCi flag for this might be
> > reasonable.
> >
> > On Wed, Feb 3, 2016 at 4:11 PM, Atze van der Ploeg wrote:
> >
> > > I think we can all agree these characters should be shown. Maybe a GHC
> bug
> > > report is a good idea?
> > > On 02/03/2016 10:37 AM, Takayuki Muranushi wrote:
> > > > I think one of the solution is to import and call u_iswprint from
> > > > GHC.Show, too,
> > > > but I don't know it's against any design choices.
> > >
> > > +1 for only escaping non-printable characters.
> > >
> > > > Yesterday, I had a chance to teach Haskell (in Japanese,) and I had
> to
> > > > use English in some of the most exciting examples, like the
> > > > Applicative List example above. I would heartedly like to see GHC
> > > > improve in these directions, so that we can make more happy learning
> > > > materials on Haskell.
> > >
> > > As a workaround, perhaps you can avoid using print/show with core data
> > > structures. Using your applicative example:
> > >
> > > > mapM_ putStrLn $ [(++"の父"), (++"の母")] <*> ["田中", "山田"]
> > > 田中の父
> > > 山田の父
> > > 田中の母
> > > 山田の母
> > >
> > > For other data structures, you can write your own Show instance:
> > >
> > > data Name = Name String String
> > >
> > > instance Show Name where
> > > show (Name family given) = family ++ given
> > >
> > > > print $ Person "山田" "太郎"
> > > 山田太郎
> > >
> > > Travis
> > > _______________________________________________
> > > Haskell-Cafe mailing list
> > > Haskell-Cafe at haskell.org
> > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> > >
> > > _______________________________________________
> > > Haskell-Cafe mailing list
> > > Haskell-Cafe at haskell.org
> > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> > >
> > >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> >
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>



-- 
Chris Allen
Currently working on http://haskellbook.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160203/3f504a01/attachment-0001.html>


More information about the Haskell-Cafe mailing list