Commit 95d0d502 authored by Iustin Pop's avatar Iustin Pop

Auto-define a LuxiReq data type

We currently auto-generate a LuxiOp data type, which holds the entire
operation (including parameters). However, having a data type just for
the method call would be useful, so let's change THH to also
defineSADT for the Luxi constructors.

Currently I don't know how to match automatically a LuxiReq to its
LuxiOp counterpart (not even sure we need that), so any matching will
remain manual.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent fae980e5
......@@ -29,6 +29,7 @@ module Ganeti.Luxi
( LuxiOp(..)
, QrViaLuxi(..)
, ResultStatus(..)
, LuxiReq(..)
, Client
, checkRS
, getClient
......@@ -144,6 +145,8 @@ $(genLuxiOp "LuxiOp"
)
])
$(makeJSONInstance ''LuxiReq)
-- | The serialisation of LuxiOps into strings in messages.
$(genStrOfOp ''LuxiOp "strOfOp")
......
......@@ -543,7 +543,10 @@ genLuxiOp name cons = do
cons
let declD = DataD [] (mkName name) [] decl_d [''Show, ''Read]
(savesig, savefn) <- genSaveLuxiOp cons
return [declD, savesig, savefn]
req_defs <- declareSADT "LuxiReq" .
map (\(str, _) -> ("Req" ++ str, mkName ("luxiReq" ++ str))) $
cons
return $ [declD, savesig, savefn] ++ req_defs
-- | Generates the \"save\" expression for a single luxi parameter.
saveLuxiField :: Name -> LuxiParam -> Q Exp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment