surrounding quotes w/ newtypes of Text/String
Short description
Currently, strings and chars are interpolated without surrounding quotes (which is a very good thing). It would be nice to have the same behaviour for types which are newtypes of Text/String/Char.
Longer description
Consider this code:
let foo :: Text
foo = "foobar"
in putTextLn [i|result: #{foo}|]
Later, one might decide to introduce a newtype for foo:
newtype Foo = Foo Text
deriving newtype (Show)
Now, this slightly modified code still compiles, but it includes (usually unwanted) surrounding quotes:
let foo :: Foo
foo = Foo "foobar"
in putTextLn [i|result: #{foo}|]
Possible solutions
- Detect if a type is
Coercible Text(orCoercible Stringetc.), and remove quotes if that is the case. - Introduce further variations of
iwhich only accept types which areCoercible Textetc. - Emit appropriate warnings (is that even possible?) if a newtype of
Textetc. is interpolated.
I am happy to help implementing something like this, but as I have close to zero knowledge of TH, it might take some time.
Edited by amesgen