git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1586 from purescript/1465
dc54fafPhil Freeman
src/Language/PureScript/TypeChecker/Monad.hs+8−2
@@ -24,6 +24,7 @@
24module Language.PureScript.TypeChecker.Monad where
24module Language.PureScript.TypeChecker.Monad where
25
25
26import Data.Maybe
26import Data.Maybe
27+import Data.Foldable (for_)
27import qualified Data.Map as M
28import qualified Data.Map as M
28
29
29#if __GLASGOW_HASKELL__ < 710
30#if __GLASGOW_HASKELL__ < 710
@@ -67,8 +68,13 @@ bindTypes newNames action = do
67-- |
68-- |
68-- Temporarily bind a collection of names to types
69-- Temporarily bind a collection of names to types
69--
70--
70−withScopedTypeVars :: (Functor m, MonadState CheckState m) => ModuleName -> [(String, Kind)] -> m a -> m a
71+withScopedTypeVars :: (Functor m, Applicative m, MonadState CheckState m, MonadWriter MultipleErrors m) => ModuleName -> [(String, Kind)] -> m a -> m a
72+withScopedTypeVars mn ks ma = do
73+ orig <- get
74+ for_ ks $ \(name, _) ->
75+ when (Qualified (Just mn) (ProperName name) `M.member` types (checkEnv orig)) $
76+ tell . errorMessage $ ShadowedTypeVar name
71−withScopedTypeVars mn ks = bindTypes (M.fromList (map (\(name, k) -> (Qualified (Just mn) (ProperName name), (k, ScopedTypeVar))) ks))
77+ bindTypes (M.fromList (map (\(name, k) -> (Qualified (Just mn) (ProperName name), (k, ScopedTypeVar))) ks)) ma
72
78
73-- |
79-- |
74-- Temporarily make a collection of type class dictionaries available
80-- Temporarily make a collection of type class dictionaries available