git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #2055, desugar ParensInType inside typed binders
50d9de0Phil Freeman
examples/passing/ParensInTypedBinder.pursnew file+20
@@ -0,0 +1,20 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff (Eff)
5+import Control.Monad.Eff.Console (CONSOLE, log)
6+
7+foo :: Array Int
8+foo = do
9+ xss :: Array (Array Int) <- [[[1,2,3], [4, 5]], [[6]]]
10+ xs :: Array Int <- xss
11+ xs
12+
13+main ::
14+ forall eff.
15+ Eff
16+ ( console :: CONSOLE
17+ | eff
18+ )
19+ Unit
20+main = log "Done"
src/Language/PureScript/Sugar/Operators.hs+17−9
@@ -112,13 +112,13 @@ rebracket externs modules = do
112 renameAliasedOperators valueAliased typeAliased (Module ss coms mn ds exts) =
112 renameAliasedOperators valueAliased typeAliased (Module ss coms mn ds exts) =
113 Module ss coms mn <$> mapM f' ds <*> pure exts
113 Module ss coms mn <$> mapM f' ds <*> pure exts
114 where
114 where
115− (goDecl', goExpr') = updateTypes goType
115+ (goDecl', goExpr', goBinder') = updateTypes goType
116 (f', _, _, _, _) =
116 (f', _, _, _, _) =
117 everywhereWithContextOnValuesM
117 everywhereWithContextOnValuesM
118 Nothing
118 Nothing
119 (\pos -> uncurry goDecl <=< goDecl' pos)
119 (\pos -> uncurry goDecl <=< goDecl' pos)
120 (\pos -> uncurry goExpr <=< goExpr' pos)
120 (\pos -> uncurry goExpr <=< goExpr' pos)
121− goBinder
121+ (\pos -> uncurry goBinder <=< goBinder' pos)
122 defS
122 defS
123 defS
123 defS
124
124
@@ -182,9 +182,9 @@ rebracketModule valueOpTable typeOpTable (Module ss coms mn ds exts) =
182 everywhereOnValuesTopDownM
182 everywhereOnValuesTopDownM
183 (decontextify goDecl)
183 (decontextify goDecl)
184 (goExpr <=< decontextify goExpr')
184 (goExpr <=< decontextify goExpr')
185− goBinder
185+ (goBinder <=< decontextify goBinder')
186
186
187− (goDecl, goExpr') = updateTypes (const goType)
187+ (goDecl, goExpr', goBinder') = updateTypes (const goType)
188
188
189 goExpr :: Expr -> m Expr
189 goExpr :: Expr -> m Expr
190 goExpr = return . matchExprOperators valueOpTable
190 goExpr = return . matchExprOperators valueOpTable
@@ -205,9 +205,9 @@ removeParens = f
205 everywhereOnValues
205 everywhereOnValues
206 (decontextify goDecl)
206 (decontextify goDecl)
207 (goExpr . decontextify goExpr')
207 (goExpr . decontextify goExpr')
208− goBinder
208+ (goBinder . decontextify goBinder')
209
209
210− (goDecl, goExpr') = updateTypes (\_ -> return . goType)
210+ (goDecl, goExpr', goBinder') = updateTypes (\_ -> return . goType)
211
211
212 goExpr :: Expr -> Expr
212 goExpr :: Expr -> Expr
213 goExpr (Parens val) = val
213 goExpr (Parens val) = val
@@ -294,10 +294,11 @@ updateTypes
294 :: forall m
294 :: forall m
295 . Monad m
295 . Monad m
296 => (Maybe SourceSpan -> Type -> m Type)
296 => (Maybe SourceSpan -> Type -> m Type)
297− -> ( Maybe SourceSpan -> Declaration -> m (Maybe SourceSpan, Declaration)
297+ -> ( Maybe SourceSpan -> Declaration -> m (Maybe SourceSpan, Declaration)
298− , Maybe SourceSpan -> Expr -> m (Maybe SourceSpan, Expr)
298+ , Maybe SourceSpan -> Expr -> m (Maybe SourceSpan, Expr)
299+ , Maybe SourceSpan -> Binder -> m (Maybe SourceSpan, Binder)
299 )
300 )
300−updateTypes goType = (goDecl, goExpr)
301+updateTypes goType = (goDecl, goExpr, goBinder)
301 where
302 where
302
303
303 goType' :: Maybe SourceSpan -> Type -> m Type
304 goType' :: Maybe SourceSpan -> Type -> m Type
@@ -339,6 +340,13 @@ updateTypes goType = (goDecl, goExpr)
339 return (pos, TypedValue check v ty')
340 return (pos, TypedValue check v ty')
340 goExpr pos other = return (pos, other)
341 goExpr pos other = return (pos, other)
341
342
343+ goBinder :: Maybe SourceSpan -> Binder -> m (Maybe SourceSpan, Binder)
344+ goBinder _ e@(PositionedBinder pos _ _) = return (Just pos, e)
345+ goBinder pos (TypedBinder ty b) = do
346+ ty' <- goType' pos ty
347+ return (pos, TypedBinder ty' b)
348+ goBinder pos other = return (pos, other)
349+
342-- |
350-- |
343-- Checks all the fixity exports within a module to ensure that members aliased
351-- Checks all the fixity exports within a module to ensure that members aliased
344-- by the operators are also exported from the module.
352-- by the operators are also exported from the module.