1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-- generated file, do not modify!
<<<<<<< c5e063b3c9aeff65161e24445e9672daff980b45
<<<<<<< 3b50722f433ec5ecc515ea1441fd633d85118cb9
-- 2016-03-01T13:00:40.810157000000Z
=======
-- 2016-03-20T21:42:12.996366000000Z
>>>>>>> working c# backend
=======
-- 2016-03-20T22:19:43.646837000000Z
>>>>>>> fix c#
module LambdaCube.TypeInfo where
import Prelude
import Data.Generic
import Data.Maybe (Maybe(..))
import Data.StrMap (StrMap(..))
import Data.Map (Map(..))
import Data.List (List(..))
import Linear
import Data.Argonaut.Combinators ((~>), (:=), (.?))
import Data.Argonaut.Core (jsonEmptyObject)
import Data.Argonaut.Printer (printJson)
import Data.Argonaut.Encode (EncodeJson, encodeJson)
import Data.Argonaut.Decode (DecodeJson, decodeJson)
import LambdaCube.IR
data Range
= Range
{ startLine :: Int
, startColumn :: Int
, endLine :: Int
, endColumn :: Int
}
data TypeInfo
= TypeInfo
{ range :: Range
, text :: String
}
data CompileResult
= CompileError (Array Range) String (Array TypeInfo)
| Compiled String String Pipeline (Array TypeInfo)
instance encodeJsonRange :: EncodeJson Range where
encodeJson v = case v of
Range r ->
"tag" := "Range" ~>
"startLine" := r.startLine ~>
"startColumn" := r.startColumn ~>
"endLine" := r.endLine ~>
"endColumn" := r.endColumn ~>
jsonEmptyObject
instance decodeJsonRange :: DecodeJson Range where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Range" -> do
startLine <- obj .? "startLine"
startColumn <- obj .? "startColumn"
endLine <- obj .? "endLine"
endColumn <- obj .? "endColumn"
pure $ Range
{ startLine:startLine
, startColumn:startColumn
, endLine:endLine
, endColumn:endColumn
}
instance encodeJsonTypeInfo :: EncodeJson TypeInfo where
encodeJson v = case v of
TypeInfo r ->
"tag" := "TypeInfo" ~>
"range" := r.range ~>
"text" := r.text ~>
jsonEmptyObject
instance decodeJsonTypeInfo :: DecodeJson TypeInfo where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"TypeInfo" -> do
range <- obj .? "range"
text <- obj .? "text"
pure $ TypeInfo
{ range:range
, text:text
}
instance encodeJsonCompileResult :: EncodeJson CompileResult where
encodeJson v = case v of
CompileError arg0 arg1 arg2 -> "tag" := "CompileError" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject
Compiled arg0 arg1 arg2 arg3 -> "tag" := "Compiled" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject
instance decodeJsonCompileResult :: DecodeJson CompileResult where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"CompileError" -> CompileError <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2"
"Compiled" -> Compiled <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3"
|