Commit 21591cc0 authored by Petr Pudlak's avatar Petr Pudlak

Improve the RPC Python function argument names generator

.. so that it's able to handle Kind '* -> *' types such as
'MaybeForJSON'.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent ed6a18f4
......@@ -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
......
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