diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-26 12:32:18 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-26 12:32:18 +0100 |
commit | 5ea5e05a87c76d80194dbdfac177994aa870b783 (patch) | |
tree | bc1c27ab28fa248b343c13e949caa3ab9a3caaa9 /ddl/out/LambdaCube.TypeInfo.hs | |
parent | c0d38528840c15998c02ef8e04a0a7b7be34ad5d (diff) |
add Range type
Diffstat (limited to 'ddl/out/LambdaCube.TypeInfo.hs')
-rw-r--r-- | ddl/out/LambdaCube.TypeInfo.hs | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/ddl/out/LambdaCube.TypeInfo.hs b/ddl/out/LambdaCube.TypeInfo.hs index f23bd83..01bf5a6 100644 --- a/ddl/out/LambdaCube.TypeInfo.hs +++ b/ddl/out/LambdaCube.TypeInfo.hs | |||
@@ -1,5 +1,5 @@ | |||
1 | -- generated file, do not modify! | 1 | -- generated file, do not modify! |
2 | -- 2016-02-26T10:42:57.376331000000Z | 2 | -- 2016-02-26T11:29:11.823283000000Z |
3 | 3 | ||
4 | {-# LANGUAGE OverloadedStrings, RecordWildCards #-} | 4 | {-# LANGUAGE OverloadedStrings, RecordWildCards #-} |
5 | module LambdaCube.TypeInfo where | 5 | module LambdaCube.TypeInfo where |
@@ -17,12 +17,19 @@ import Control.Monad | |||
17 | 17 | ||
18 | import LambdaCube.IR | 18 | import LambdaCube.IR |
19 | 19 | ||
20 | data TypeInfo | 20 | data Range |
21 | = TypeInfo | 21 | = Range |
22 | { startLine :: Int | 22 | { startLine :: Int |
23 | , startColumn :: Int | 23 | , startColumn :: Int |
24 | , endLine :: Int | 24 | , endLine :: Int |
25 | , endColumn :: Int | 25 | , endColumn :: Int |
26 | } | ||
27 | |||
28 | deriving (Show, Eq, Ord) | ||
29 | |||
30 | data TypeInfo | ||
31 | = TypeInfo | ||
32 | { range :: Range | ||
26 | , text :: String | 33 | , text :: String |
27 | } | 34 | } |
28 | 35 | ||
@@ -34,32 +41,50 @@ data CompileResult | |||
34 | deriving (Show, Eq, Ord) | 41 | deriving (Show, Eq, Ord) |
35 | 42 | ||
36 | 43 | ||
37 | instance ToJSON TypeInfo where | 44 | instance ToJSON Range where |
38 | toJSON v = case v of | 45 | toJSON v = case v of |
39 | TypeInfo{..} -> object | 46 | Range{..} -> object |
40 | [ "tag" .= ("TypeInfo" :: Text) | 47 | [ "tag" .= ("Range" :: Text) |
41 | , "startLine" .= startLine | 48 | , "startLine" .= startLine |
42 | , "startColumn" .= startColumn | 49 | , "startColumn" .= startColumn |
43 | , "endLine" .= endLine | 50 | , "endLine" .= endLine |
44 | , "endColumn" .= endColumn | 51 | , "endColumn" .= endColumn |
45 | , "text" .= text | ||
46 | ] | 52 | ] |
47 | 53 | ||
48 | instance FromJSON TypeInfo where | 54 | instance FromJSON Range where |
49 | parseJSON (Object obj) = do | 55 | parseJSON (Object obj) = do |
50 | tag <- obj .: "tag" | 56 | tag <- obj .: "tag" |
51 | case tag :: Text of | 57 | case tag :: Text of |
52 | "TypeInfo" -> do | 58 | "Range" -> do |
53 | startLine <- obj .: "startLine" | 59 | startLine <- obj .: "startLine" |
54 | startColumn <- obj .: "startColumn" | 60 | startColumn <- obj .: "startColumn" |
55 | endLine <- obj .: "endLine" | 61 | endLine <- obj .: "endLine" |
56 | endColumn <- obj .: "endColumn" | 62 | endColumn <- obj .: "endColumn" |
57 | text <- obj .: "text" | 63 | pure $ Range |
58 | pure $ TypeInfo | ||
59 | { startLine = startLine | 64 | { startLine = startLine |
60 | , startColumn = startColumn | 65 | , startColumn = startColumn |
61 | , endLine = endLine | 66 | , endLine = endLine |
62 | , endColumn = endColumn | 67 | , endColumn = endColumn |
68 | } | ||
69 | parseJSON _ = mzero | ||
70 | |||
71 | instance ToJSON TypeInfo where | ||
72 | toJSON v = case v of | ||
73 | TypeInfo{..} -> object | ||
74 | [ "tag" .= ("TypeInfo" :: Text) | ||
75 | , "range" .= range | ||
76 | , "text" .= text | ||
77 | ] | ||
78 | |||
79 | instance FromJSON TypeInfo where | ||
80 | parseJSON (Object obj) = do | ||
81 | tag <- obj .: "tag" | ||
82 | case tag :: Text of | ||
83 | "TypeInfo" -> do | ||
84 | range <- obj .: "range" | ||
85 | text <- obj .: "text" | ||
86 | pure $ TypeInfo | ||
87 | { range = range | ||
63 | , text = text | 88 | , text = text |
64 | } | 89 | } |
65 | parseJSON _ = mzero | 90 | parseJSON _ = mzero |