lawbreakers in Text.PrettyPrint.HughesPJ

Conal Elliott conal at conal.net
Thu Nov 24 10:56:37 EST 2005


> Can you construct an example [...]

Certainly.  Here's the example that caught my attention (in my GHC 6.5
STABLE):

    Prelude Text.PrettyPrint> isEmpty empty
    True
    Prelude Text.PrettyPrint> isEmpty (empty<>empty)
    False

Similarly,

    Prelude Text.PrettyPrint> isEmpty (empty$$empty)
    False

Cheers, - Conal

-----Original Message-----
From: Christian Maeder [mailto:maeder at tzi.de] 
Sent: Thursday, November 24, 2005 1:12 AM
To: Conal Elliott
Cc: libraries at haskell.org
Subject: Re: lawbreakers in Text.PrettyPrint.HughesPJ

Conal Elliott wrote:
> The comments in HughesPJ say that empty is an identity for <> and $$,
> but the implementation doesn't satisfy either of these laws.  Here are
> the implementations:

I think, the "observable" results of <> and $$ satisfy these laws. Can 
you construct an example were these laws can be observed to be not 
fulfilled (for a reduced doc)?

>> p $$ q = Above p False q
> 
>> p <> q = Beside p False q

Above and Beside are not observable and (I think) your proposed fix is 
not necessary.

Christian



More information about the Libraries mailing list