default instance for IsString

Yitzchak Gale gale at
Mon Apr 23 18:58:34 CEST 2012

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


More information about the Glasgow-haskell-users mailing list