[ ("names", [t| [String] |], [| id |])
, ("fields", [t| [String] |], [| id |])
, ("lock", [t| Bool |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("QueryGroups",
[ ("names", [t| [String] |], [| id |])
, ("fields", [t| [String] |], [| id |])
, ("lock", [t| Bool |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("QueryInstances",
[ ("names", [t| [String] |], [| id |])
, ("fields", [t| [String] |], [| id |])
, ("lock", [t| Bool |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("QueryJobs",
[ ("ids", [t| [Int] |], [| map show |])
, ("fields", [t| [String] |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("QueryExports",
[ ("nodes", [t| [String] |], [| id |])
, ("lock", [t| Bool |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("QueryConfigValues",
- [ ("fields", [t| [String] |], [| id |]) ],
- [| J.showJSON |])
- , ("QueryClusterInfo",
- [],
- [| J.showJSON |])
+ [ ("fields", [t| [String] |], [| id |]) ])
+ , ("QueryClusterInfo", [])
, ("QueryTags",
[ ("kind", [t| String |], [| id |])
, ("name", [t| String |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("SubmitJob",
- [ ("job", [t| [OpCode] |], [| id |]) ],
- [| J.showJSON |])
+ [ ("job", [t| [OpCode] |], [| id |]) ])
, ("SubmitManyJobs",
- [ ("ops", [t| [[OpCode]] |], [| id |]) ],
- [| J.showJSON |])
+ [ ("ops", [t| [[OpCode]] |], [| id |]) ])
, ("WaitForJobChange",
- [ ("job", [t| Int |], [| J.showJSON |])
- , ("fields", [t| [String]|], [| J.showJSON |])
- , ("prev_job", [t| JSValue |], [| J.showJSON |])
- , ("prev_log", [t| JSValue |], [| J.showJSON |])
- , ("tmout", [t| Int |], [| J.showJSON |])
- ],
- [| \(j, f, pj, pl, t) -> JSArray [j, f, pj, pl, t] |])
+ [ ("job", [t| Int |], [| id |])
+ , ("fields", [t| [String]|], [| id |])
+ , ("prev_job", [t| JSValue |], [| id |])
+ , ("prev_log", [t| JSValue |], [| id |])
+ , ("tmout", [t| Int |], [| id |])
+ ])
, ("ArchiveJob",
- [ ("job", [t| Int |], [| show |]) ],
- [| J.showJSON |])
+ [ ("job", [t| Int |], [| show |]) ])
, ("AutoArchiveJobs",
[ ("age", [t| Int |], [| id |])
, ("tmout", [t| Int |], [| id |])
- ],
- [| J.showJSON |])
+ ])
, ("CancelJob",
- [("job", [t| Int |], [| show |]) ],
- [| J.showJSON |])
+ [("job", [t| Int |], [| show |]) ])
, ("SetDrainFlag",
- [ ("flag", [t| Bool |], [| id |]) ],
- [| J.showJSON |])
+ [ ("flag", [t| Bool |], [| id |]) ])
, ("SetWatcherPause",
- [ ("duration", [t| Double |], [| (: []) |]) ],
- [| J.showJSON |])
+ [ ("duration", [t| Double |], [| (: []) |]) ])
])
-- | The serialisation of LuxiOps into strings in messages.
-- * operation; this is the operation performed on the parameter before
-- serialization
--
-genLuxiOp :: String -> [(String, [LuxiParam], Q Exp)] -> Q [Dec]
+genLuxiOp :: String -> [(String, [LuxiParam])] -> Q [Dec]
genLuxiOp name cons = do
- decl_d <- mapM (\(cname, fields, _) -> do
+ decl_d <- mapM (\(cname, fields) -> do
fields' <- mapM (\(_, qt, _) ->
qt >>= \t -> return (NotStrict, t))
fields
return [declD, savesig, savefn]
-- | Generates the \"save\" clause for entire LuxiOp constructor.
-saveLuxiConstructor :: (String, [LuxiParam], Q Exp) -> Q Clause
-saveLuxiConstructor (sname, fields, finfn) =
+saveLuxiConstructor :: (String, [LuxiParam]) -> Q Clause
+saveLuxiConstructor (sname, fields) =
let cname = mkName sname
fnames = map (\(nm, _, _) -> mkName nm) fields
pat = conP cname (map varP fnames)
- flist = map (\(nm, _, fn) -> liftM2 appFn fn $ varNameE nm) fields
- finval = appE finfn (tupE flist)
- in
- clause [pat] (normalB finval) []
+ flist = map (\(nm, _, fn) -> liftM2 appFn fn $ (varNameE nm)) fields
+ showlist = map (\x -> [| JSON.showJSON $x |]) flist
+ finval = case showlist of
+ [] -> [| JSON.showJSON () |]
+ _ -> [| JSON.showJSON $(listE showlist) |]
+ in clause [pat] (normalB finval) []
-- | Generates the main save LuxiOp function.
-genSaveLuxiOp :: [(String, [LuxiParam], Q Exp)] -> Q (Dec, Dec)
+genSaveLuxiOp :: [(String, [LuxiParam])] -> Q (Dec, Dec)
genSaveLuxiOp opdefs = do
sigt <- [t| $(conT (mkName "LuxiOp")) -> JSON.JSValue |]
let fname = mkName "opToArgs"