On 8 March 2012 10:53, Simon Hengel s...@typeful.net wrote:
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
class ToString a where
toString :: a - String
class ToText a where
toText :: a - Text
Text
* Simon Hengel s...@typeful.net [2012-03-08 10:53:15+0100]
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
[...]
How do you guys deal with that? Any thoughts?
If it's fine to depend on FunDeps, you can use ListLike.
On Thu, Mar 08, 2012 at 11:00:34AM +0100, Christopher Done wrote:
On 8 March 2012 10:53, Simon Hengel s...@typeful.net wrote:
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
class ToString a where
toString
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?
Cheers,
Simon
___
Haskell-Cafe mailing list
* Simon Hengel s...@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
If you just need to go back and forth from String to Text, why do you need
to be generic? pack and unpack from Data.Text do the job.
Plus, in the way of what Christopher said, you can use the
OverloadedStrings extension. You can then use the string syntax at a place
that expects a text:
{-#
On Thu, Mar 08, 2012 at 12:37:31PM +0100, Yves Parès wrote:
If you just need to go back and forth from String to Text, why do you need
to be generic? pack and unpack from Data.Text do the job.
Always going through String or Text may (depending on what your
underlying representation is) be less
On Thu, Mar 08, 2012 at 12:54:13PM +0200, Roman Cheplyaka wrote:
* Simon Hengel s...@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
* Simon Hengel s...@typeful.net [2012-03-08 13:20:22+0100]
On Thu, Mar 08, 2012 at 12:54:13PM +0200, Roman Cheplyaka wrote:
* Simon Hengel s...@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