Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 56 lines (46 sloc) 1.885 kb
7c3cfacf »
2012-03-05 Edits to testing code
1 module Main (main) where
a75ee605 »
2012-03-05 Restructure code base.
2
3 import Text.PrettyPrint.HughesPJ
4
5 stuff :: String -> String -> Double -> Rational -> Int -> Int -> Int -> Doc
6 stuff s1 s2 d1 r1 i1 i2 i3 =
7 let a = nest i1 $ text s1
8 b = double d1
9 c = rational r1
10 d = replicate i1 (text s2 <> b <> c <+> a)
11 e = cat d $+$ cat d $$ (c <> b <+> a)
12 f = parens e <> brackets c <> hcat d
13 g = lparen <> f <> rparen
14 h = text $ s2 ++ s1
15 i = map rational ([1..(toRational i2)]::[Rational])
16 j = punctuate comma i
17 k = nest i3 h <> (nest (i1 + i3) $ sep i) $+$ g <> cat j
18 l = cat $ punctuate (comma <> b <> comma) $ replicate i3 k
19 in l
20
21 doc1 :: Doc
22 doc1 = stuff "Adsas ads" "dassdab weeaa xxxxx" 123.231321 ((-1)/5) 30 300 20
23
24 doc2 :: Doc
25 doc2 = stuff "aDSAS ADS asdasdsa sdsda xx" "SDAB WEEAA" 1333.212 ((-4)/5) 31 301 30
26
27 doc3 :: Doc
28 doc3 = stuff "ADsAs --____ aDS" "DasSdAB weEAA" 2533.21299 ((-4)/999) 39 399 60
29
30 {-
31 txt :: TextDetails -> String -> String
32 txt (Chr c) s = c:s
33 txt (Str s1) s2 = s1 ++ s2
34 -}
35
36 main :: IO ()
37 main = do
38 putStrLn "==================================================="
39 putStrLn $ render doc1
40 {-
41 putStrLn "==================================================="
42 putStrLn $ fullRender PageMode 1000 4 txt "" doc2
43 putStrLn "==================================================="
44 putStrLn $ fullRender PageMode 100 1.5 txt "" doc2
45 putStrLn "==================================================="
46 putStrLn $ fullRender ZigZagMode 1000 4 txt "" doc2
47 putStrLn "==================================================="
48 putStrLn $ fullRender LeftMode 1000 4 txt "" doc2
49 putStrLn "==================================================="
50 putStrLn $ fullRender OneLineMode 1000 4 txt "" doc3
51 putStrLn "==================================================="
52 -}
53 putStrLn $ render doc3
54
55
Something went wrong with that request. Please try again.