~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to src/full/Agda/Utils/String.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane, d5cf60f
  • Date: 2015-05-20 13:08:33 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20150520130833-cdcmhagwsouna237
Tags: 2.4.2.2-2
[d5cf60f] Depend on ${shlibs:Depends}, to get libc (& maybe other) deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
  , addFinalNewLine
5
5
  , indent
6
6
  , Str(..)
 
7
  , showThousandSep
7
8
  ) where
8
9
 
9
10
import Data.List
10
11
import Numeric
 
12
import Agda.Utils.List
11
13
 
12
14
-- | 'quote' adds double quotes around the string, replaces newline
13
15
-- characters with @\n@, and escapes double quotes and backslashes
51
53
indent :: Integral i => i -> String -> String
52
54
indent i = unlines . map (genericReplicate i ' ' ++) . lines
53
55
 
54
 
newtype Str = Str { getStr :: String }
 
56
newtype Str = Str { unStr :: String }
 
57
  deriving Eq
55
58
 
56
59
instance Show Str where
57
 
  show = getStr
58
 
 
 
60
  show = unStr
 
61
 
 
62
-- | Show a number using comma to separate powers of 1,000.
 
63
 
 
64
showThousandSep :: Show a => a -> String
 
65
showThousandSep = reverse . intercalate "," . chop 3 . reverse . show