diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-12 17:07:41 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-12 17:07:41 +0100 |
commit | 5ca4d7845df57242e4a2c85030693faab9b17822 (patch) | |
tree | 6f76812ee47d184e01827ab4f3cba3e9c150013e /testclient/TestData.hs | |
parent | 4b51e6a96d528bad7aee1f1e30b1b0a1dc2998f0 (diff) |
improve exceptions
Diffstat (limited to 'testclient/TestData.hs')
-rw-r--r-- | testclient/TestData.hs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/testclient/TestData.hs b/testclient/TestData.hs index a48dc42..d6d8e38 100644 --- a/testclient/TestData.hs +++ b/testclient/TestData.hs | |||
@@ -1,5 +1,5 @@ | |||
1 | -- generated file, do not modify! | 1 | -- generated file, do not modify! |
2 | -- 2016-01-28T13:15:31.27456Z | 2 | -- 2016-02-12T16:05:13.383716000000Z |
3 | 3 | ||
4 | {-# LANGUAGE OverloadedStrings, RecordWildCards #-} | 4 | {-# LANGUAGE OverloadedStrings, RecordWildCards #-} |
5 | module TestData where | 5 | module TestData where |
@@ -46,13 +46,21 @@ data Scene | |||
46 | 46 | ||
47 | deriving (Show, Eq, Ord) | 47 | deriving (Show, Eq, Ord) |
48 | 48 | ||
49 | data PipelineInfo | ||
50 | = PipelineInfo | ||
51 | { pipelineName :: String | ||
52 | , pipeline :: Pipeline | ||
53 | } | ||
54 | |||
55 | deriving (Show, Eq, Ord) | ||
56 | |||
49 | data RenderJob | 57 | data RenderJob |
50 | = RenderJob | 58 | = RenderJob |
51 | { meshes :: Vector Mesh | 59 | { meshes :: Vector Mesh |
52 | , textures :: Vector String | 60 | , textures :: Vector String |
53 | , schema :: PipelineSchema | 61 | , schema :: PipelineSchema |
54 | , scenes :: Vector Scene | 62 | , scenes :: Vector Scene |
55 | , pipelines :: Vector Pipeline | 63 | , pipelines :: Vector PipelineInfo |
56 | } | 64 | } |
57 | 65 | ||
58 | deriving (Show, Eq, Ord) | 66 | deriving (Show, Eq, Ord) |
@@ -144,6 +152,27 @@ instance FromJSON Scene where | |||
144 | } | 152 | } |
145 | parseJSON _ = mzero | 153 | parseJSON _ = mzero |
146 | 154 | ||
155 | instance ToJSON PipelineInfo where | ||
156 | toJSON v = case v of | ||
157 | PipelineInfo{..} -> object | ||
158 | [ "tag" .= ("PipelineInfo" :: Text) | ||
159 | , "pipelineName" .= pipelineName | ||
160 | , "pipeline" .= pipeline | ||
161 | ] | ||
162 | |||
163 | instance FromJSON PipelineInfo where | ||
164 | parseJSON (Object obj) = do | ||
165 | tag <- obj .: "tag" | ||
166 | case tag :: Text of | ||
167 | "PipelineInfo" -> do | ||
168 | pipelineName <- obj .: "pipelineName" | ||
169 | pipeline <- obj .: "pipeline" | ||
170 | pure $ PipelineInfo | ||
171 | { pipelineName = pipelineName | ||
172 | , pipeline = pipeline | ||
173 | } | ||
174 | parseJSON _ = mzero | ||
175 | |||
147 | instance ToJSON RenderJob where | 176 | instance ToJSON RenderJob where |
148 | toJSON v = case v of | 177 | toJSON v = case v of |
149 | RenderJob{..} -> object | 178 | RenderJob{..} -> object |