[Haskell-cafe] Type classes for converting to Text and String
roma at ro-che.info
Thu Mar 8 13:40:00 CET 2012
* Simon Hengel <sol at typeful.net> [2012-03-08 13:20:22+0100]
> On Thu, Mar 08, 2012 at 12:54:13PM +0200, Roman Cheplyaka wrote:
> > * Simon Hengel <sol at typeful.net> [2012-03-08 11:48:41+0100]
> > > On Thu, Mar 08, 2012 at 12:18:56PM +0200, Roman Cheplyaka wrote:
> > > > If it's fine to depend on FunDeps, you can use ListLike.
> > > > http://hackage.haskell.org/package/ListLike
> > >
> > > How would that help with toText?
> > toText = fromListLike
> > (ListLike instance for Text is provided by the listlike-instances
> > package.)
> Ah, the listlike-instances package is the missing piece.
> Not sure if this is going somewhere. But I'm still trying to get a
> clear picture of the performance implications.
> Say I have a newtype-wrapped ByteString that I would decode to
> String/Text using UTF-8:
> newtype Value = Value ByteString
> Would it be possible to go from Value to Text by essentially ending up
> with Data.Text.Encoding.decodeUtf8 at runtime (e.g. by using rewrite
You can do that, but it will work only if your functions are specialized
enough at compile time.
Roman I. Cheplyaka :: http://ro-che.info/
More information about the Haskell-Cafe