Add instance IsString ShowS where fromString = showString

View: New views
10 Messages — Rating Filter:   Alert me  

Add instance IsString ShowS where fromString = showString

by Bas van Dijk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

It would be really nice to use OverloadedStrings when constructing a
ShowS, for example in a definition of showsPrec in an instance for
Show.

The patch attached in the ticket[3544] adds the necessary instance to
base/GHC/Show.lhs:

instance IsString ShowS where
    fromString = showString

Note that this does require TypeSynonymInstances.

Discussion period 2 weeks.

regards,

Bas

[3544] http://hackage.haskell.org/trac/ghc/ticket/3544
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by Bas van Dijk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Sep 27, 2009 at 10:51 PM, Bas van Dijk <v.dijk.bas@...> wrote:

> Hello,
>
> It would be really nice to use OverloadedStrings when constructing a
> ShowS, for example in a definition of showsPrec in an instance for
> Show.
>
> The patch attached in the ticket[3544] adds the necessary instance to
> base/GHC/Show.lhs:
>
> instance IsString ShowS where
>    fromString = showString
>
> Note that this does require TypeSynonymInstances.
>
> Discussion period 2 weeks.
>
> regards,
>
> Bas
>
> [3544] http://hackage.haskell.org/trac/ghc/ticket/3544
>

Just a reminder for this proposal. One week has passed and one to go.

Any comments, +1 or -1?

regards,

Bas
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by Nicolas Pouillard-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Excerpts from Bas van Dijk's message of Mon Oct 05 09:27:07 +0200 2009:

> On Sun, Sep 27, 2009 at 10:51 PM, Bas van Dijk <v.dijk.bas@...> wrote:
> > Hello,
> >
> > It would be really nice to use OverloadedStrings when constructing a
> > ShowS, for example in a definition of showsPrec in an instance for
> > Show.
> >
> > The patch attached in the ticket[3544] adds the necessary instance to
> > base/GHC/Show.lhs:
> >
> > instance IsString ShowS where
> >    fromString = showString
> >
> > Note that this does require TypeSynonymInstances.
> >
> > Discussion period 2 weeks.
> >
> > regards,
> >
> > Bas
> >
> > [3544] http://hackage.haskell.org/trac/ghc/ticket/3544
> >
>
> Just a reminder for this proposal. One week has passed and one to go.
>
> Any comments, +1 or -1?

+1

--
Nicolas Pouillard
http://nicolaspouillard.fr
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

RE: Add instance IsString ShowS where fromString = showString

by Sittampalam, Ganesh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bas van Dijk wrote:

> Hello,
>
> It would be really nice to use OverloadedStrings when constructing a
> ShowS, for example in a definition of showsPrec in an instance for
> Show.  
>
> The patch attached in the ticket[3544] adds the necessary instance to
> base/GHC/Show.lhs:
>
> instance IsString ShowS where
>     fromString = showString
>
> Note that this does require TypeSynonymInstances.

-1 : I don't think it's appropriate to use a type synonym instance in a
standard library.

A concrete example of the problems this would cause is that it would
interfere with any generic function instance for IsString, e.g.

instance IsString b => IsString (a -> b) where
    fromString = const . fromString

I am not suggesting that such an instance is generally useful, but
people who wanted to use it in their own private code would be
obstructed from doing so by an instance for (String -> String).

Cheers,

Ganesh


===============================================================================
 Please access the attached hyperlink for an important electronic communications disclaimer:
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 ===============================================================================
 
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

RE: Add instance IsString ShowS where fromString = showString

by Duncan Coutts-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 2009-10-05 at 10:42 +0100, Sittampalam, Ganesh wrote:

> Bas van Dijk wrote:
> > Hello,
> >
> > It would be really nice to use OverloadedStrings when constructing a
> > ShowS, for example in a definition of showsPrec in an instance for
> > Show.  
> >
> > The patch attached in the ticket[3544] adds the necessary instance to
> > base/GHC/Show.lhs:
> >
> > instance IsString ShowS where
> >     fromString = showString
> >
> > Note that this does require TypeSynonymInstances.
>
> -1 : I don't think it's appropriate to use a type synonym instance in a
> standard library.

Strictly speaking it's not the type synonym that is worrying, it's the
need for flexible instances which then leads on to needing overlapping
and incoherent instances.

http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#instance-rules

> A concrete example of the problems this would cause is that it would
> interfere with any generic function instance for IsString, e.g.
>
> instance IsString b => IsString (a -> b) where
>     fromString = const . fromString

Right, then uses of fromString would require -XOverlappingInstances and
possibly -XIncoherentInstances.

This needs -XOverlappingInstances

foo :: String -> String
foo = fromString "blah"

This needs -XOverlappingInstances -XIncoherentInstances

foo :: a -> String
foo = fromString "blah"

> I am not suggesting that such an instance is generally useful, but
> people who wanted to use it in their own private code would be
> obstructed from doing so by an instance for (String -> String).

Right. It makes me nervous too. I think what this show us is that ShowS
should have been a newtype.

Duncan

_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by Ross Paterson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Sep 27, 2009 at 10:51:04PM +0200, Bas van Dijk wrote:

> It would be really nice to use OverloadedStrings when constructing a
> ShowS, for example in a definition of showsPrec in an instance for
> Show.
>
> The patch attached in the ticket[3544] adds the necessary instance to
> base/GHC/Show.lhs:
>
> instance IsString ShowS where
>     fromString = showString
>
> Note that this does require TypeSynonymInstances.

and also FlexibleInstances.  I think that's a problem, as Ganesh outlined.
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by Lennart Augustsson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-1

What Ganesh said.

On Mon, Oct 5, 2009 at 1:32 PM, Ross Paterson <ross@...> wrote:

> On Sun, Sep 27, 2009 at 10:51:04PM +0200, Bas van Dijk wrote:
>> It would be really nice to use OverloadedStrings when constructing a
>> ShowS, for example in a definition of showsPrec in an instance for
>> Show.
>>
>> The patch attached in the ticket[3544] adds the necessary instance to
>> base/GHC/Show.lhs:
>>
>> instance IsString ShowS where
>>     fromString = showString
>>
>> Note that this does require TypeSynonymInstances.
>
> and also FlexibleInstances.  I think that's a problem, as Ganesh outlined.
> _______________________________________________
> Libraries mailing list
> Libraries@...
> http://www.haskell.org/mailman/listinfo/libraries
>
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by Bas van Dijk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 5, 2009 at 12:47 PM, Duncan Coutts
<duncan.coutts@...> wrote:
> Right, then uses of fromString would require -XOverlappingInstances and
> possibly -XIncoherentInstances.

That's a bummer.

> Right. It makes me nervous too. I think what this show us is that ShowS
> should have been a newtype.

Yes, I think I just keep using dstring[1] instead.

regards,

Bas

[1] http://hackage.haskell.org/package/dstring
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by Bas van Dijk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Because of the required language extensions, I'm not in favor of this
ticket[1] anymore. So I'm resolving it as WONTFIX.

regards,

Bas

[1] http://hackage.haskell.org/trac/ghc/ticket/3544
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries

Re: Add instance IsString ShowS where fromString = showString

by edwardk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-1.

A ShowS instance would interfere with any other anonymous reader-monad style IsString instance.

-Edward Kmett

On Mon, Oct 5, 2009 at 5:23 AM, Nicolas Pouillard <nicolas.pouillard@...> wrote:
Excerpts from Bas van Dijk's message of Mon Oct 05 09:27:07 +0200 2009:
> On Sun, Sep 27, 2009 at 10:51 PM, Bas van Dijk <v.dijk.bas@...> wrote:
> > Hello,
> >
> > It would be really nice to use OverloadedStrings when constructing a
> > ShowS, for example in a definition of showsPrec in an instance for
> > Show.
> >
> > The patch attached in the ticket[3544] adds the necessary instance to
> > base/GHC/Show.lhs:
> >
> > instance IsString ShowS where
> >    fromString = showString
> >
> > Note that this does require TypeSynonymInstances.
> >
> > Discussion period 2 weeks.
> >
> > regards,
> >
> > Bas
> >
> > [3544] http://hackage.haskell.org/trac/ghc/ticket/3544
> >
>
> Just a reminder for this proposal. One week has passed and one to go.
>
> Any comments, +1 or -1?

+1

--
Nicolas Pouillard
http://nicolaspouillard.fr
_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries@...
http://www.haskell.org/mailman/listinfo/libraries