@@ -14,7 +14,7 @@
14-----------------------------------------------------------------------------
14-----------------------------------------------------------------------------
16{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances, RankNTypes,
16{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances, RankNTypes,
17− MultiParamTypeClasses, FlexibleContexts #-}
17+ MultiParamTypeClasses, FlexibleContexts, GADTs #-}
19module Language.PureScript.TypeChecker.Monad where
19module Language.PureScript.TypeChecker.Monad where
@@ -22,7 +22,7 @@ import Data.Maybe
22import qualified Data.Map as M
22import qualified Data.Map as M
24import Control.Applicative
24import Control.Applicative
25−import Control.Monad.Error
25+import Control.Monad.Except
26import Control.Monad.Reader.Class
26import Control.Monad.Reader.Class
27import Control.Monad.State
27import Control.Monad.State
28import Control.Monad.Unify
28import Control.Monad.Unify
@@ -109,7 +109,7 @@ makeBindingGroupVisible action = do
110-- Lookup the type of a value by name in the @Environment@
110-- Lookup the type of a value by name in the @Environment@
112−lookupVariable :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m Type
112+lookupVariable :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m Type
113lookupVariable currentModule (Qualified moduleName var) = do
113lookupVariable currentModule (Qualified moduleName var) = do
114 env <- getEnv
114 env <- getEnv
115 case M.lookup (fromMaybe currentModule moduleName, var) (names env) of
115 case M.lookup (fromMaybe currentModule moduleName, var) (names env) of
@@ -119,7 +119,7 @@ lookupVariable currentModule (Qualified moduleName var) = do
120-- Lookup the visibility of a value by name in the @Environment@
120-- Lookup the visibility of a value by name in the @Environment@
122−getVisibility :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m NameVisibility
122+getVisibility :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m NameVisibility
123getVisibility currentModule (Qualified moduleName var) = do
123getVisibility currentModule (Qualified moduleName var) = do
124 env <- getEnv
124 env <- getEnv
125 case M.lookup (fromMaybe currentModule moduleName, var) (names env) of
125 case M.lookup (fromMaybe currentModule moduleName, var) (names env) of
@@ -129,7 +129,7 @@ getVisibility currentModule (Qualified moduleName var) = do
130-- Assert that a name is visible
130-- Assert that a name is visible
132−checkVisibility :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m ()
132+checkVisibility :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m ()
133checkVisibility currentModule name@(Qualified _ var) = do
133checkVisibility currentModule name@(Qualified _ var) = do
134 vis <- getVisibility currentModule name
134 vis <- getVisibility currentModule name
135 case vis of
135 case vis of
@@ -139,7 +139,7 @@ checkVisibility currentModule name@(Qualified _ var) = do
140-- Lookup the kind of a type by name in the @Environment@
140-- Lookup the kind of a type by name in the @Environment@
142−lookupTypeVariable :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified ProperName -> m Kind
142+lookupTypeVariable :: (e ~ ErrorStack, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified ProperName -> m Kind
143lookupTypeVariable currentModule (Qualified moduleName name) = do
143lookupTypeVariable currentModule (Qualified moduleName name) = do
144 env <- getEnv
144 env <- getEnv
145 case M.lookup (Qualified (Just $ fromMaybe currentModule moduleName) name) (types env) of
145 case M.lookup (Qualified (Just $ fromMaybe currentModule moduleName) name) (types env) of
@@ -172,7 +172,7 @@ data CheckState = CheckState {
172-- The type checking monad, which provides the state of the type checker, and error reporting capabilities
172-- The type checking monad, which provides the state of the type checker, and error reporting capabilities
174newtype Check a = Check { unCheck :: StateT CheckState (Either ErrorStack) a }
174newtype Check a = Check { unCheck :: StateT CheckState (Either ErrorStack) a }
175− deriving (Functor, Monad, Applicative, Alternative, MonadPlus, MonadState CheckState, MonadError ErrorStack)
175+ deriving (Functor, Monad, Applicative, MonadState CheckState, MonadError ErrorStack)
178-- Get the current @Environment@
178-- Get the current @Environment@