1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +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.Field
, Syntax.FunctionConstructor
, Syntax.GADT
, Syntax.Identifier
, Syntax.ListConstructor
, Syntax.Module
@ -86,6 +87,7 @@ expressionChoices = [
, float
, functionConstructor
, functionDeclaration
, gadtDeclaration
, integer
, listConstructor
, listExpression
@ -180,6 +182,16 @@ functionDeclaration = makeTerm
<*> (manyTermsTill expression (symbol FunctionBody) <|> pure [])
<*> 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 = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source)
@ -203,7 +215,9 @@ parenthesizedTypePattern :: Assignment
parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children typeParameters
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)))
tuplingConstructor :: Assignment

View File

@ -144,3 +144,12 @@ instance Ord1 Class where liftCompare = genericLiftCompare
instance Show1 Class where liftShowsPrec = genericLiftShowsPrec
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) }
(TypeParameters))
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(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))
{+(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
{-(Empty)-}
{-(Type

View File

@ -60,120 +60,113 @@
{ (Identifier)
->(Identifier) }
(TypeParameters))
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{+(Constructor
{+(Empty)+}
{+(Identifier)+}
{+(TypeParameters)+})+}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
{-(Constructor
{-(Empty)-}
{-(Identifier)-}
{-(TypeParameters)-})-}
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Constructor
(Empty)
{ (Identifier)
->(Identifier) }
(TypeParameters))
(Empty))
(Datatype
(Empty)
(Type
{ (Identifier)
->(Identifier) }
(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))
{+(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
@ -194,74 +187,6 @@
{+(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
(Empty)
(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)))