Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Christopher Done
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

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Roman Cheplyaka
* 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.

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Simon Hengel
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

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Simon Hengel
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

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Roman Cheplyaka
* 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

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Yves Parès
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: {-#

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Simon Hengel
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

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Simon Hengel
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

Re: [Haskell-cafe] Type classes for converting to Text and String

2012-03-08 Thread Roman Cheplyaka
* 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