summaryrefslogtreecommitdiff
path: root/ddl/out/haskell/LambdaCube/TypeInfo.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ddl/out/haskell/LambdaCube/TypeInfo.hs')
-rw-r--r--ddl/out/haskell/LambdaCube/TypeInfo.hs162
1 files changed, 162 insertions, 0 deletions
diff --git a/ddl/out/haskell/LambdaCube/TypeInfo.hs b/ddl/out/haskell/LambdaCube/TypeInfo.hs
new file mode 100644
index 0000000..3aed071
--- /dev/null
+++ b/ddl/out/haskell/LambdaCube/TypeInfo.hs
@@ -0,0 +1,162 @@
1-- generated file, do not modify!
2-- 2016-11-11T11:17:03.605012000000Z
3
4{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
5module LambdaCube.TypeInfo where
6
7import Data.Int
8import Data.Word
9import Data.Map
10import Data.Vector (Vector(..))
11import LambdaCube.Linear
12
13import Data.Text
14import Data.Aeson hiding (Value,Bool)
15import Data.Aeson.Types hiding (Value,Bool)
16import Control.Monad
17
18import LambdaCube.IR
19
20data Range
21 = Range
22 { startLine :: Int
23 , startColumn :: Int
24 , endLine :: Int
25 , endColumn :: Int
26 }
27
28 deriving (Show, Eq, Ord)
29
30data TypeInfo
31 = TypeInfo
32 { range :: Range
33 , text :: String
34 }
35
36 deriving (Show, Eq, Ord)
37
38data WarningInfo
39 = WarningInfo
40 { wRange :: Range
41 , wText :: String
42 }
43
44 deriving (Show, Eq, Ord)
45
46data ErrorInfo
47 = ErrorInfo
48 { eRange :: Range
49 , eText :: String
50 }
51
52 deriving (Show, Eq, Ord)
53
54data CompileResult
55 = CompileError String (Vector TypeInfo) (Vector WarningInfo) (Vector ErrorInfo)
56 | Compiled String String Pipeline (Vector TypeInfo) (Vector WarningInfo)
57 deriving (Show, Eq, Ord)
58
59
60instance ToJSON Range where
61 toJSON v = case v of
62 Range{..} -> object
63 [ "tag" .= ("Range" :: Text)
64 , "startLine" .= startLine
65 , "startColumn" .= startColumn
66 , "endLine" .= endLine
67 , "endColumn" .= endColumn
68 ]
69
70instance FromJSON Range where
71 parseJSON (Object obj) = do
72 tag <- obj .: "tag"
73 case tag :: Text of
74 "Range" -> do
75 startLine <- obj .: "startLine"
76 startColumn <- obj .: "startColumn"
77 endLine <- obj .: "endLine"
78 endColumn <- obj .: "endColumn"
79 pure $ Range
80 { startLine = startLine
81 , startColumn = startColumn
82 , endLine = endLine
83 , endColumn = endColumn
84 }
85 parseJSON _ = mzero
86
87instance ToJSON TypeInfo where
88 toJSON v = case v of
89 TypeInfo{..} -> object
90 [ "tag" .= ("TypeInfo" :: Text)
91 , "range" .= range
92 , "text" .= text
93 ]
94
95instance FromJSON TypeInfo where
96 parseJSON (Object obj) = do
97 tag <- obj .: "tag"
98 case tag :: Text of
99 "TypeInfo" -> do
100 range <- obj .: "range"
101 text <- obj .: "text"
102 pure $ TypeInfo
103 { range = range
104 , text = text
105 }
106 parseJSON _ = mzero
107
108instance ToJSON WarningInfo where
109 toJSON v = case v of
110 WarningInfo{..} -> object
111 [ "tag" .= ("WarningInfo" :: Text)
112 , "wRange" .= wRange
113 , "wText" .= wText
114 ]
115
116instance FromJSON WarningInfo where
117 parseJSON (Object obj) = do
118 tag <- obj .: "tag"
119 case tag :: Text of
120 "WarningInfo" -> do
121 wRange <- obj .: "wRange"
122 wText <- obj .: "wText"
123 pure $ WarningInfo
124 { wRange = wRange
125 , wText = wText
126 }
127 parseJSON _ = mzero
128
129instance ToJSON ErrorInfo where
130 toJSON v = case v of
131 ErrorInfo{..} -> object
132 [ "tag" .= ("ErrorInfo" :: Text)
133 , "eRange" .= eRange
134 , "eText" .= eText
135 ]
136
137instance FromJSON ErrorInfo where
138 parseJSON (Object obj) = do
139 tag <- obj .: "tag"
140 case tag :: Text of
141 "ErrorInfo" -> do
142 eRange <- obj .: "eRange"
143 eText <- obj .: "eText"
144 pure $ ErrorInfo
145 { eRange = eRange
146 , eText = eText
147 }
148 parseJSON _ = mzero
149
150instance ToJSON CompileResult where
151 toJSON v = case v of
152 CompileError arg0 arg1 arg2 arg3 -> object [ "tag" .= ("CompileError" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2, "arg3" .= arg3]
153 Compiled arg0 arg1 arg2 arg3 arg4 -> object [ "tag" .= ("Compiled" :: Text), "arg0" .= arg0, "arg1" .= arg1, "arg2" .= arg2, "arg3" .= arg3, "arg4" .= arg4]
154
155instance FromJSON CompileResult where
156 parseJSON (Object obj) = do
157 tag <- obj .: "tag"
158 case tag :: Text of
159 "CompileError" -> CompileError <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" <*> obj .: "arg3"
160 "Compiled" -> Compiled <$> obj .: "arg0" <*> obj .: "arg1" <*> obj .: "arg2" <*> obj .: "arg3" <*> obj .: "arg4"
161 parseJSON _ = mzero
162