1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Define a catamorphism determining whether a term contains parse errors.

This commit is contained in:
Rob Rix 2017-07-23 14:40:30 -04:00
parent 93f653b765
commit 8b3b6f36e2

View File

@ -227,6 +227,11 @@ runParser options parser blob@Blob{..} = case parser of
errorTerm :: Syntax.Error :< fs => Source -> Term (Union fs) (Record Assignment.Location)
errorTerm source = cofree ((totalRange source :. totalSpan source :. Nil) :< inj (Syntax.Error []))
hasErrors :: (Syntax.Error :< fs, Foldable (Union fs), Functor (Union fs)) => Term (Union fs) (Record Assignment.Location) -> Bool
hasErrors = cata $ \ (_ :< syntax) -> case syntax of
_ | Just err <- prj syntax -> const True (err :: Syntax.Error Bool)
_ -> or syntax
instance MonadIO Task where
liftIO action = LiftIO action `Then` return