1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Two version of empty

This commit is contained in:
Timothy Clem 2017-06-16 15:52:11 -06:00
parent e29a17b26b
commit ef9886972d
3 changed files with 5 additions and 6 deletions

View File

@ -36,7 +36,7 @@ instance Show1 Identifier where liftShowsPrec = genericLiftShowsPrec
-- | Empty syntax, with essentially no-op semantics.
--
-- This can be used to represent an implicit no-op, e.g. the alternative in an 'if' statement without an 'else'.
data Empty a = Empty
data Empty a = Empty (Maybe ByteString)
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
instance Eq1 Empty where liftEq _ _ _ = True

View File

@ -358,7 +358,7 @@ makeTerm :: (HasCallStack, f :< fs) => a -> f (Term.Term (Union fs) a) -> Term.T
makeTerm a f = cofree (a :< inj f)
emptyTerm :: Assignment
emptyTerm = makeTerm <$> location <*> pure Syntax.Empty
emptyTerm = makeTerm <$> location <*> pure (Syntax.Empty Nothing)
handleError :: Assignment -> Assignment
handleError = flip catchError $ \ error -> case errorCause error of

View File

@ -189,16 +189,15 @@ while' =
-- <|> makeTerm <$> symbol AnonCaretEqual <*> (Expression.BXOr var <$> expression)))
emptyStatement :: Assignment
emptyStatement = makeTerm <$> symbol EmptyStatement <*> children (Syntax.Identifier <$> source)
emptyStatement = makeTerm <$> symbol EmptyStatement <*> (Syntax.Empty <$> (Just <$> source))
--
makeTerm :: (f :< fs, HasCallStack) => a -> f (Term.Term (Union fs) a) -> Term.Term (Union fs) a
makeTerm a f = cofree $ a :< inj f
emptyTerm :: Assignment
emptyTerm = makeTerm <$> location <*> pure Syntax.Empty
emptyTerm = makeTerm <$> location <*> pure (Syntax.Empty Nothing)
invert :: (Expression.Boolean :< fs, HasCallStack) => Assignment.Assignment ast grammar (Term.Term (Union fs) (Record Location)) -> Assignment.Assignment ast grammar (Term.Term (Union fs) (Record Location))
invert term = makeTerm <$> location <*> fmap Expression.Not term