git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Desugar operator section always to lambda
9c29a14bagl
examples/failing/OperatorSections.pursnew file+7
@@ -0,0 +1,7 @@
1+-- @shouldFailWith CannotApplyFunction
2+module Main where
3+
4+import Prelude
5+
6+main = do
7+ (true `not` _)
src/Language/PureScript/AST/Declarations.hs+1−2
@@ -342,8 +342,7 @@ data Expr
342 --
342 --
343 | Parens Expr
343 | Parens Expr
344 -- |
344 -- |
345− -- Operator section. This will be removed during desugaring and replaced with a partially applied
345+ -- Operator section. This will be removed during desugaring and replaced with lambda.
346− -- operator or lambda to flip the arguments.
347 --
346 --
348 | OperatorSection Expr (Either Expr Expr)
347 | OperatorSection Expr (Either Expr Expr)
349 -- |
348 -- |
src/Language/PureScript/Sugar/Operators.hs+6−3
@@ -189,8 +189,11 @@ desugarOperatorSections (Module ss coms mn ds exts) =
189 (goDecl, _, _) = everywhereOnValuesM return goExpr return
189 (goDecl, _, _) = everywhereOnValuesM return goExpr return
190
190
191 goExpr :: Expr -> m Expr
191 goExpr :: Expr -> m Expr
192− goExpr (OperatorSection op (Left val)) = return $ App op val
192+ goExpr (OperatorSection op eVal) = do
193− goExpr (OperatorSection op (Right val)) = do
194 arg <- freshIdent'
193 arg <- freshIdent'
195− return $ Abs (Left arg) $ App (App op (Var (Qualified Nothing arg))) val
194+ let var = Var (Qualified Nothing arg)
195+ f2 a b = Abs (Left arg) $ App (App op a) b
196+ return $ case eVal of
197+ Left val -> f2 val var
198+ Right val -> f2 var val
196 goExpr other = return other
199 goExpr other = return other