-
Notifications
You must be signed in to change notification settings - Fork 0
/
pretty.hs
42 lines (35 loc) · 1.04 KB
/
pretty.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{-# LANGUAGE CPP #-}
{-# Language DeriveDataTypeable, StandaloneDeriving #-} -- for GHC < 7.10
import Test.Speculate
import Data.Function (on)
import Data.List (isPrefixOf)
import Text.PrettyPrint as P
deriving instance Typeable Doc -- for GHC < 7.10
#if __GLASGOW_HASKELL__ < 710
-- pretty <= 1.1.1.1 (bundled with GHC <= 7.8) does not provide this instance
-- pretty >= 1.1.2.0 (bundled with GHC >= 7.10) does provide this instance
instance Eq Doc where
d == d' = show d == show d'
#endif
instance Ord Doc where
(<=) = isPrefixOf `on` show
instance Listable Doc where
tiers = cons1 text
\/ cons2 ($$)
\/ cons2 (P.<>)
\/ cons2 nest
instance Name Doc where name _ = "d1"
main :: IO ()
main = speculate args
{ instances = [reifyInstances (undefined :: Doc)]
, maxSize = 7
, maxVars = 3
, constants =
[ constant "$$" ($$)
, constant "<>" (P.<>)
, constant "nest" nest
, background
, constant "++" $ (++) -:> string
, constant "length" $ length -:> string
]
}