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: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>
( LuxiOp(..)
, QrViaLuxi(..)
, ResultStatus(..)
+ , LuxiReq(..)
, Client
, checkRS
, getClient
)
])
+$(makeJSONInstance ''LuxiReq)
+
-- | The serialisation of LuxiOps into strings in messages.
$(genStrOfOp ''LuxiOp "strOfOp")
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