git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Desugar operator section always to lambda

Fix issue #1916

commit9c29a145b8abb10e1a7615556e81196c542e2337 authorbagl <petr.vapenka@volny.cz> dateSun 6 Mar 2016, 00:40 (11 years ago) parent38618a5
3 files changed+14−5
examples/failing/OperatorSections.purs+7 src/Language/PureScript/AST/Declarations.hs+1−2 src/Language/PureScript/Sugar/Operators.hs+6−3
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
342342 --
343343 | Parens Expr
344344 -- |
345− -- Operator section. This will be removed during desugaring and replaced with a partially applied
346− -- operator or lambda to flip the arguments.
345+ -- Operator section. This will be removed during desugaring and replaced with lambda.
347346 --
348347 | OperatorSection Expr (Either Expr Expr)
349348 -- |
src/Language/PureScript/Sugar/Operators.hs+6−3
@@ -189,8 +189,11 @@ desugarOperatorSections (Module ss coms mn ds exts) =
189189 (goDecl, _, _) = everywhereOnValuesM return goExpr return
190190
191191 goExpr :: Expr -> m Expr
192− goExpr (OperatorSection op (Left val)) = return $ App op val
193− goExpr (OperatorSection op (Right val)) = do
192+ goExpr (OperatorSection op eVal) = do
194193 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
196199 goExpr other = return other