From f87a5039a75527cd14b817ef217b03a834acd2c6 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 12 Jul 2017 08:18:03 -0700 Subject: [PATCH] Go back to original Syntax.Empty --- src/Data/Syntax.hs | 2 +- src/Language/Python/Syntax.hs | 6 +++--- src/Language/Ruby/Syntax.hs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index 173017b18..995e44d2f 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -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 (Maybe ByteString) +data Empty a = Empty deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) instance Eq1 Empty where liftEq _ _ _ = True diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index 7c8443ffb..f51f13764 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -203,8 +203,8 @@ functionDefinition = (symbol FunctionDefinition >>= \ loc -> children (makeFunc <|> (symbol AsyncFunctionDefinition >>= \ loc -> children (makeAsyncFunctionDeclaration loc <$> async' <*> identifier <*> (symbol Parameters *> children (many expression)) <*> (optional (symbol Type *> children expression)) <*> (makeTerm <$> location <*> many declaration))) <|> (symbol Lambda >>= \ loc -> children (makeFunctionDeclaration loc <$> (makeTerm <$> symbol AnonLambda <*> (Syntax.Identifier <$> source)) <*> ((symbol LambdaParameters *> children (many expression)) <|> (pure [])) <*> (optional (symbol Type *> children expression)) <*> (makeTerm <$> location <*> many declaration))) where - makeFunctionDeclaration loc functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc (Syntax.Empty Nothing)) identity ty) - makeAsyncFunctionDeclaration loc async' functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc (Syntax.Empty Nothing)) identity ty)) async' + makeFunctionDeclaration loc functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc Syntax.Empty) identity ty) + makeAsyncFunctionDeclaration loc async' functionName' functionParameters ty functionBody = makeTerm loc $ Type.Annotation (makeTerm loc $ Type.Annotation (makeTerm loc $ Declaration.Function functionName' functionParameters functionBody) (maybe (makeTerm loc Syntax.Empty) identity ty)) async' async' :: Assignment async' = makeTerm <$> symbol AnonAsync <*> (Syntax.Identifier <$> source) @@ -449,7 +449,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 Nothing) +emptyTerm = makeTerm <$> location <*> pure Syntax.Empty handleError :: Assignment -> Assignment handleError = flip catchError $ \ error -> case errorCause error of diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 0044d8e1b..2432b6f4e 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -386,7 +386,7 @@ conditional :: Assignment conditional = makeTerm <$> symbol Conditional <*> children (Statement.If <$> statement <*> statement <*> statement) emptyStatement :: Assignment -emptyStatement = makeTerm <$> symbol EmptyStatement <*> (Syntax.Empty <$> (Just <$> source)) +emptyStatement = makeTerm <$> symbol EmptyStatement <*> pure Syntax.Empty -- Helper functions @@ -395,7 +395,7 @@ makeTerm :: (f :< fs, HasCallStack) => a -> f (Term.Term (Union fs) a) -> Term.T makeTerm a f = cofree $ a :< inj f emptyTerm :: Assignment -emptyTerm = makeTerm <$> location <*> pure (Syntax.Empty Nothing) +emptyTerm = makeTerm <$> location <*> pure Syntax.Empty 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