@@ -21,7 +21,8 @@
2121
2222module Language.PureScript.Sugar.Operators (
2323 rebracket,
24− removeSignedLiterals
24+ removeSignedLiterals,
25+ desugarOperatorSections
2526) where
2627
2728import Language.PureScript.Names
@@ -148,3 +149,14 @@ matchOp op = do
148149 ident <- parseOp
149150 guard $ ident == op
150151
152+desugarOperatorSections :: Module -> Module
153+desugarOperatorSections (Module mn ds exts) = Module mn (map goDecl ds) exts
154+ where
155+
156+ goDecl :: Declaration -> Declaration
157+ (goDecl, _, _) = everywhereOnValues id goExpr id
158+
159+ goExpr :: Expr -> Expr
160+ goExpr (OperatorSection op (Left val)) = App (Var op) val
161+ goExpr (OperatorSection op (Right val)) = Abs (Left $ Ident "_lhs") $ App (App (Var op) (Var (Qualified Nothing (Ident "_lhs")))) val
162+ goExpr other = other