Make data in Interface more opaque

This commit is contained in:
Ng Zhi An 2018-07-29 22:50:49 -07:00
parent 581be5878b
commit c8e0797350
8 changed files with 182 additions and 50 deletions

View file

@ -40,7 +40,10 @@ format = do
}
instance ToJSON (PositionedComment) where
toJSON comment@(PositionedComment start end (Comment level code string)) =
toJSON comment =
let start = pcStartPos comment
end = pcEndPos comment
c = pcComment comment in
object [
"file" .= posFile start,
"line" .= posLine start,
@ -48,11 +51,14 @@ instance ToJSON (PositionedComment) where
"column" .= posColumn start,
"endColumn" .= posColumn end,
"level" .= severityText comment,
"code" .= code,
"message" .= string
"code" .= cCode c,
"message" .= cMessage c
]
toEncoding comment@(PositionedComment start end (Comment level code string)) =
toEncoding comment =
let start = pcStartPos comment
end = pcEndPos comment
c = pcComment comment in
pairs (
"file" .= posFile start
<> "line" .= posLine start
@ -60,8 +66,8 @@ instance ToJSON (PositionedComment) where
<> "column" .= posColumn start
<> "endColumn" .= posColumn end
<> "level" .= severityText comment
<> "code" .= code
<> "message" .= string
<> "code" .= cCode c
<> "message" .= cMessage c
)
outputError file msg = hPutStrLn stderr $ file ++ ": " ++ msg