@@ -52,7 +52,29 @@ instance Compile Py.False where compile _ = pure (Bool False)
5252
5353instance Compile Py. Float
5454instance Compile Py. ForStatement
55- instance Compile Py. FunctionDefinition
55+
56+ instance Compile Py. FunctionDefinition where
57+ compile Py. FunctionDefinition
58+ { name = Py. Identifier name
59+ , parameters = Py. Parameters parameters
60+ , ..
61+ } = do
62+ parameters' <- params
63+ body' <- compile body
64+ pure (Let (User name) := lams parameters' body')
65+ where params = case parameters of
66+ Nothing -> pure []
67+ Just p -> traverse param [p] -- FIXME: this is wrong in node-types.json, @p@ should already be a list
68+ param (Left Py. AnonymousComma {}) = fail " lol what"
69+ param (Right (Left Py. DefaultParameter {.. })) = fail " lol what"
70+ param (Right (Right (Left Py. DictionarySplat {.. }))) = fail " lol what"
71+ param (Right (Right (Right (Left (Py. Identifier name))))) = pure (User name)
72+ param (Right (Right (Right (Right (Left Py. KeywordIdentifier {.. }))))) = fail " lol what"
73+ param (Right (Right (Right (Right (Right (Left Py. ListSplat {.. })))))) = fail " lol what"
74+ param (Right (Right (Right (Right (Right (Right (Left Py. Tuple {.. }))))))) = fail " lol what"
75+ param (Right (Right (Right (Right (Right (Right (Right (Left Py. TypedDefaultParameter {.. })))))))) = fail " lol what"
76+ param (Right (Right (Right (Right (Right (Right (Right (Right Py. TypedParameter {.. })))))))) = fail " lol what"
77+
5678instance Compile Py. FutureImportStatement
5779instance Compile Py. GeneratorExpression
5880instance Compile Py. GlobalStatement
0 commit comments