Proposal: Add IsString and Monoid instances for Doc

Hello, Since we're discussing a proposal for the pretty package I would like to make another one: The proposal is to add the following to Text.PrettyPrint.HughesPJ: instance IsString Doc where fromString = text This allows users to use string literals as Doc values using the OverloadedStrings language extension. I would also like to add: instance Monoid Doc where mempty = empty mappend = (<>) If there's enough demand (because it's a lot of work) I can find out if this change breaks anything by analyzing pretty's direct reverse dependencies: http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/pretty-... to see if some of them define an orphaned instance for IsString or Monoid. The patch that implements this is attached to the ticket: http://hackage.haskell.org/trac/ghc/ticket/4378 Deadline: 2 weeks (Friday 22 October 2010) Regards, Bas

+1, conditional upon there not being to many breakages.
That reminds me of the proposal to make `mappend == <>`. What
happened to that one?
On 8 October 2010 08:52, Bas van Dijk
Hello,
Since we're discussing a proposal for the pretty package I would like to make another one:
The proposal is to add the following to Text.PrettyPrint.HughesPJ:
instance IsString Doc where fromString = text
This allows users to use string literals as Doc values using the OverloadedStrings language extension.
I would also like to add:
instance Monoid Doc where mempty = empty mappend = (<>)
If there's enough demand (because it's a lot of work) I can find out if this change breaks anything by analyzing pretty's direct reverse dependencies:
http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/pretty-...
to see if some of them define an orphaned instance for IsString or Monoid.
The patch that implements this is attached to the ticket:
http://hackage.haskell.org/trac/ghc/ticket/4378
Deadline: 2 weeks (Friday 22 October 2010)
Regards,
Bas _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Push the envelope. Watch it bend.

On Mon, Oct 11, 2010 at 6:32 PM, Thomas Schilling
+1, conditional upon there not being to many breakages.
Thanks, I try to determine if somethings breaks this week.
That reminds me of the proposal to make `mappend == <>`. What happened to that one?
That would be nice. Note that I also define that combinator in my string-combinators package: http://hackage.haskell.org/packages/archive/string-combinators/0.5/doc/html/... But it sure would be nice if it was exported by Data.Monoid. This is the related, still open, ticket: http://hackage.haskell.org/trac/ghc/ticket/3339 Anyone care to revive it? Bas

On Fri, Oct 8, 2010 at 9:52 AM, Bas van Dijk
Hello,
Since we're discussing a proposal for the pretty package I would like to make another one:
The proposal is to add the following to Text.PrettyPrint.HughesPJ:
instance IsString Doc where fromString = text
This allows users to use string literals as Doc values using the OverloadedStrings language extension.
I would also like to add:
instance Monoid Doc where mempty = empty mappend = (<>)
If there's enough demand (because it's a lot of work) I can find out if this change breaks anything by analyzing pretty's direct reverse dependencies:
http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/pretty-...
to see if some of them define an orphaned instance for IsString or Monoid.
The patch that implements this is attached to the ticket:
http://hackage.haskell.org/trac/ghc/ticket/4378
Deadline: 2 weeks (Friday 22 October 2010)
Regards,
Bas
The deadline for this proposal has passed. There were no objections. I will move the ticket status to 'patch'. Thanks, Bas

Did you test how many packages this would break, i.e., how many
packages define their own instance for Monoid Doc?
On 24 October 2010 09:16, Bas van Dijk
On Fri, Oct 8, 2010 at 9:52 AM, Bas van Dijk
wrote: Hello,
Since we're discussing a proposal for the pretty package I would like to make another one:
The proposal is to add the following to Text.PrettyPrint.HughesPJ:
instance IsString Doc where fromString = text
This allows users to use string literals as Doc values using the OverloadedStrings language extension.
I would also like to add:
instance Monoid Doc where mempty = empty mappend = (<>)
If there's enough demand (because it's a lot of work) I can find out if this change breaks anything by analyzing pretty's direct reverse dependencies:
http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/pretty-...
to see if some of them define an orphaned instance for IsString or Monoid.
The patch that implements this is attached to the ticket:
http://hackage.haskell.org/trac/ghc/ticket/4378
Deadline: 2 weeks (Friday 22 October 2010)
Regards,
Bas
The deadline for this proposal has passed. There were no objections.
I will move the ticket status to 'patch'.
Thanks,
Bas _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Push the envelope. Watch it bend.

On Sun, Oct 24, 2010 at 5:38 PM, Bas van Dijk
On Sun, Oct 24, 2010 at 3:25 PM, Thomas Schilling
wrote: Did you test how many packages this would break, i.e., how many packages define their own instance for Monoid Doc?
No, but I will try do that later today. Thanks for reminding me.
I just did an analysis on how many packages would break if we add Monoid and IsString instances for Doc. There are no packages that define a (orphaned) Monoid instance for Doc. There's one package that adds an (orphaned) IsString instance for Doc: numerals (of which I'm a maintainer and which uses the PVP so it won't break). So I think we can go ahead an apply the patch attached to the ticket: http://hackage.haskell.org/trac/ghc/ticket/4378 Regards, Bas

(Apparently my previous message didn't come through so this is a resend)
On Sun, Oct 24, 2010 at 5:38 PM, Bas van Dijk
On Sun, Oct 24, 2010 at 3:25 PM, Thomas Schilling
wrote: Did you test how many packages this would break, i.e., how many packages define their own instance for Monoid Doc?
No, but I will try do that later today. Thanks for reminding me.
I just did an analysis on how many packages would break if we add Monoid and IsString instances for Doc. There are no packages that define a (orphaned) Monoid instance for Doc. There's one package that adds an (orphaned) IsString instance for Doc: numerals (of which I'm a maintainer and which uses the PVP so it won't break). So I think we can go ahead an apply the patch attached to the ticket: http://hackage.haskell.org/trac/ghc/ticket/4378 Regards, Bas
participants (2)
-
Bas van Dijk
-
Thomas Schilling