
8 Mar
2012
8 Mar
'12
4:53 a.m.
Hi! 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 (I use this with newtype wrapped value types backed by Text or ByteString.) So I wonder whether it would be a good idea to have a package that provides those classes. Or maybe just ToText, and provide default implementations of toString and toText, like: class ToText a where toText :: a -> Text toText = Text.pack . toString toString :: a -> String toString = Text.unpack . toText How do you guys deal with that? Any thoughts? Cheers, Simon