From 21591cc04d407a90cb6ed7705332819c947d16f6 Mon Sep 17 00:00:00 2001 From: Petr Pudlak Date: Thu, 22 May 2014 15:52:12 +0200 Subject: [PATCH] Improve the RPC Python function argument names generator .. so that it's able to handle Kind '* -> *' types such as 'MaybeForJSON'. Signed-off-by: Petr Pudlak Reviewed-by: Klaus Aehlig --- src/Ganeti/THH/PyRPC.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Ganeti/THH/PyRPC.hs b/src/Ganeti/THH/PyRPC.hs index 729075c4d..5ca2a22d4 100644 --- a/src/Ganeti/THH/PyRPC.hs +++ b/src/Ganeti/THH/PyRPC.hs @@ -98,6 +98,7 @@ toFunc fname as = do varName idx (AppT ListT t) = listOf idx t varName idx (AppT (ConT n) t) | n == ''[] = listOf idx t + | otherwise = kind1Of idx n t varName idx (AppT (AppT (TupleT 2) t) t') = pairOf idx t t' varName idx (AppT (AppT (ConT n) t) t') @@ -112,6 +113,11 @@ toFunc fname as = do listOf :: Int -> Type -> Q Doc listOf idx t = (<> text "List") <$> varName idx t + -- | Create a name for a method argument, knowing that its wrapped in + -- a type of kind @* -> *@. + kind1Of :: Int -> Name -> Type -> Q Doc + kind1Of idx name t = (<> text (nameBase name)) <$> varName idx t + -- | Create a name for a method argument, knowing that its a pair of -- the given types. pairOf :: Int -> Type -> Type -> Q Doc -- GitLab