default instance for IsString

Greg Weber greg at
Mon Apr 23 20:15:47 CEST 2012

On Mon, Apr 23, 2012 at 9:58 AM, Yitzchak Gale <gale at> wrote:
> Jeremy Shaw wrote:
>>> I have often wished for something like:
>>>     {-# LANGUAGE StringLiteralsAs Text #-}
>>> where all string literals like:
>>>     f = "foo"
>>> would be translated to:
>>>     f = (fromString "foo" :: Text)
> Agreed, I would also really like this.
>>> I find that OverloadedStrings is too general and causes ambiguous type
>>> errors. Additionally, I seldom find that I have more than one type of
>>> string literal per file. Things tend to be all String, all Text, etc.
>>> So, if I could just pick a concrete type for all the string literals
>>> in my file, I would be happy.
> In addition, OverloadedStrings is unsound. Library authors can,
> and do, write unsafe implementations of IsString that cause
> syntax errors to be caught only at run time instead of at
> compile time. That is the opposite of one of the most
> important things we are trying to accomplish by using
> Haskell instead of, say, some dynamically typed language.
> Greg Weber wrote:
>> You can default a String. So this compiles just fine:
>> {-# LANGUAGE OverloadedStrings #-}
>> {-# LANGUAGE ExtendedDefaultRules #-}
>> import Data.Text as T
>> default (T.Text)
> No, I do not want string literals to be polymorphic, even
> if there is some kind of defaulting. I want them to be
> monomorphic, as they always have been. But I still
> want to be able to specify to the compiler somehow
> that the monomorphic type for string literals in a
> particular module should be something other than
> String.
> Thanks,
> Yitz

Hi Yitz,

I very much agree with you. However, when we complain about something
essentially we are asking others to prioritize it ahead of other
things. I don't think any more visibility of this issue is going to
improve its prioritization. I suspect your only way forward right now
is to start implementing something yourself.

More information about the Glasgow-haskell-users mailing list