From bbf3554bd7d30d04424a7c3d0c85881707d54606 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Wed, 2 Oct 2019 12:23:59 -0400 Subject: [PATCH] Move and export the exception type. --- src/Parsing/TreeSitter.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Parsing/TreeSitter.hs b/src/Parsing/TreeSitter.hs index 04eaeb041..f66697ee0 100644 --- a/src/Parsing/TreeSitter.hs +++ b/src/Parsing/TreeSitter.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DataKinds, GADTs, LambdaCase, ScopedTypeVariables, TypeOperators #-} module Parsing.TreeSitter -( Duration(..) +( TSParseException (..) +, Duration(..) , parseToAST , parseToPreciseAST ) where @@ -30,6 +31,12 @@ import qualified TreeSitter.Parser as TS import qualified TreeSitter.Tree as TS import qualified TreeSitter.Unmarshal as TS +data TSParseException + = ParserTimedOut + | IncompatibleVersions + | UnmarshalFailure String + deriving (Eq, Show, Generic) + -- | Parse a 'Blob' with the given 'TS.Language' and return its AST. -- Returns 'Nothing' if the operation timed out. parseToAST :: ( Bounded grammar @@ -55,13 +62,6 @@ parseToPreciseAST parseTimeout language blob = runParse parseTimeout language bl runM (runFail (runReader cursor (runReader (Source.bytes (blobSource blob)) (TS.peekNode >>= TS.unmarshalNode)))) >>= either (Control.Exception.throw . UnmarshalFailure) pure - -data TSParseException - = ParserTimedOut - | IncompatibleVersions - | UnmarshalFailure String - deriving (Eq, Show, Generic) - instance Exception TSParseException where displayException = \case ParserTimedOut -> "tree-sitter: parser timed out"