@@ -277,26 +277,19 @@ def :: IParser Source.Def
278 addLocation $ Indent.withPos $
278 addLocation $ Indent.withPos $
279 do start <- defStart
279 do start <- defStart
280 case start of
281 case start of
281 A.A _ (P.Var name) ->
282 A.A _ (P.Var name) ->
284− [ do hasType
284+ [ do hasType
285− whitespace
285+ whitespace
286− tipe <- Type.expr
286+ tipe <- Type.expr
287− return $ Source.Annotation name tipe
287+ return $ Source.Annotation name tipe
288− , do args <- spacePrefix Pattern.term
288+ , defEnd start []
291− return $ Source.Definition start (makeFunction args body)
295− do args <- spacePrefix Pattern.term
292+ defEnd start []
298− return $ Source.Definition start (makeFunction args body)
302defStart :: IParser P.Raw
295defStart :: IParser P.Raw
@@ -307,6 +300,19 @@ defStart =
303+defEnd :: P.Raw -> [P.Raw] -> IParser Source.Def'
304+defEnd start revArgs =
306+ [ do arg <- Pattern.term
308+ defEnd start (arg : revArgs)
312+ return $ Source.Definition start (makeFunction revArgs body)
310makeFunction :: [P.Raw] -> Source.Expr -> Source.Expr
316makeFunction :: [P.Raw] -> Source.Expr -> Source.Expr
311−makeFunction args body@(A.A ann _) =
317+makeFunction revArgs body@(A.A ann _) =
312− foldr (\arg body' -> A.A ann $ E.Lambda arg body') body args
318+ List.foldl' (\expr arg -> A.A ann $ E.Lambda arg expr) body revArgs