1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Assign GADT declarations without constructors

This commit is contained in:
Rick Winfrey 2018-06-05 12:26:42 -07:00
parent e2dba7cd28
commit 97c71544ea
10 changed files with 280 additions and 362 deletions

View File

@ -41,6 +41,7 @@ type Syntax = '[
, Syntax.Error , Syntax.Error
, Syntax.Field , Syntax.Field
, Syntax.FunctionConstructor , Syntax.FunctionConstructor
, Syntax.GADT
, Syntax.Identifier , Syntax.Identifier
, Syntax.ListConstructor , Syntax.ListConstructor
, Syntax.Module , Syntax.Module
@ -86,6 +87,7 @@ expressionChoices = [
, float , float
, functionConstructor , functionConstructor
, functionDeclaration , functionDeclaration
, gadtDeclaration
, integer , integer
, listConstructor , listConstructor
, listExpression , listExpression
@ -180,6 +182,16 @@ functionDeclaration = makeTerm
<*> (manyTermsTill expression (symbol FunctionBody) <|> pure []) <*> (manyTermsTill expression (symbol FunctionBody) <|> pure [])
<*> functionBody) <*> functionBody)
gadtDeclaration :: Assignment
gadtDeclaration = makeTerm
<$> symbol GadtDeclaration
<*> children (Syntax.GADT
<$> (context' <|> emptyTerm)
<*> (makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParameters'))
<*> where')
where
typeParameters' = makeTerm <$> location <*> (manyTermsTill expression (symbol Where'))
integer :: Assignment integer :: Assignment
integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source) integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source)
@ -203,7 +215,9 @@ parenthesizedTypePattern :: Assignment
parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children typeParameters parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children typeParameters
strictType :: Assignment strictType :: Assignment
strictType = makeTerm' <$> symbol StrictType <*> children ((inject <$> (Syntax.StrictType <$> typeConstructor <*> typeParameters)) strictType = makeTerm'
<$> symbol StrictType
<*> children ( (inject <$> (Syntax.StrictType <$> typeConstructor <*> typeParameters))
<|> (inject <$> (Syntax.StrictTypeVariable <$> typeVariableIdentifier))) <|> (inject <$> (Syntax.StrictTypeVariable <$> typeVariableIdentifier)))
tuplingConstructor :: Assignment tuplingConstructor :: Assignment

View File

@ -144,3 +144,12 @@ instance Ord1 Class where liftCompare = genericLiftCompare
instance Show1 Class where liftShowsPrec = genericLiftShowsPrec instance Show1 Class where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Class instance Evaluatable Class
data GADT a = GADT { gadtContext :: a, gadtName :: a, gadtConstructors :: a }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable)
instance Eq1 GADT where liftEq = genericLiftEq
instance Ord1 GADT where liftCompare = genericLiftCompare
instance Show1 GADT where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable GADT

View File

@ -60,191 +60,113 @@
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(TypeParameters)) (TypeParameters))
{+(Constructor (Constructor
{+(Empty)+} (Empty)
{+(Identifier)+} { (Identifier)
{+(TypeParameters)+})+} ->(Identifier) }
{+(Constructor (TypeParameters))
{+(Empty)+} (Constructor
{+(Identifier)+} (Empty)
{+(TypeParameters)+})+} { (Identifier)
{+(Constructor ->(Identifier) }
{+(Empty)+} (TypeParameters))
{+(Identifier)+} (Constructor
{+(TypeParameters)+})+} (Empty)
{+(Constructor { (Identifier)
{+(Empty)+} ->(Identifier) }
{+(Identifier)+} (TypeParameters))
{+(TypeParameters)+})+} (Constructor
{+(Constructor (Empty)
{+(Empty)+} { (Identifier)
{+(Identifier)+} ->(Identifier) }
{+(TypeParameters)+})+} (TypeParameters))
{+(Constructor (Constructor
{+(Empty)+} (Empty)
{+(Identifier)+} { (Identifier)
{+(TypeParameters)+})+} ->(Identifier) }
{-(Constructor (TypeParameters))
{-(Empty)-} (Constructor
{-(Identifier)-} (Empty)
{-(TypeParameters)-})-} { (Identifier)
{-(Constructor ->(Identifier) }
{-(Empty)-} (TypeParameters))
{-(Identifier)-} (Empty))
{-(TypeParameters)-})-} (Datatype
{-(Constructor (Empty)
{-(Empty)-} (Type
{-(Identifier)-} { (Identifier)
{-(TypeParameters)-})-} ->(Identifier) }
{-(Constructor (TypeParameters))
{-(Empty)-} (RecordDataConstructor
{-(Identifier)-} { (Identifier)
{-(TypeParameters)-})-} ->(Identifier) }
{-(Constructor (Statements
{-(Empty)-} (Field
{-(Identifier)-} (Statements
{-(TypeParameters)-})-} (Identifier))
{-(Constructor (Identifier))))
{-(Empty)-} (Empty))
{-(Identifier)-} (Datatype
{-(TypeParameters)-})-} (Empty)
(Type
{ (Identifier)
->(Identifier) }
(TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier)
(Identifier))
(Identifier))))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier))
(StrictType
(Identifier)
(TypeParameters)))
(Field
(Statements
(Identifier))
(Identifier))))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier)
(Identifier))
(Context
(Pragma)
(StrictType
(Identifier)
(TypeParameters))))
(Field
(Statements
(Identifier))
(Identifier))))
(Empty)) (Empty))
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(StrictType
{+(Identifier)+}
{+(TypeParameters)+})+})+}
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+}
{+(Identifier)+})+}
{+(Context
{+(Pragma)+}
{+(StrictType
{+(Identifier)+}
{+(TypeParameters)+})+})+})+}
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(StrictType
{-(Identifier)-}
{-(TypeParameters)-})-})-}
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-}
{-(Identifier)-})-}
{-(Context
{-(Pragma)-}
{-(StrictType
{-(Identifier)-}
{-(TypeParameters)-})-})-})-}
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype {-(Datatype
{-(Empty)-} {-(Empty)-}
{-(Type {-(Type

View File

@ -60,120 +60,113 @@
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(TypeParameters)) (TypeParameters))
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
(Constructor (Constructor
(Empty) (Empty)
{ (Identifier) { (Identifier)
->(Identifier) } ->(Identifier) }
(TypeParameters)) (TypeParameters))
{+(Constructor (Constructor
{+(Empty)+} (Empty)
{+(Identifier)+} { (Identifier)
{+(TypeParameters)+})+} ->(Identifier) }
{+(Constructor (TypeParameters))
{+(Empty)+} (Constructor
{+(Identifier)+} (Empty)
{+(TypeParameters)+})+} { (Identifier)
{+(Constructor ->(Identifier) }
{+(Empty)+} (TypeParameters))
{+(Identifier)+} (Constructor
{+(TypeParameters)+})+} (Empty)
{-(Constructor { (Identifier)
{-(Empty)-} ->(Identifier) }
{-(Identifier)-} (TypeParameters))
{-(TypeParameters)-})-} (Constructor
{-(Constructor (Empty)
{-(Empty)-} { (Identifier)
{-(Identifier)-} ->(Identifier) }
{-(TypeParameters)-})-} (TypeParameters))
{-(Constructor (Constructor
{-(Empty)-} (Empty)
{-(Identifier)-} { (Identifier)
{-(TypeParameters)-})-} ->(Identifier) }
{-(Constructor (TypeParameters))
{-(Empty)-} (Empty))
{-(Identifier)-} (Datatype
{-(TypeParameters)-})-} (Empty)
{-(Constructor (Type
{-(Empty)-} { (Identifier)
{-(Identifier)-} ->(Identifier) }
{-(TypeParameters)-})-} (TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier))
(Identifier))))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier)
(Identifier))
(Identifier))))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier))
(StrictType
(Identifier)
(TypeParameters)))
(Field
(Statements
(Identifier))
(Identifier))))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(TypeParameters))
(RecordDataConstructor
{ (Identifier)
->(Identifier) }
(Statements
(Field
(Statements
(Identifier)
(Identifier))
(Context
(Pragma)
(StrictType
(Identifier)
(TypeParameters))))
(Field
(Statements
(Identifier))
(Identifier))))
(Empty)) (Empty))
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(StrictType
{+(Identifier)+}
{+(TypeParameters)+})+})+}
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype
{+(Empty)+}
{+(Type
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(RecordDataConstructor
{+(Identifier)+}
{+(Statements
{+(Field
{+(Statements
{+(Identifier)+}
{+(Identifier)+})+}
{+(Context
{+(Pragma)+}
{+(StrictType
{+(Identifier)+}
{+(TypeParameters)+})+})+})+}
{+(Field
{+(Statements
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Empty)+})+}
{+(Datatype {+(Datatype
{+(Empty)+} {+(Empty)+}
{+(Type {+(Type
@ -194,74 +187,6 @@
{+(Identifier)+})+} {+(Identifier)+})+}
{+(Identifier)+})+})+})+} {+(Identifier)+})+})+})+}
{+(Empty)+})+} {+(Empty)+})+}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(StrictType
{-(Identifier)-}
{-(TypeParameters)-})-})-}
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
{-(Datatype
{-(Empty)-}
{-(Type
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(RecordDataConstructor
{-(Identifier)-}
{-(Statements
{-(Field
{-(Statements
{-(Identifier)-}
{-(Identifier)-})-}
{-(Context
{-(Pragma)-}
{-(StrictType
{-(Identifier)-}
{-(TypeParameters)-})-})-})-}
{-(Field
{-(Statements
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Empty)-})-}
(Datatype (Datatype
(Empty) (Empty)
(Type (Type

View File

@ -0,0 +1 @@
data Foo a b c where

View File

@ -0,0 +1 @@
data Bar a b c where

View File

@ -0,0 +1,12 @@
(Module
(Empty)
(GADT
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(Statements
(Identifier)
(Identifier)
(Identifier)))
(Statements)))

View File

@ -0,0 +1,12 @@
(Module
(Empty)
(GADT
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(Statements
(Identifier)
(Identifier)
(Identifier)))
(Statements)))

View File

@ -0,0 +1,11 @@
(Module
(Empty)
(GADT
(Empty)
(Type
(Identifier)
(Statements
(Identifier)
(Identifier)
(Identifier)))
(Statements)))

View File

@ -0,0 +1,11 @@
(Module
(Empty)
(GADT
(Empty)
(Type
(Identifier)
(Statements
(Identifier)
(Identifier)
(Identifier)))
(Statements)))