Skip to content

Commit 71fd1fb

Browse files
committed
Switch to using just Either instead of Error.
1 parent 9c89deb commit 71fd1fb

4 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/Language/Python/Common/LexerUtils.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
module Language.Python.Common.LexerUtils where
1515

1616
import Control.Monad (liftM)
17-
import Control.Monad.Error.Class (throwError)
1817
import Data.List (foldl')
1918
import Data.Word (Word8)
2019
import Language.Python.Common.Token as Token

src/Language/Python/Common/ParseError.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ module Language.Python.Common.ParseError ( ParseError (..) ) where
1414

1515
import Language.Python.Common.SrcLocation (SrcLocation)
1616
import Language.Python.Common.Token (Token)
17-
import Control.Monad.Error.Class
1817

1918
data ParseError
2019
= UnexpectedToken Token -- ^ An error from the parser. Token found where it should not be. Note: tokens contain their own source span.
2120
| UnexpectedChar Char SrcLocation -- ^ An error from the lexer. Character found where it should not be.
2221
| StrError String -- ^ A generic error containing a string message. No source location.
2322
deriving (Eq, Ord, Show)
24-
25-
instance Error ParseError where
26-
noMsg = StrError ""
27-
strMsg = StrError

src/Language/Python/Common/ParserMonad.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module Language.Python.Common.ParserMonad
4343
, addComment
4444
, getComments
4545
, spanError
46+
, throwError
4647
) where
4748

4849
import Language.Python.Common.SrcLocation (SrcLocation (..), SrcSpan (..), Span (..))
@@ -51,7 +52,6 @@ import Language.Python.Common.ParseError (ParseError (..))
5152
import Control.Applicative ((<$>))
5253
import Control.Monad.State.Class
5354
import Control.Monad.State.Strict as State
54-
import Control.Monad.Error as Error
5555
import Language.Python.Common.Pretty
5656

5757
internalError :: String -> P a
@@ -91,6 +91,9 @@ initialState initLoc inp scStack
9191

9292
type P a = StateT ParseState (Either ParseError) a
9393

94+
throwError :: ParseError -> P a
95+
throwError = lift . Left
96+
9497
execParser :: P a -> ParseState -> Either ParseError a
9598
execParser = evalStateT
9699

src/Language/Python/Common/ParserUtils.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module Language.Python.Common.ParserUtils where
1515

1616
import Data.List (foldl')
1717
import Data.Maybe (isJust)
18-
import Control.Monad.Error.Class (throwError)
1918
import Language.Python.Common.AST as AST
2019
import Language.Python.Common.Token as Token
2120
import Language.Python.Common.ParserMonad hiding (location)

0 commit comments

Comments
 (0)