1
1
mirror of https://github.com/github/semantic.git synced 2024-11-27 12:57:49 +03:00

Assign lambdas

This commit is contained in:
Rick Winfrey 2018-06-12 14:50:38 -07:00
parent 00e299ad25
commit c53dab76cf
12 changed files with 296 additions and 98 deletions

View File

@ -69,6 +69,7 @@ type Syntax = '[
, Syntax.KindFunctionType
, Syntax.KindListType
, Syntax.KindSignature
, Syntax.Lambda
, Syntax.ListComprehension
, Syntax.ListConstructor
, Syntax.Module
@ -234,6 +235,7 @@ expressionChoices = [
, integer
, kind
, kindSignature
, lambda
, listConstructor
, listComprehension
, listExpression
@ -391,6 +393,12 @@ kindListType = makeTerm <$> symbol KindListType <*> children (Syntax.KindListTyp
kindSignature :: Assignment
kindSignature = makeTerm <$> symbol KindSignature <*> children (Syntax.KindSignature <$ token Annotation <*> kind)
lambda :: Assignment
lambda = makeTerm <$> symbol Lambda <*> children (Syntax.Lambda <$> lambdaHead <*> lambdaBody)
where
lambdaHead = symbol LambdaHead *> children (expressions)
lambdaBody = symbol LambdaBody *> children (expressions)
listComprehension :: Assignment
listComprehension = makeTerm <$> symbol ListComprehension <*> children (Syntax.ListComprehension <$> expression <*> manyTerm expression)

View File

@ -542,3 +542,12 @@ instance Ord1 Do where liftCompare = genericLiftCompare
instance Show1 Do where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Do
data Lambda a = Lambda { lambdaHead :: a, lambdaBody :: a }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable)
instance Eq1 Lambda where liftEq = genericLiftEq
instance Ord1 Lambda where liftCompare = genericLiftCompare
instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Lambda

View File

@ -70,9 +70,6 @@
{ (ConstructorIdentifier)
->(ConstructorIdentifier) }
(TypeParameters))
{+(Constructor
{+(ConstructorIdentifier)+}
{+(TypeParameters)+})+}
(Constructor
{ (ConstructorIdentifier)
->(ConstructorIdentifier) }
@ -83,6 +80,9 @@
{+(Constructor
{+(ConstructorIdentifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(ConstructorIdentifier)+}
{+(TypeParameters)+})+}
{-(Constructor
{-(ConstructorIdentifier)-}
{-(TypeParameters)-})-}

View File

@ -70,6 +70,10 @@
{ (ConstructorIdentifier)
->(ConstructorIdentifier) }
(TypeParameters))
(Constructor
{ (ConstructorIdentifier)
->(ConstructorIdentifier) }
(TypeParameters))
{+(Constructor
{+(ConstructorIdentifier)+}
{+(TypeParameters)+})+}
@ -79,12 +83,6 @@
{+(Constructor
{+(ConstructorIdentifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(ConstructorIdentifier)+}
{+(TypeParameters)+})+}
{-(Constructor
{-(ConstructorIdentifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(ConstructorIdentifier)-}
{-(TypeParameters)-})-}

View File

@ -40,3 +40,11 @@ parseJSON (JSON.Object r) = IncPK <$>
f = do
a <- b =<< c
b <- e >>= g
f = \ x -> x
f = \ (Just a) -> a
f = \ x -> x : a : xs
f = \ g a b -> g <$> a <*> b

View File

@ -40,3 +40,11 @@ parseJSON (JSON.Object s) = IncPK <$>
g = do
b <- d =<< e
c <- f >>= h
g = \ x -> x
g = \ (Just a) -> a
g = \ x -> x : a : xs
g = \ g a b -> g <$> a <*> b

View File

@ -239,48 +239,31 @@
->(VariableIdentifier) }
(ConstructorOperator
(ConstructorSymbol)))))
{+(Function
{+(VariableIdentifier)+}
{+(Statements
{+(LeftOperatorSection
{+(VariableIdentifier)+}
{+(ConstructorOperator
{+(ConstructorSymbol)+})+})+})+})+}
{+(Function
{+(VariableIdentifier)+}
{+(Statements
{+(InfixOperatorApp
{+(VariableIdentifier)+}
{+(VariableOperator
{+(InfixVariableIdentifier)+})+}
{+(VariableIdentifier)+})+})+})+}
{+(Function
{+(VariableIdentifier)+}
{+(Statements
{+(QualifiedConstructorIdentifier
{+(ModuleIdentifier)+}
{+(ConstructorIdentifier)+})+})+})+}
{-(Function
{-(VariableIdentifier)-}
{-(Statements
{-(LeftOperatorSection
{-(VariableIdentifier)-}
{-(ConstructorOperator
{-(ConstructorSymbol)-})-})-})-})-}
{-(Function
{-(VariableIdentifier)-}
{-(Statements
{-(InfixOperatorApp
{-(VariableIdentifier)-}
{-(VariableOperator
{-(InfixVariableIdentifier)-})-}
{-(VariableIdentifier)-})-})-})-}
{-(Function
{-(VariableIdentifier)-}
{-(Statements
{-(QualifiedConstructorIdentifier
{-(ModuleIdentifier)-}
{-(ConstructorIdentifier)-})-})-})-}
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(LeftOperatorSection
{ (VariableIdentifier)
->(VariableIdentifier) }
(ConstructorOperator
(ConstructorSymbol)))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(InfixVariableIdentifier))
(VariableIdentifier))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(QualifiedConstructorIdentifier
(ModuleIdentifier)
(ConstructorIdentifier))))
(Function
(VariableIdentifier)
(ConstructorPattern
@ -352,4 +335,54 @@
(VariableOperator
(VariableSymbol))
{ (VariableIdentifier)
->(VariableIdentifier) })))))))
->(VariableIdentifier) })))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(VariableIdentifier)
(VariableIdentifier))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(ConstructorPattern
(Statements
(ConstructorIdentifier)
(VariableIdentifier)))
(VariableIdentifier))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(VariableIdentifier)
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(VariableIdentifier))))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(Statements
(VariableIdentifier)
(VariableIdentifier)
(VariableIdentifier))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(VariableIdentifier))))))))

View File

@ -239,20 +239,15 @@
->(VariableIdentifier) }
(ConstructorOperator
(ConstructorSymbol)))))
{+(Function
{+(VariableIdentifier)+}
{+(Statements
{+(LeftOperatorSection
{+(VariableIdentifier)+}
{+(ConstructorOperator
{+(ConstructorSymbol)+})+})+})+})+}
{-(Function
{-(VariableIdentifier)-}
{-(Statements
{-(LeftOperatorSection
{-(VariableIdentifier)-}
{-(ConstructorOperator
{-(ConstructorSymbol)-})-})-})-})-}
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(LeftOperatorSection
{ (VariableIdentifier)
->(VariableIdentifier) }
(ConstructorOperator
(ConstructorSymbol)))))
{-(Function
{-(VariableIdentifier)-}
{-(Statements
@ -332,12 +327,16 @@
{-(VariableOperator
{-(VariableSymbol)-})-}
{-(VariableIdentifier)-})-})-})-}))
{+(Function
{+(VariableIdentifier)+}
{+(Statements
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
{+(QualifiedConstructorIdentifier
{+(ModuleIdentifier)+}
{+(ConstructorIdentifier)+})+})+})+}
{+(ConstructorIdentifier)+})+}
{-(Lambda
{-(VariableIdentifier)-}
{-(VariableIdentifier)-})-}))
{+(Function
{+(VariableIdentifier)+}
{+(ConstructorPattern
@ -397,4 +396,53 @@
{+(VariableIdentifier)+}
{+(VariableOperator
{+(VariableSymbol)+})+}
{+(VariableIdentifier)+})+})+})+})+})+}))
{+(VariableIdentifier)+})+})+})+})+})+}
{+(Function
{+(VariableIdentifier)+}
{+(Statements
{+(Lambda
{+(VariableIdentifier)+}
{+(VariableIdentifier)+})+})+})+}
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(ConstructorPattern
(Statements
(ConstructorIdentifier)
(VariableIdentifier)))
(VariableIdentifier))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(VariableIdentifier)
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(VariableIdentifier))))))
(Function
{ (VariableIdentifier)
->(VariableIdentifier) }
(Statements
(Lambda
(Statements
(VariableIdentifier)
(VariableIdentifier)
(VariableIdentifier))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(VariableIdentifier))))))))

View File

@ -275,6 +275,52 @@
(VariableIdentifier)))
(BindPattern
(VariableIdentifier)
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(VariableIdentifier))))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(VariableIdentifier)
(VariableIdentifier))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(ConstructorPattern
(Statements
(ConstructorIdentifier)
(VariableIdentifier)))
(VariableIdentifier))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(VariableIdentifier)
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(VariableIdentifier))))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(Statements
(VariableIdentifier)
(VariableIdentifier)
(VariableIdentifier))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator

View File

@ -277,6 +277,52 @@
(VariableIdentifier)))
(BindPattern
(VariableIdentifier)
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(VariableIdentifier))))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(VariableIdentifier)
(VariableIdentifier))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(ConstructorPattern
(Statements
(ConstructorIdentifier)
(VariableIdentifier)))
(VariableIdentifier))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(VariableIdentifier)
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(InfixOperatorApp
(VariableIdentifier)
(ConstructorOperator
(ConstructorSymbol))
(VariableIdentifier))))))
(Function
(VariableIdentifier)
(Statements
(Lambda
(Statements
(VariableIdentifier)
(VariableIdentifier)
(VariableIdentifier))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator
(VariableSymbol))
(InfixOperatorApp
(VariableIdentifier)
(VariableOperator

View File

@ -52,17 +52,17 @@
(TypeConstructorIdentifier))
(TypePattern
(TupleConstructor)))
(TypeSynonym
(Statements
(TypeConstructorIdentifier))
(TypePattern
{ (FunctionConstructor)
->(TupleConstructor) }))
{+(TypeSynonym
{+(Statements
{+(TypeConstructorIdentifier)+})+}
{+(TypePattern
{+(TupleConstructor)+})+})+}
(TypeSynonym
(Statements
{ (TypeConstructorIdentifier)
->(TypeConstructorIdentifier) })
(TypePattern
(FunctionConstructor)))
{+(FunctionConstructor)+})+})+}
(TypeSynonym
(Statements
(TypeConstructorIdentifier))

View File

@ -52,11 +52,12 @@
(TypeConstructorIdentifier))
(TypePattern
(TupleConstructor)))
{+(TypeSynonym
{+(Statements
{+(TypeConstructorIdentifier)+})+}
{+(TypePattern
{+(FunctionConstructor)+})+})+}
(TypeSynonym
(Statements
(TypeConstructorIdentifier))
(TypePattern
{ (TupleConstructor)
->(FunctionConstructor) }))
{+(TypeSynonym
{+(Statements
{+(TypeConstructorIdentifier)+})+}
@ -114,11 +115,14 @@
{+(TypeConstructorIdentifier)+}
{+(TypeVariableIdentifier)+})+})+}
{+(Empty)+})+})+})+})+})+}
{+(TypeSynonym
{+(Statements
{+(TypeConstructorIdentifier)+}
{+(TypeConstructorIdentifier)+})+}
{+(TextElement)+})+}
(TypeSynonym
(Statements
{ (TypeConstructorIdentifier)
->(TypeConstructorIdentifier) }
{+(TypeConstructorIdentifier)+})
{ (TypePattern
{-(FunctionConstructor)-})
->(TextElement) })
{+(TypeSynonym
{+(Statements
{+(TypeConstructorIdentifier)+}
@ -167,16 +171,6 @@
{+(TypeConstructorIdentifier)+}
{+(TypeVariableIdentifier)+}
{+(TypeVariableIdentifier)+})+})+})+})+}
{-(TypeSynonym
{-(Statements
{-(TypeConstructorIdentifier)-})-}
{-(TypePattern
{-(TupleConstructor)-})-})-}
{-(TypeSynonym
{-(Statements
{-(TypeConstructorIdentifier)-})-}
{-(TypePattern
{-(FunctionConstructor)-})-})-}
{-(TypeSynonym
{-(Statements
{-(TypeConstructorIdentifier)-})-}