summaryrefslogtreecommitdiff
path: root/ddl/out/LambdaCube.TypeInfo.hs
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-26 12:32:18 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-26 12:32:18 +0100
commit5ea5e05a87c76d80194dbdfac177994aa870b783 (patch)
treebc1c27ab28fa248b343c13e949caa3ab9a3caaa9 /ddl/out/LambdaCube.TypeInfo.hs
parentc0d38528840c15998c02ef8e04a0a7b7be34ad5d (diff)
add Range type
Diffstat (limited to 'ddl/out/LambdaCube.TypeInfo.hs')
-rw-r--r--ddl/out/LambdaCube.TypeInfo.hs47
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 #-}
5module LambdaCube.TypeInfo where 5module LambdaCube.TypeInfo where
@@ -17,12 +17,19 @@ import Control.Monad
17 17
18import LambdaCube.IR 18import LambdaCube.IR
19 19
20data TypeInfo 20data 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
30data 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
37instance ToJSON TypeInfo where 44instance 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
48instance FromJSON TypeInfo where 54instance 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
71instance ToJSON TypeInfo where
72 toJSON v = case v of
73 TypeInfo{..} -> object
74 [ "tag" .= ("TypeInfo" :: Text)
75 , "range" .= range
76 , "text" .= text
77 ]
78
79instance 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