[Haskell-cafe] fromString and toString

Erik Hesselink hesselink at gmail.com
Wed Feb 5 09:35:26 UTC 2014


Show is usually valid Haskell (at least derived instances are), and
has instances for most types. This class would only be a conversion
from types that *are* strings in some sense (like Text) to String.

We have a (very small) package for this called 'isstring' that we use
internally. It has instances for String, Text (x2) and ByteString (x2)
assuming UTF8 encoding. I'd be happy to open source it if people are
interested.

Regards,

Erik

On Wed, Feb 5, 2014 at 9:13 AM, Atze van der Ploeg <atzeus at gmail.com> wrote:
> Isn't toString just show?
>
> On Feb 4, 2014 3:20 PM, "Johannes Waldmann" <waldmann at imn.htwk-leipzig.de>
> wrote:
>>
>> Ben Foppa <benjamin.foppa <at> gmail.com> writes:
>>
>> > But do we have an inverse generic function toString defined anywhere?
>>
>> well, we have:  class Show a where show :: a -> String
>>
>> > likereString :: (IsString a, IsString b) => a -> b
>>
>> well you probably don't want to actually convert from a to String
>> (= List of Char) then from there to b,
>> so it would need to be accompanied by some RULES
>> (for specific instances of a, b) for efficiency.
>>
>> This still does not answer the concern whether it is
>> (semantically) wise to have String as the "base" concept here.
>>
>> - J.W.
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list