on master help sign in
Use UNPACK pragma in Region.Position
41df71fEvan Czaplicki
src/Docs/Check.hs+2−2
@@ -151,7 +151,7 @@ checkModuleComment docRegion exports locatedDocNames =
151
151
152
152
153commentedNames :: R.Region -> String -> [A.Located String]
153commentedNames :: R.Region -> String -> [A.Located String]
154−commentedNames (R.Region start _) comment =
154+commentedNames (R.Region (R.Position line column) _) comment =
155 let
155 let
156 nameParser =
156 nameParser =
157 choice
157 choice
@@ -163,7 +163,7 @@ commentedNames (R.Region start _) comment =
163 ]
163 ]
164
164
165 docCommentParser =
165 docCommentParser =
166− do setPosition (newPos "docs" (R.line start) (R.column start + 3))
166+ do setPosition (newPos "docs" line (column + 3))
167 concat <$> many nameParser
167 concat <$> many nameParser
168 in
168 in
169 case parse docCommentParser comment of
169 case parse docCommentParser comment of
src/Reporting/Region.hs+18−12
@@ -6,16 +6,18 @@ import qualified Data.Aeson as Json
6import qualified Text.Parsec.Pos as Parsec
6import qualified Text.Parsec.Pos as Parsec
7
7
8
8
9−data Region = Region
9+data Region =
10+ Region
10− { start :: Position
11+ { start :: !Position
11− , end :: Position
12+ , end :: !Position
12 }
13 }
13 deriving (Eq, Show)
14 deriving (Eq, Show)
14
15
15
16
16−data Position = Position
17+data Position =
18+ Position
17− { line :: Int
19+ { line :: {-# UNPACK #-} !Int
18− , column :: Int
20+ , column :: {-# UNPACK #-} !Int
19 }
21 }
20 deriving (Eq, Show)
22 deriving (Eq, Show)
21
23
@@ -32,22 +34,26 @@ merge (Region start _) (Region _ end) =
32 Region start end
34 Region start end
33
35
34
36
37+
35-- TO STRING
38-- TO STRING
36
39
40+
37toString :: Region -> String
41toString :: Region -> String
38−toString (Region start end) =
42+toString (Region (Position startLine startColumn) (Position endLine endColumn)) =
39− case line start == line end of
43+ case startLine == endLine of
40 False ->
44 False ->
41− "between lines " ++ show (line start)
45+ "between lines " ++ show startLine
42− ++ " and " ++ show (line end)
46+ ++ " and " ++ show endLine
43
47
44 True ->
48 True ->
45− "on line " ++ show (line end) ++ ", column "
49+ "on line " ++ show endLine ++ ", column "
46− ++ show (column start) ++ " to " ++ show (column end)
50+ ++ show startColumn ++ " to " ++ show endColumn
51+
47
52
48
53
49-- JSON
54-- JSON
50
55
56+
51instance Json.ToJSON Region where
57instance Json.ToJSON Region where
52 toJSON (Region start end) =
58 toJSON (Region start end) =
53 Json.object
59 Json.object