From e2dba7cd28c48fd1384e298c232fbe7151c1e29a Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 5 Jun 2018 11:32:40 -0700 Subject: [PATCH 01/11] Assign contexts per constructor --- src/Data/Syntax/Declaration.hs | 2 +- src/Language/Go/Assignment.hs | 2 +- src/Language/Haskell/Assignment.hs | 2 +- .../algebraic-datatype-declarations.A.hs | 3 + .../algebraic-datatype-declarations.B.hs | 3 + ...lgebraic-datatype-declarations.diffA-B.txt | 291 ++++++++++++------ ...lgebraic-datatype-declarations.diffB-A.txt | 274 ++++++++++++----- ...algebraic-datatype-declarations.parseA.txt | 43 +++ ...algebraic-datatype-declarations.parseB.txt | 43 +++ 9 files changed, 493 insertions(+), 170 deletions(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index 3bf92cbda..c669a538c 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -194,7 +194,7 @@ instance Evaluatable Data.Syntax.Declaration.Datatype -- | A single constructor in a datatype, or equally a 'struct' in C, Rust, or Swift. -data Constructor a = Constructor { constructorName :: !a, constructorFields :: !a } +data Constructor a = Constructor { constructorContext :: a, constructorName :: a, constructorFields :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Data.Syntax.Declaration.Constructor where liftEq = genericLiftEq diff --git a/src/Language/Go/Assignment.hs b/src/Language/Go/Assignment.hs index 4564836a6..dd87bde0f 100644 --- a/src/Language/Go/Assignment.hs +++ b/src/Language/Go/Assignment.hs @@ -307,7 +307,7 @@ sliceType :: Assignment sliceType = makeTerm <$> symbol SliceType <*> children (Type.Slice <$> expression) structType :: Assignment -structType = makeTerm <$> symbol StructType <*> children (Declaration.Constructor <$> emptyTerm <*> expressions) +structType = makeTerm <$> symbol StructType <*> children (Declaration.Constructor <$> emptyTerm <*> emptyTerm <*> expressions) typeAlias :: Assignment typeAlias = makeTerm <$> symbol TypeAlias <*> children (Declaration.TypeAlias [] <$> expression <*> expression) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 524d5b34b..b15f1f716 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -120,7 +120,7 @@ comment :: Assignment comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) constructor :: Assignment -constructor = (makeTerm <$> symbol DataConstructor <*> children (Declaration.Constructor <$> typeConstructor <*> typeParameters)) +constructor = (makeTerm <$> symbol DataConstructor <*> children (Declaration.Constructor <$> (context' <|> emptyTerm) <*> typeConstructor <*> typeParameters)) <|> (makeTerm <$> symbol RecordDataConstructor <*> children (Syntax.RecordDataConstructor <$> constructorIdentifier <*> fields)) class' :: Assignment diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.A.hs b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.A.hs index e4cadf473..0496329da 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.A.hs +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.A.hs @@ -23,3 +23,6 @@ data N = N deriving (Eq, Ord, Enum, Bounded, Show, Read) data Show a => N a = N a data (Eq a, Show a, Eq b) => N a b = N a b data (Eq (f a), Functor f) => N f a = N f a + +data Foo bar = HasCallStack => Foo bar +data Baz foo = Show foo => Baz foo diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.B.hs b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.B.hs index 51ab98920..d870e1525 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.B.hs +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.B.hs @@ -23,3 +23,6 @@ data N = N deriving (Functor, Ord, Enum, Bounded, Show, Read) data Monad a => N a = N a data (Ord a, Show a, Eq b) => N a b = N a b data (Eq (f a), Applicative f) => N f a = N f a + +data Foo bar = HasCallStack => Wiz bar +data Baz a = Show a => Baz a diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index 79e846b8a..ffee4ef04 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -16,6 +16,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) { (Identifier) ->(Identifier) } (TypeParameters @@ -29,6 +30,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) { (Identifier) ->(Identifier) } (TypeParameters @@ -44,6 +46,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) { (Identifier) ->(Identifier) } (TypeParameters @@ -58,114 +61,190 @@ ->(Identifier) } (TypeParameters)) {+(Constructor + {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} {+(Constructor - {+(Identifier)+} - {+(TypeParameters)+})+} - (Constructor - { (Identifier) - ->(Identifier) } - (TypeParameters)) - {+(Constructor + {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} {+(Constructor + {+(Empty)+} + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(Empty)+} + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(Empty)+} + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} - (Constructor - { (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)-})-} (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 @@ -232,6 +311,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -242,6 +322,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -264,6 +345,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier))) @@ -289,6 +371,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) @@ -313,8 +396,42 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + (Identifier))) + (Constructor + (Context' + (Identifier)) + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + { (Identifier) + ->(Identifier) })) + (Constructor + (Context' + (Class + (Identifier) + (TypeParameters + { (Identifier) + ->(Identifier) }))) + (Identifier) + (TypeParameters + { (Identifier) + ->(Identifier) })) (Empty)))) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index aa3e6ab85..2ea0e2b66 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -16,6 +16,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) { (Identifier) ->(Identifier) } (TypeParameters @@ -29,6 +30,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) { (Identifier) ->(Identifier) } (TypeParameters @@ -44,6 +46,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) { (Identifier) ->(Identifier) } (TypeParameters @@ -58,114 +61,119 @@ ->(Identifier) } (TypeParameters)) {+(Constructor + {+(Empty)+} + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} (Constructor - { (Identifier) - ->(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)-})-} (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 @@ -186,6 +194,74 @@ {+(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 @@ -232,6 +308,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -242,6 +319,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -264,6 +342,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier))) @@ -289,6 +368,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) @@ -313,8 +393,42 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + (Identifier))) + (Constructor + (Context' + (Identifier)) + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + { (Identifier) + ->(Identifier) })) + (Constructor + (Context' + (Class + (Identifier) + (TypeParameters + { (Identifier) + ->(Identifier) }))) + (Identifier) + (TypeParameters + { (Identifier) + ->(Identifier) })) (Empty)))) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt index 7eda5ef92..3efc87e97 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt @@ -14,6 +14,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier))) @@ -25,6 +26,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (StrictTypeVariable @@ -38,6 +40,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (StrictTypeVariable @@ -50,21 +53,27 @@ (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)) (Empty)) @@ -182,6 +191,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -192,6 +202,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -212,6 +223,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier))) @@ -236,6 +248,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) @@ -259,8 +272,38 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + (Identifier))) + (Constructor + (Context' + (Identifier)) + (Identifier) + (TypeParameters + (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + (Identifier))) + (Constructor + (Context' + (Class + (Identifier) + (TypeParameters + (Identifier)))) + (Identifier) + (TypeParameters + (Identifier))) (Empty)))) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt index 7eda5ef92..3efc87e97 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt @@ -14,6 +14,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier))) @@ -25,6 +26,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (StrictTypeVariable @@ -38,6 +40,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (StrictTypeVariable @@ -50,21 +53,27 @@ (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)) (Empty)) @@ -182,6 +191,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -192,6 +202,7 @@ (Identifier) (TypeParameters)) (Constructor + (Empty) (Identifier) (TypeParameters)) (Deriving @@ -212,6 +223,7 @@ (TypeParameters (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier))) @@ -236,6 +248,7 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) @@ -259,8 +272,38 @@ (Identifier) (Identifier))) (Constructor + (Empty) (Identifier) (TypeParameters (Identifier) (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + (Identifier))) + (Constructor + (Context' + (Identifier)) + (Identifier) + (TypeParameters + (Identifier))) + (Empty)) + (Datatype + (Empty) + (Type + (Identifier) + (TypeParameters + (Identifier))) + (Constructor + (Context' + (Class + (Identifier) + (TypeParameters + (Identifier)))) + (Identifier) + (TypeParameters + (Identifier))) (Empty)))) From 97c71544ea71124117a3ee3e286e488a370f50f2 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 5 Jun 2018 12:26:42 -0700 Subject: [PATCH 02/11] Assign GADT declarations without constructors --- src/Language/Haskell/Assignment.hs | 18 +- src/Language/Haskell/Syntax.hs | 9 + ...lgebraic-datatype-declarations.diffA-B.txt | 290 +++++++----------- ...lgebraic-datatype-declarations.diffB-A.txt | 277 ++++++----------- .../haskell/corpus/gadt-declarations.A.hs | 1 + .../haskell/corpus/gadt-declarations.B.hs | 1 + .../corpus/gadt-declarations.diffA-B.txt | 12 + .../corpus/gadt-declarations.diffB-A.txt | 12 + .../corpus/gadt-declarations.parseA.txt | 11 + .../corpus/gadt-declarations.parseB.txt | 11 + 10 files changed, 280 insertions(+), 362 deletions(-) create mode 100644 test/fixtures/haskell/corpus/gadt-declarations.A.hs create mode 100644 test/fixtures/haskell/corpus/gadt-declarations.B.hs create mode 100644 test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt create mode 100644 test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt create mode 100644 test/fixtures/haskell/corpus/gadt-declarations.parseA.txt create mode 100644 test/fixtures/haskell/corpus/gadt-declarations.parseB.txt diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index b15f1f716..cc24bc24f 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -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,8 +215,10 @@ parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children typeParameters strictType :: Assignment -strictType = makeTerm' <$> symbol StrictType <*> children ((inject <$> (Syntax.StrictType <$> typeConstructor <*> typeParameters)) - <|> (inject <$> (Syntax.StrictTypeVariable <$> typeVariableIdentifier))) +strictType = makeTerm' + <$> symbol StrictType + <*> children ( (inject <$> (Syntax.StrictType <$> typeConstructor <*> typeParameters)) + <|> (inject <$> (Syntax.StrictTypeVariable <$> typeVariableIdentifier))) tuplingConstructor :: Assignment tuplingConstructor = makeTerm <$> symbol TuplingConstructor <*> (tupleWithArity <$> rawSource) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 1459c0a36..a215a1041 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -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 diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index ffee4ef04..5a1531a9a 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -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 diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index 2ea0e2b66..dc109a703 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -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 diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs new file mode 100644 index 000000000..0aa0ddc21 --- /dev/null +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -0,0 +1 @@ +data Foo a b c where diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs new file mode 100644 index 000000000..ddcc525f4 --- /dev/null +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -0,0 +1 @@ +data Bar a b c where diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt new file mode 100644 index 000000000..ec0d6b7dc --- /dev/null +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -0,0 +1,12 @@ +(Module + (Empty) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier) + (Identifier) + (Identifier))) + (Statements))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt new file mode 100644 index 000000000..ec0d6b7dc --- /dev/null +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -0,0 +1,12 @@ +(Module + (Empty) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier) + (Identifier) + (Identifier))) + (Statements))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt new file mode 100644 index 000000000..fff54d58c --- /dev/null +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -0,0 +1,11 @@ +(Module + (Empty) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier) + (Identifier))) + (Statements))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt new file mode 100644 index 000000000..fff54d58c --- /dev/null +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -0,0 +1,11 @@ +(Module + (Empty) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier) + (Identifier))) + (Statements))) From 4c162ab20d36d29d17b8b1975b3238b03fb28a06 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 5 Jun 2018 16:01:37 -0700 Subject: [PATCH 03/11] Assign type signatures and function types --- src/Language/Haskell/Assignment.hs | 25 ++++++- src/Language/Haskell/Syntax.hs | 10 +++ ...lgebraic-datatype-declarations.diffA-B.txt | 65 ++++++++++------- ...lgebraic-datatype-declarations.diffB-A.txt | 52 ++++++++------ .../haskell/corpus/type-signatures.A.hs | 2 + .../haskell/corpus/type-signatures.B.hs | 1 + .../corpus/type-signatures.diffA-B.txt | 72 +++++++++++++++++++ .../corpus/type-signatures.diffB-A.txt | 72 +++++++++++++++++++ .../haskell/corpus/type-signatures.parseA.txt | 50 +++++++++++++ .../haskell/corpus/type-signatures.parseB.txt | 24 +++++++ 10 files changed, 325 insertions(+), 48 deletions(-) create mode 100644 test/fixtures/haskell/corpus/type-signatures.A.hs create mode 100644 test/fixtures/haskell/corpus/type-signatures.B.hs create mode 100644 test/fixtures/haskell/corpus/type-signatures.diffA-B.txt create mode 100644 test/fixtures/haskell/corpus/type-signatures.diffB-A.txt create mode 100644 test/fixtures/haskell/corpus/type-signatures.parseA.txt create mode 100644 test/fixtures/haskell/corpus/type-signatures.parseB.txt diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index cc24bc24f..2d51ba5b3 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -41,6 +41,7 @@ type Syntax = '[ , Syntax.Error , Syntax.Field , Syntax.FunctionConstructor + , Syntax.FunctionType , Syntax.GADT , Syntax.Identifier , Syntax.ListConstructor @@ -51,6 +52,7 @@ type Syntax = '[ , Syntax.StrictTypeVariable , Syntax.TupleConstructor , Syntax.Type + , Syntax.TypeSignature , Syntax.TypeSynonym , Syntax.UnitConstructor , Type.TypeParameters @@ -87,6 +89,7 @@ expressionChoices = [ , float , functionConstructor , functionDeclaration + , functionType , gadtDeclaration , integer , listConstructor @@ -161,6 +164,9 @@ typeClassIdentifier = makeTerm <$> symbol TypeClassIdentifier <*> (Syntax.Identi typeConstructorIdentifier :: Assignment typeConstructorIdentifier = makeTerm <$> symbol TypeConstructorIdentifier <*> (Syntax.Identifier . Name.name <$> source) +typeSignature :: Assignment +typeSignature = makeTerm <$> symbol TypeSignature <*> children (Syntax.TypeSignature <$> variableIdentifier <* token Annotation <*> type') + typeVariableIdentifier :: Assignment typeVariableIdentifier = makeTerm <$> symbol TypeVariableIdentifier <*> (Syntax.Identifier . Name.name <$> source) @@ -182,6 +188,9 @@ functionDeclaration = makeTerm <*> (manyTermsTill expression (symbol FunctionBody) <|> pure []) <*> functionBody) +functionType :: Assignment +functionType = makeTerm <$> symbol FunctionType <*> children (Syntax.FunctionType <$> type' <*> type') + gadtDeclaration :: Assignment gadtDeclaration = makeTerm <$> symbol GadtDeclaration @@ -226,16 +235,26 @@ tuplingConstructor = makeTerm <$> symbol TuplingConstructor <*> (tupleWithArity where tupleWithArity = Syntax.TupleConstructor . succ . count ',' type' :: Assignment -type' = (makeTerm <$> symbol Type <*> children (Syntax.Type <$> typeConstructor <*> typeParameters)) - <|> (makeTerm <$> symbol TypePattern <*> children (Syntax.Type <$> typeConstructor <*> typeParameters)) +type' = class' + <|> functionType <|> parenthesizedTypePattern <|> strictType <|> typeConstructor - <|> class' + <|> typePattern + +type'' :: Assignment +type'' = makeTerm + <$> symbol Type + <*> children (Syntax.Type + <$> (typeConstructor <|> typeVariableIdentifier) + <*> typeParameters) typeParameters :: Assignment typeParameters = makeTerm <$> location <*> (Type.TypeParameters <$> many expression) +typePattern :: Assignment +typePattern = makeTerm <$> symbol TypePattern <*> children (Syntax.Type <$> typeConstructor <*> typeParameters) + float :: Assignment float = makeTerm <$> symbol Float <*> (Literal.Float <$> source) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index a215a1041..0dd555b14 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -153,3 +153,13 @@ instance Ord1 GADT where liftCompare = genericLiftCompare instance Show1 GADT where liftShowsPrec = genericLiftShowsPrec instance Evaluatable GADT + +data FunctionType a = FunctionType { functionTypeLeft :: a, functionTypeRight :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 FunctionType where liftEq = genericLiftEq +instance Ord1 FunctionType where liftCompare = genericLiftCompare +instance Show1 FunctionType where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable FunctionType + diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index 5a1531a9a..bb2ecfc5e 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -65,31 +65,46 @@ { (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)) + {+(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)-})-} (Empty)) (Datatype (Empty) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index dc109a703..274fb42c3 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -65,31 +65,43 @@ { (Identifier) ->(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)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(Empty)+} + {+(Identifier)+} + {+(TypeParameters)+})+} + {-(Constructor + {-(Empty)-} + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(Empty)-} + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(Empty)-} + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(Empty)-} + {-(Identifier)-} + {-(TypeParameters)-})-} (Empty)) (Datatype (Empty) diff --git a/test/fixtures/haskell/corpus/type-signatures.A.hs b/test/fixtures/haskell/corpus/type-signatures.A.hs new file mode 100644 index 000000000..181bdea3a --- /dev/null +++ b/test/fixtures/haskell/corpus/type-signatures.A.hs @@ -0,0 +1,2 @@ +bar :: a -> b -> c -> Int -> Maybe Int +bar :: a -> b -> c -> [Int] -> Maybe Int diff --git a/test/fixtures/haskell/corpus/type-signatures.B.hs b/test/fixtures/haskell/corpus/type-signatures.B.hs new file mode 100644 index 000000000..bf0f94e19 --- /dev/null +++ b/test/fixtures/haskell/corpus/type-signatures.B.hs @@ -0,0 +1 @@ +foo :: a -> b -> c -> Int -> Maybe Int diff --git a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt new file mode 100644 index 000000000..3ff813744 --- /dev/null +++ b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt @@ -0,0 +1,72 @@ +(Module + (Empty) +{ (Statements + {-(TypeSignature + {-(Identifier)-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters + {-(Identifier)-})-})-})-})-})-})-})-} + {-(TypeSignature + {-(Identifier)-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Array + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-})-} + {-(TypeParameters)-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters + {-(Identifier)-})-})-})-})-})-})-})-}) +->(TypeSignature + {+(Identifier)+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters + {+(Identifier)+})+})+})+})+})+})+}) }) diff --git a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt new file mode 100644 index 000000000..1d8eb2ff0 --- /dev/null +++ b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt @@ -0,0 +1,72 @@ +(Module + (Empty) +{ (TypeSignature + {-(Identifier)-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(FunctionType + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters + {-(Identifier)-})-})-})-})-})-})-}) +->(Statements + {+(TypeSignature + {+(Identifier)+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters + {+(Identifier)+})+})+})+})+})+})+})+} + {+(TypeSignature + {+(Identifier)+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+} + {+(FunctionType + {+(Type + {+(Array + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+})+} + {+(TypeParameters)+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters + {+(Identifier)+})+})+})+})+})+})+})+}) }) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseA.txt b/test/fixtures/haskell/corpus/type-signatures.parseA.txt new file mode 100644 index 000000000..c9291b776 --- /dev/null +++ b/test/fixtures/haskell/corpus/type-signatures.parseA.txt @@ -0,0 +1,50 @@ +(Module + (Empty) + (Statements + (TypeSignature + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier)))))))) + (TypeSignature + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Array + (Type + (Identifier) + (TypeParameters))) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier)))))))))) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseB.txt b/test/fixtures/haskell/corpus/type-signatures.parseB.txt new file mode 100644 index 000000000..016943570 --- /dev/null +++ b/test/fixtures/haskell/corpus/type-signatures.parseB.txt @@ -0,0 +1,24 @@ +(Module + (Empty) + (TypeSignature + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier))))))))) From a452136999cda20f500d10d1951dd73eab3cd356 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 5 Jun 2018 16:01:56 -0700 Subject: [PATCH 04/11] Assign simple GADTs --- src/Language/Haskell/Assignment.hs | 16 +++++++++++++ src/Language/Haskell/Syntax.hs | 17 +++++++++++++ .../haskell/corpus/gadt-declarations.A.hs | 1 + .../haskell/corpus/gadt-declarations.B.hs | 1 + .../corpus/gadt-declarations.diffA-B.txt | 24 ++++++++++++++++++- .../corpus/gadt-declarations.diffB-A.txt | 24 ++++++++++++++++++- .../corpus/gadt-declarations.parseA.txt | 23 +++++++++++++++++- .../corpus/gadt-declarations.parseB.txt | 23 +++++++++++++++++- 8 files changed, 125 insertions(+), 4 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 2d51ba5b3..402413edb 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -43,6 +43,7 @@ type Syntax = '[ , Syntax.FunctionConstructor , Syntax.FunctionType , Syntax.GADT + , Syntax.GADTConstructor , Syntax.Identifier , Syntax.ListConstructor , Syntax.Module @@ -90,6 +91,7 @@ expressionChoices = [ , functionConstructor , functionDeclaration , functionType + , gadtConstructor , gadtDeclaration , integer , listConstructor @@ -100,6 +102,7 @@ expressionChoices = [ , string , type' , typeConstructorIdentifier + , typeSignature , typeSynonymDeclaration , typeVariableIdentifier , tuplingConstructor @@ -191,6 +194,15 @@ functionDeclaration = makeTerm functionType :: Assignment functionType = makeTerm <$> symbol FunctionType <*> children (Syntax.FunctionType <$> type' <*> type') +gadtConstructor :: Assignment +gadtConstructor = makeTerm + <$> symbol GadtConstructor + <*> children (Syntax.GADTConstructor + <$> (context' <|> emptyTerm) + <*> typeConstructor + <* token Annotation + <*> type') + gadtDeclaration :: Assignment gadtDeclaration = makeTerm <$> symbol GadtDeclaration @@ -201,6 +213,9 @@ gadtDeclaration = makeTerm where typeParameters' = makeTerm <$> location <*> (manyTermsTill expression (symbol Where')) +-- gadtConstructor :: Assignment +-- gadtConstructor = makeTerm <$> symbol GadtConstructor <*> children + integer :: Assignment integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source) @@ -239,6 +254,7 @@ type' = class' <|> functionType <|> parenthesizedTypePattern <|> strictType + <|> type'' <|> typeConstructor <|> typePattern diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 0dd555b14..ed5ff8109 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -154,6 +154,15 @@ instance Show1 GADT where liftShowsPrec = genericLiftShowsPrec instance Evaluatable GADT +data GADTConstructor a = GADTConstructor { gadtConstructorContext :: a, gadtConstructorName :: a, gadtConstructorTypeSignature :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 GADTConstructor where liftEq = genericLiftEq +instance Ord1 GADTConstructor where liftCompare = genericLiftCompare +instance Show1 GADTConstructor where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable GADTConstructor + data FunctionType a = FunctionType { functionTypeLeft :: a, functionTypeRight :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) @@ -163,3 +172,11 @@ instance Show1 FunctionType where liftShowsPrec = genericLiftShowsPrec instance Evaluatable FunctionType +data TypeSignature a = TypeSignature { typeSignatureName :: a, typeSignatureContent :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 TypeSignature where liftEq = genericLiftEq +instance Ord1 TypeSignature where liftCompare = genericLiftCompare +instance Show1 TypeSignature where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable TypeSignature diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs index 0aa0ddc21..38d138318 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.A.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -1 +1,2 @@ data Foo a b c where + Baz :: a -> b -> c -> Foo a b c diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs index ddcc525f4..5e80bf4a0 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.B.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -1 +1,2 @@ data Bar a b c where + Baz :: a -> b -> c -> Bar a b c diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt index ec0d6b7dc..6547f67f0 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -9,4 +9,26 @@ (Identifier) (Identifier) (Identifier))) - (Statements))) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier) + (Identifier) + (Identifier)))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt index ec0d6b7dc..6547f67f0 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -9,4 +9,26 @@ (Identifier) (Identifier) (Identifier))) - (Statements))) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier) + (Identifier) + (Identifier)))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt index fff54d58c..7d2301f77 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -8,4 +8,25 @@ (Identifier) (Identifier) (Identifier))) - (Statements))) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier) + (Identifier)))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt index fff54d58c..7d2301f77 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -8,4 +8,25 @@ (Identifier) (Identifier) (Identifier))) - (Statements))) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier) + (Identifier)))))))))) From 2e792df2501281fd04658040de6b42af38603c98 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 14:42:25 -0700 Subject: [PATCH 05/11] Assign fields within GADT constructors --- src/Language/Haskell/Assignment.hs | 17 ++-- ...lgebraic-datatype-declarations.diffA-B.txt | 58 +++++++++---- ...lgebraic-datatype-declarations.diffB-A.txt | 58 +++++++++---- ...algebraic-datatype-declarations.parseA.txt | 50 +++++++---- ...algebraic-datatype-declarations.parseB.txt | 50 +++++++---- .../haskell/corpus/gadt-declarations.A.hs | 3 + .../haskell/corpus/gadt-declarations.B.hs | 3 + .../corpus/gadt-declarations.diffA-B.txt | 82 ++++++++++++++----- .../corpus/gadt-declarations.diffB-A.txt | 82 ++++++++++++++----- .../corpus/gadt-declarations.parseA.txt | 75 ++++++++++++----- .../corpus/gadt-declarations.parseB.txt | 75 ++++++++++++----- 11 files changed, 398 insertions(+), 155 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 402413edb..be1d4f903 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -147,7 +147,14 @@ fields :: Assignment fields = makeTerm <$> symbol Fields <*> children (many field) field :: Assignment -field = makeTerm <$> symbol Field <*> children (Syntax.Field <$> variableIdentifiers <* token Annotation <*> term type') +field = makeTerm + <$> symbol Field + <*> children (Syntax.Field + <$> variableIdentifiers + <* token Annotation + <*> fieldType) + where + fieldType = makeTerm <$> location <*> (Syntax.Type <$> term (type' <|> typeVariableIdentifier) <*> typeParameters) variableIdentifier :: Assignment variableIdentifier = makeTerm <$> symbol VariableIdentifier <*> (Syntax.Identifier . Name.name <$> source) @@ -213,9 +220,6 @@ gadtDeclaration = makeTerm where typeParameters' = makeTerm <$> location <*> (manyTermsTill expression (symbol Where')) --- gadtConstructor :: Assignment --- gadtConstructor = makeTerm <$> symbol GadtConstructor <*> children - integer :: Assignment integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source) @@ -251,6 +255,7 @@ tuplingConstructor = makeTerm <$> symbol TuplingConstructor <*> (tupleWithArity type' :: Assignment type' = class' + <|> fields <|> functionType <|> parenthesizedTypePattern <|> strictType @@ -261,9 +266,7 @@ type' = class' type'' :: Assignment type'' = makeTerm <$> symbol Type - <*> children (Syntax.Type - <$> (typeConstructor <|> typeVariableIdentifier) - <*> typeParameters) + <*> children (Syntax.Type <$> (typeConstructor <|> typeVariableIdentifier <|> type') <*> typeParameters) typeParameters :: Assignment typeParameters = makeTerm <$> location <*> (Type.TypeParameters <$> many expression) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index bb2ecfc5e..dd2e2cd23 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -119,7 +119,9 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -135,7 +137,9 @@ (Statements (Identifier) (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -150,13 +154,17 @@ (Field (Statements (Identifier)) - (StrictType - (Identifier) + (Type + (StrictType + (Identifier) + (TypeParameters)) (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -172,15 +180,19 @@ (Statements (Identifier) (Identifier)) - (Context - (Pragma) - (StrictType - (Identifier) - (TypeParameters)))) + (Type + (Context + (Pragma) + (StrictType + (Identifier) + (TypeParameters))) + (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) {-(Datatype {-(Empty)-} @@ -193,14 +205,18 @@ {-(Field {-(Statements {-(Identifier)-})-} - {-(Identifier)-})-})-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-})-})-})-} {-(RecordDataConstructor {-(Identifier)-} {-(Statements {-(Field {-(Statements {-(Identifier)-})-} - {-(Identifier)-})-})-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-})-})-})-} {-(Empty)-})-} (Datatype (Empty) @@ -213,14 +229,18 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (RecordDataConstructor (Identifier) (Statements (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) {+(Datatype {+(Empty)+} @@ -233,14 +253,18 @@ {+(Field {+(Statements {+(Identifier)+})+} - {+(Identifier)+})+})+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+})+})+})+} {+(RecordDataConstructor {+(Identifier)+} {+(Statements {+(Field {+(Statements {+(Identifier)+})+} - {+(Identifier)+})+})+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+})+})+})+} {+(Empty)+})+} (Datatype (Empty) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index 274fb42c3..eba6fa4de 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -116,7 +116,9 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -132,7 +134,9 @@ (Statements (Identifier) (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -147,13 +151,17 @@ (Field (Statements (Identifier)) - (StrictType - (Identifier) + (Type + (StrictType + (Identifier) + (TypeParameters)) (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -169,15 +177,19 @@ (Statements (Identifier) (Identifier)) - (Context - (Pragma) - (StrictType - (Identifier) - (TypeParameters)))) + (Type + (Context + (Pragma) + (StrictType + (Identifier) + (TypeParameters))) + (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) {+(Datatype {+(Empty)+} @@ -190,14 +202,18 @@ {+(Field {+(Statements {+(Identifier)+})+} - {+(Identifier)+})+})+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+})+})+})+} {+(RecordDataConstructor {+(Identifier)+} {+(Statements {+(Field {+(Statements {+(Identifier)+})+} - {+(Identifier)+})+})+})+} + {+(Type + {+(Identifier)+} + {+(TypeParameters)+})+})+})+})+} {+(Empty)+})+} (Datatype (Empty) @@ -210,14 +226,18 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (RecordDataConstructor (Identifier) (Statements (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) {-(Datatype {-(Empty)-} @@ -230,14 +250,18 @@ {-(Field {-(Statements {-(Identifier)-})-} - {-(Identifier)-})-})-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-})-})-})-} {-(RecordDataConstructor {-(Identifier)-} {-(Statements {-(Field {-(Statements {-(Identifier)-})-} - {-(Identifier)-})-})-})-} + {-(Type + {-(Identifier)-} + {-(TypeParameters)-})-})-})-})-} {-(Empty)-})-} (Datatype (Empty) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt index 3efc87e97..58e85ecbe 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt @@ -88,7 +88,9 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -102,7 +104,9 @@ (Statements (Identifier) (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -115,13 +119,17 @@ (Field (Statements (Identifier)) - (StrictType - (Identifier) + (Type + (StrictType + (Identifier) + (TypeParameters)) (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -135,15 +143,19 @@ (Statements (Identifier) (Identifier)) - (Context - (Pragma) - (StrictType - (Identifier) - (TypeParameters)))) + (Type + (Context + (Pragma) + (StrictType + (Identifier) + (TypeParameters))) + (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -156,14 +168,18 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (RecordDataConstructor (Identifier) (Statements (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -176,14 +192,18 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (RecordDataConstructor (Identifier) (Statements (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt index 3efc87e97..58e85ecbe 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt @@ -88,7 +88,9 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -102,7 +104,9 @@ (Statements (Identifier) (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -115,13 +119,17 @@ (Field (Statements (Identifier)) - (StrictType - (Identifier) + (Type + (StrictType + (Identifier) + (TypeParameters)) (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -135,15 +143,19 @@ (Statements (Identifier) (Identifier)) - (Context - (Pragma) - (StrictType - (Identifier) - (TypeParameters)))) + (Type + (Context + (Pragma) + (StrictType + (Identifier) + (TypeParameters))) + (TypeParameters))) (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -156,14 +168,18 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (RecordDataConstructor (Identifier) (Statements (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) @@ -176,14 +192,18 @@ (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (RecordDataConstructor (Identifier) (Statements (Field (Statements (Identifier)) - (Identifier)))) + (Type + (Identifier) + (TypeParameters))))) (Empty)) (Datatype (Empty) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs index 38d138318..8fd8f0938 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.A.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -1,2 +1,5 @@ data Foo a b c where Baz :: a -> b -> c -> Foo a b c + +data Foo f a where + Bar :: { jolo :: Maybe String, runJolo :: f a } -> Foo f a diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs index 5e80bf4a0..98b8165bf 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.B.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -1,2 +1,5 @@ data Bar a b c where Baz :: a -> b -> c -> Bar a b c + +data Bar f a where + Baz :: { jolo :: Maybe String, runJolo :: f a } -> Bar f a diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt index 6547f67f0..527d830e2 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -1,22 +1,19 @@ (Module (Empty) - (GADT - (Empty) - (Type - { (Identifier) - ->(Identifier) } + (Statements + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier) + (Identifier) + (Identifier))) (Statements - (Identifier) - (Identifier) - (Identifier))) - (Statements - (GADTConstructor - (Empty) - (Identifier) - (FunctionType - (Type - (Identifier) - (TypeParameters)) + (GADTConstructor + (Empty) + (Identifier) (FunctionType (Type (Identifier) @@ -25,10 +22,51 @@ (Type (Identifier) (TypeParameters)) - (Type - { (Identifier) - ->(Identifier) } - (TypeParameters + (FunctionType + (Type (Identifier) - (Identifier) - (Identifier)))))))))) + (TypeParameters)) + (Type + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier) + (Identifier) + (Identifier))))))))) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier) + (Identifier))) + (Statements + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (Statements + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier)))) + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier))))) + (TypeParameters)) + (Type + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier) + (Identifier))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt index 6547f67f0..527d830e2 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -1,22 +1,19 @@ (Module (Empty) - (GADT - (Empty) - (Type - { (Identifier) - ->(Identifier) } + (Statements + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier) + (Identifier) + (Identifier))) (Statements - (Identifier) - (Identifier) - (Identifier))) - (Statements - (GADTConstructor - (Empty) - (Identifier) - (FunctionType - (Type - (Identifier) - (TypeParameters)) + (GADTConstructor + (Empty) + (Identifier) (FunctionType (Type (Identifier) @@ -25,10 +22,51 @@ (Type (Identifier) (TypeParameters)) - (Type - { (Identifier) - ->(Identifier) } - (TypeParameters + (FunctionType + (Type (Identifier) - (Identifier) - (Identifier)))))))))) + (TypeParameters)) + (Type + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier) + (Identifier) + (Identifier))))))))) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier) + (Identifier))) + (Statements + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (Statements + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier)))) + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier))))) + (TypeParameters)) + (Type + { (Identifier) + ->(Identifier) } + (TypeParameters + (Identifier) + (Identifier))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt index 7d2301f77..1cbb67e0e 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -1,21 +1,18 @@ (Module (Empty) - (GADT - (Empty) - (Type - (Identifier) + (Statements + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier) + (Identifier))) (Statements - (Identifier) - (Identifier) - (Identifier))) - (Statements - (GADTConstructor - (Empty) - (Identifier) - (FunctionType - (Type - (Identifier) - (TypeParameters)) + (GADTConstructor + (Empty) + (Identifier) (FunctionType (Type (Identifier) @@ -24,9 +21,47 @@ (Type (Identifier) (TypeParameters)) - (Type + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier) + (Identifier))))))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier))) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (Statements + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier)))) + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier))))) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters (Identifier) - (TypeParameters - (Identifier) - (Identifier) - (Identifier)))))))))) + (Identifier))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt index 7d2301f77..1cbb67e0e 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -1,21 +1,18 @@ (Module (Empty) - (GADT - (Empty) - (Type - (Identifier) + (Statements + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier) + (Identifier))) (Statements - (Identifier) - (Identifier) - (Identifier))) - (Statements - (GADTConstructor - (Empty) - (Identifier) - (FunctionType - (Type - (Identifier) - (TypeParameters)) + (GADTConstructor + (Empty) + (Identifier) (FunctionType (Type (Identifier) @@ -24,9 +21,47 @@ (Type (Identifier) (TypeParameters)) - (Type + (FunctionType + (Type + (Identifier) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier) + (Identifier))))))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier))) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (Statements + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier)))) + (Field + (Statements + (Identifier)) + (Type + (Identifier) + (TypeParameters + (Identifier))))) + (TypeParameters)) + (Type + (Identifier) + (TypeParameters (Identifier) - (TypeParameters - (Identifier) - (Identifier) - (Identifier)))))))))) + (Identifier))))))))) From 8cb6d7ed0af1ffc58d5ec24c61b8606fc402d298 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 15:41:57 -0700 Subject: [PATCH 06/11] Release the kinds! --- src/Language/Haskell/Assignment.hs | 198 ++++++++++-------- src/Language/Haskell/Syntax.hs | 47 ++++- ...lgebraic-datatype-declarations.diffA-B.txt | 130 +++++++----- ...lgebraic-datatype-declarations.diffB-A.txt | 101 +++++---- ...algebraic-datatype-declarations.parseA.txt | 84 +++++--- ...algebraic-datatype-declarations.parseB.txt | 84 +++++--- .../haskell/corpus/gadt-declarations.A.hs | 2 + .../haskell/corpus/gadt-declarations.B.hs | 2 + .../corpus/gadt-declarations.diffA-B.txt | 47 ++++- .../corpus/gadt-declarations.diffB-A.txt | 47 ++++- .../corpus/gadt-declarations.parseA.txt | 44 +++- .../corpus/gadt-declarations.parseB.txt | 45 +++- .../corpus/type-signatures.diffA-B.txt | 48 +++-- .../corpus/type-signatures.diffB-A.txt | 48 +++-- .../haskell/corpus/type-signatures.parseA.txt | 33 ++- .../haskell/corpus/type-signatures.parseB.txt | 15 +- .../haskell/corpus/type-synonyms.diffA-B.txt | 57 +++-- .../haskell/corpus/type-synonyms.diffB-A.txt | 57 +++-- .../haskell/corpus/type-synonyms.parseA.txt | 51 +++-- .../haskell/corpus/type-synonyms.parseB.txt | 51 +++-- 20 files changed, 801 insertions(+), 390 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index be1d4f903..a0aaf0f23 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -45,10 +45,15 @@ type Syntax = '[ , Syntax.GADT , Syntax.GADTConstructor , Syntax.Identifier + , Syntax.Kind + , Syntax.KindFunctionType + , Syntax.KindListType + , Syntax.KindSignature , Syntax.ListConstructor , Syntax.Module , Syntax.Pragma , Syntax.RecordDataConstructor + , Syntax.Star , Syntax.StrictType , Syntax.StrictTypeVariable , Syntax.TupleConstructor @@ -67,11 +72,40 @@ type Assignment' a = HasCallStack => Assignment.Assignment [] Grammar a assignment :: Assignment assignment = handleError $ module' <|> parseError -module' :: Assignment -module' = makeTerm - <$> symbol Module - <*> children (Syntax.Module <$> (moduleIdentifier <|> emptyTerm) <*> pure [] <*> (where' <|> expressions <|> emptyTerm)) +algebraicDatatypeDeclaration :: Assignment +algebraicDatatypeDeclaration = makeTerm + <$> symbol AlgebraicDatatypeDeclaration + <*> children (Declaration.Datatype + <$> (context' <|> emptyTerm) + <*> (makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParameters <*> (kindSignature <|> emptyTerm))) + <*> ((symbol Constructors *> children (many constructor)) + <|> pure []) + <*> (derivingClause <|> emptyTerm)) +character :: Assignment +character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) + +class' :: Assignment +class' = makeTerm <$> symbol Class <*> children (Syntax.Class <$> typeConstructor <*> typeParameters) + +comment :: Assignment +comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) + +constructor :: Assignment +constructor = (makeTerm <$> symbol DataConstructor <*> children (Declaration.Constructor <$> (context' <|> emptyTerm) <*> typeConstructor <*> typeParameters)) + <|> (makeTerm <$> symbol RecordDataConstructor <*> children (Syntax.RecordDataConstructor <$> constructorIdentifier <*> fields)) + +constructorIdentifier :: Assignment +constructorIdentifier = makeTerm <$> symbol ConstructorIdentifier <*> (Syntax.Identifier . Name.name <$> source) + +context' :: Assignment +context' = makeTerm <$> symbol Context <*> children (Syntax.Context' <$> many (type' <|> contextPattern)) + +contextPattern :: Assignment +contextPattern = symbol ContextPattern *> children type' + +derivingClause :: Assignment +derivingClause = makeTerm <$> symbol Deriving <*> children (Syntax.Deriving <$> many typeConstructor) expressions :: Assignment expressions = makeTerm'' <$> location <*> many expression @@ -94,10 +128,13 @@ expressionChoices = [ , gadtConstructor , gadtDeclaration , integer + , kind + , kindSignature , listConstructor , listExpression , listType , moduleIdentifier + , star , strictType , string , type' @@ -111,38 +148,6 @@ expressionChoices = [ , where' ] -term :: Assignment -> Assignment -term term = contextualize (comment <|> pragma) (postContextualize (comment <|> pragma) term) - -algebraicDatatypeDeclaration :: Assignment -algebraicDatatypeDeclaration = makeTerm - <$> symbol AlgebraicDatatypeDeclaration - <*> children (Declaration.Datatype - <$> (context' <|> emptyTerm) - <*> (makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParameters)) - <*> ((symbol Constructors *> children (many constructor)) - <|> pure []) - <*> (derivingClause <|> emptyTerm)) - -comment :: Assignment -comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) - -constructor :: Assignment -constructor = (makeTerm <$> symbol DataConstructor <*> children (Declaration.Constructor <$> (context' <|> emptyTerm) <*> typeConstructor <*> typeParameters)) - <|> (makeTerm <$> symbol RecordDataConstructor <*> children (Syntax.RecordDataConstructor <$> constructorIdentifier <*> fields)) - -class' :: Assignment -class' = makeTerm <$> symbol Class <*> children (Syntax.Class <$> typeConstructor <*> typeParameters) - -context' :: Assignment -context' = makeTerm <$> symbol Context <*> children (Syntax.Context' <$> many (type' <|> contextPattern)) - -contextPattern :: Assignment -contextPattern = symbol ContextPattern *> children type' - -derivingClause :: Assignment -derivingClause = makeTerm <$> symbol Deriving <*> children (Syntax.Deriving <$> many typeConstructor) - fields :: Assignment fields = makeTerm <$> symbol Fields <*> children (many field) @@ -154,34 +159,10 @@ field = makeTerm <* token Annotation <*> fieldType) where - fieldType = makeTerm <$> location <*> (Syntax.Type <$> term (type' <|> typeVariableIdentifier) <*> typeParameters) + fieldType = makeTerm <$> location <*> (Syntax.Type <$> term (type' <|> typeVariableIdentifier) <*> typeParameters <*> (kindSignature <|> emptyTerm)) -variableIdentifier :: Assignment -variableIdentifier = makeTerm <$> symbol VariableIdentifier <*> (Syntax.Identifier . Name.name <$> source) - -variableIdentifiers :: Assignment -variableIdentifiers = makeTerm <$> location <*> many variableIdentifier - -constructorIdentifier :: Assignment -constructorIdentifier = makeTerm <$> symbol ConstructorIdentifier <*> (Syntax.Identifier . Name.name <$> source) - -moduleIdentifier :: Assignment -moduleIdentifier = makeTerm <$> symbol ModuleIdentifier <*> (Syntax.Identifier . Name.name <$> source) - -typeClassIdentifier :: Assignment -typeClassIdentifier = makeTerm <$> symbol TypeClassIdentifier <*> (Syntax.Identifier . Name.name <$> source) - -typeConstructorIdentifier :: Assignment -typeConstructorIdentifier = makeTerm <$> symbol TypeConstructorIdentifier <*> (Syntax.Identifier . Name.name <$> source) - -typeSignature :: Assignment -typeSignature = makeTerm <$> symbol TypeSignature <*> children (Syntax.TypeSignature <$> variableIdentifier <* token Annotation <*> type') - -typeVariableIdentifier :: Assignment -typeVariableIdentifier = makeTerm <$> symbol TypeVariableIdentifier <*> (Syntax.Identifier . Name.name <$> source) - -where' :: Assignment -where' = makeTerm <$> (symbol Where <|> symbol Where') <*> children (many expression) +float :: Assignment +float = makeTerm <$> symbol Float <*> (Literal.Float <$> source) functionBody :: Assignment functionBody = makeTerm <$> symbol FunctionBody <*> children (many expression) @@ -215,23 +196,35 @@ gadtDeclaration = makeTerm <$> symbol GadtDeclaration <*> children (Syntax.GADT <$> (context' <|> emptyTerm) - <*> (makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParameters')) + <*> (makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParameters' <*> (kindSignature <|> emptyTerm))) <*> where') where - typeParameters' = makeTerm <$> location <*> (manyTermsTill expression (symbol Where')) + typeParameters' = makeTerm <$> location <*> (manyTermsTill expression (symbol KindSignature <|> symbol Where')) integer :: Assignment integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source) +kind :: Assignment +kind = kind' + <|> kindFunctionType + <|> kindListType + <|> star + +kind' :: Assignment +kind' = makeTerm <$> symbol Kind <*> children (Syntax.Kind <$> kind) + +kindFunctionType :: Assignment +kindFunctionType = makeTerm <$> symbol KindFunctionType <*> children (Syntax.KindFunctionType <$> kind <*> kind) + +kindListType :: Assignment +kindListType = makeTerm <$> symbol KindListType <*> children (Syntax.KindListType <$> kind) + +kindSignature :: Assignment +kindSignature = makeTerm <$> symbol KindSignature <*> children (Syntax.KindSignature <$ token Annotation <*> kind) + listConstructor :: Assignment listConstructor = makeTerm <$> token ListConstructor <*> pure Syntax.ListConstructor -pragma :: Assignment -pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) - -unitConstructor :: Assignment -unitConstructor = makeTerm <$> token UnitConstructor <*> pure Syntax.UnitConstructor - listExpression :: Assignment listExpression = makeTerm <$> symbol ListExpression <*> children (Literal.Array <$> many listElement) where listElement = symbol Expression *> children expression @@ -239,15 +232,44 @@ listExpression = makeTerm <$> symbol ListExpression <*> children (Literal.Array listType :: Assignment listType = makeTerm <$> symbol ListType <*> children (Literal.Array <$> many type') +module' :: Assignment +module' = makeTerm + <$> symbol Module + <*> children (Syntax.Module <$> (moduleIdentifier <|> emptyTerm) <*> pure [] <*> (where' <|> expressions <|> emptyTerm)) + +moduleIdentifier :: Assignment +moduleIdentifier = makeTerm <$> symbol ModuleIdentifier <*> (Syntax.Identifier . Name.name <$> source) + parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children typeParameters +pragma :: Assignment +pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) + +star :: Assignment +star = makeTerm <$> token Star <*> pure Syntax.Star + strictType :: Assignment strictType = makeTerm' <$> symbol StrictType <*> children ( (inject <$> (Syntax.StrictType <$> typeConstructor <*> typeParameters)) <|> (inject <$> (Syntax.StrictTypeVariable <$> typeVariableIdentifier))) +string :: Assignment +string = makeTerm <$> symbol String <*> (Literal.TextElement <$> source) + +typeClassIdentifier :: Assignment +typeClassIdentifier = makeTerm <$> symbol TypeClassIdentifier <*> (Syntax.Identifier . Name.name <$> source) + +typeConstructorIdentifier :: Assignment +typeConstructorIdentifier = makeTerm <$> symbol TypeConstructorIdentifier <*> (Syntax.Identifier . Name.name <$> source) + +typeSignature :: Assignment +typeSignature = makeTerm <$> symbol TypeSignature <*> children (Syntax.TypeSignature <$> variableIdentifier <* token Annotation <*> type') + +typeVariableIdentifier :: Assignment +typeVariableIdentifier = makeTerm <$> symbol TypeVariableIdentifier <*> (Syntax.Identifier . Name.name <$> source) + tuplingConstructor :: Assignment tuplingConstructor = makeTerm <$> symbol TuplingConstructor <*> (tupleWithArity <$> rawSource) -- a tuple (,) has arity two, but only one comma, so apply the successor to the count of commas for the correct arity. @@ -266,22 +288,13 @@ type' = class' type'' :: Assignment type'' = makeTerm <$> symbol Type - <*> children (Syntax.Type <$> (typeConstructor <|> typeVariableIdentifier <|> type') <*> typeParameters) + <*> children (Syntax.Type <$> (typeConstructor <|> typeVariableIdentifier <|> type') <*> typeParameters <*> (kindSignature <|> emptyTerm)) typeParameters :: Assignment -typeParameters = makeTerm <$> location <*> (Type.TypeParameters <$> many expression) +typeParameters = makeTerm <$> location <*> (Type.TypeParameters <$> (manyTermsTill expression (symbol Annotation) <|> many expression)) typePattern :: Assignment -typePattern = makeTerm <$> symbol TypePattern <*> children (Syntax.Type <$> typeConstructor <*> typeParameters) - -float :: Assignment -float = makeTerm <$> symbol Float <*> (Literal.Float <$> source) - -character :: Assignment -character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) - -string :: Assignment -string = makeTerm <$> symbol String <*> (Literal.TextElement <$> source) +typePattern = makeTerm <$> symbol TypePattern <*> children (Syntax.Type <$> typeConstructor <*> typeParameters <*> (kindSignature <|> emptyTerm)) typeConstructor :: Assignment typeConstructor = constructorIdentifier @@ -298,10 +311,27 @@ typeSynonymDeclaration = makeTerm <$> symbol TypeSynonymDeclaration <*> children (Syntax.TypeSynonym <$> typeLeft <*> typeRight) where - typeLeft = makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParametersLeft) + typeLeft = makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParametersLeft <*> (kindSignature <|> emptyTerm)) typeParametersLeft = makeTerm <$> location <*> (Type.TypeParameters <$> manyTill expression (symbol TypeSynonymBody)) typeRight = symbol TypeSynonymBody *> children type' +unitConstructor :: Assignment +unitConstructor = makeTerm <$> token UnitConstructor <*> pure Syntax.UnitConstructor + +variableIdentifier :: Assignment +variableIdentifier = makeTerm <$> symbol VariableIdentifier <*> (Syntax.Identifier . Name.name <$> source) + +variableIdentifiers :: Assignment +variableIdentifiers = makeTerm <$> location <*> many variableIdentifier + +where' :: Assignment +where' = makeTerm <$> (symbol Where <|> symbol Where') <*> children (many expression) + +-- | Helpers + -- | Match a series of terms or comments until a delimiter is matched. manyTermsTill :: Assignment.Assignment [] Grammar Term -> Assignment.Assignment [] Grammar b -> Assignment.Assignment [] Grammar [Term] manyTermsTill step = manyTill (step <|> comment) + +term :: Assignment -> Assignment +term term = contextualize (comment <|> pragma) (postContextualize (comment <|> pragma) term) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index ed5ff8109..15da30297 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -37,7 +37,7 @@ instance Show1 StrictTypeVariable where liftShowsPrec = genericLiftShowsPrec instance Evaluatable StrictTypeVariable -data Type a = Type { typeIdentifier :: !a, typeParameters :: !a } +data Type a = Type { typeIdentifier :: a, typeParameters :: a, typeKindSignature :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Type where liftEq = genericLiftEq @@ -180,3 +180,48 @@ instance Ord1 TypeSignature where liftCompare = genericLiftCompare instance Show1 TypeSignature where liftShowsPrec = genericLiftShowsPrec instance Evaluatable TypeSignature + +newtype KindSignature a = KindSignature { kindSignatureContent :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 KindSignature where liftEq = genericLiftEq +instance Ord1 KindSignature where liftCompare = genericLiftCompare +instance Show1 KindSignature where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable KindSignature + +data KindFunctionType a = KindFunctionType { kindFunctionTypeLeft :: a, kindFunctionTypeRight :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 KindFunctionType where liftEq = genericLiftEq +instance Ord1 KindFunctionType where liftCompare = genericLiftCompare +instance Show1 KindFunctionType where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable KindFunctionType + +newtype Kind a = Kind { kindKind :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Kind where liftEq = genericLiftEq +instance Ord1 Kind where liftCompare = genericLiftCompare +instance Show1 Kind where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Kind + +newtype KindListType a = KindListType { kindListTypeKind :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 KindListType where liftEq = genericLiftEq +instance Ord1 KindListType where liftCompare = genericLiftCompare +instance Show1 KindListType where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable KindListType + +data Star a = Star + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Star where liftEq = genericLiftEq +instance Ord1 Star where liftCompare = genericLiftCompare +instance Show1 Star where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Star diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index dd2e2cd23..bbfff3dd9 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -6,7 +6,8 @@ (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Empty)) (Datatype (Empty) @@ -14,7 +15,8 @@ { (Identifier) ->(Identifier) } (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) { (Identifier) @@ -28,7 +30,8 @@ { (Identifier) ->(Identifier) } (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) { (Identifier) @@ -44,7 +47,8 @@ ->(Identifier) } (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) { (Identifier) @@ -58,6 +62,12 @@ (Empty) (Type { (Identifier) + ->(Identifier) } + (TypeParameters) + (Empty)) + (Constructor + (Empty) + { (Identifier) ->(Identifier) } (TypeParameters)) (Constructor @@ -69,34 +79,20 @@ {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} + (Constructor + (Empty) + { (Identifier) + ->(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)-} @@ -111,7 +107,8 @@ (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -121,14 +118,16 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -139,14 +138,16 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -158,20 +159,23 @@ (StrictType (Identifier) (TypeParameters)) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -186,19 +190,22 @@ (StrictType (Identifier) (TypeParameters))) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) {-(Datatype {-(Empty)-} {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(RecordDataConstructor {-(Identifier)-} {-(Statements @@ -207,7 +214,8 @@ {-(Identifier)-})-} {-(Type {-(Identifier)-} - {-(TypeParameters)-})-})-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-})-} {-(RecordDataConstructor {-(Identifier)-} {-(Statements @@ -216,13 +224,15 @@ {-(Identifier)-})-} {-(Type {-(Identifier)-} - {-(TypeParameters)-})-})-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-})-} {-(Empty)-})-} (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -231,7 +241,8 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (RecordDataConstructor (Identifier) (Statements @@ -240,13 +251,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) {+(Datatype {+(Empty)+} {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(RecordDataConstructor {+(Identifier)+} {+(Statements @@ -255,7 +268,8 @@ {+(Identifier)+})+} {+(Type {+(Identifier)+} - {+(TypeParameters)+})+})+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+})+} {+(RecordDataConstructor {+(Identifier)+} {+(Statements @@ -264,13 +278,15 @@ {+(Identifier)+})+} {+(Type {+(Identifier)+} - {+(TypeParameters)+})+})+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+})+} {+(Empty)+})+} (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -281,7 +297,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -304,7 +321,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -330,7 +348,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -355,7 +374,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -368,7 +388,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Context' (Identifier)) @@ -383,7 +404,8 @@ (Identifier) (TypeParameters { (Identifier) - ->(Identifier) })) + ->(Identifier) }) + (Empty)) (Constructor (Context' (Class diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index eba6fa4de..0dd399d37 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -6,7 +6,8 @@ (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Empty)) (Datatype (Empty) @@ -14,7 +15,8 @@ { (Identifier) ->(Identifier) } (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) { (Identifier) @@ -28,7 +30,8 @@ { (Identifier) ->(Identifier) } (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) { (Identifier) @@ -44,7 +47,8 @@ ->(Identifier) } (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) { (Identifier) @@ -58,6 +62,12 @@ (Empty) (Type { (Identifier) + ->(Identifier) } + (TypeParameters) + (Empty)) + (Constructor + (Empty) + { (Identifier) ->(Identifier) } (TypeParameters)) (Constructor @@ -73,11 +83,6 @@ {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} - (Constructor - (Empty) - { (Identifier) - ->(Identifier) } - (TypeParameters)) {+(Constructor {+(Empty)+} {+(Identifier)+} @@ -108,7 +113,8 @@ (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -118,14 +124,16 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -136,14 +144,16 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -155,20 +165,23 @@ (StrictType (Identifier) (TypeParameters)) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor { (Identifier) ->(Identifier) } @@ -183,19 +196,22 @@ (StrictType (Identifier) (TypeParameters))) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) {+(Datatype {+(Empty)+} {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(RecordDataConstructor {+(Identifier)+} {+(Statements @@ -204,7 +220,8 @@ {+(Identifier)+})+} {+(Type {+(Identifier)+} - {+(TypeParameters)+})+})+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+})+} {+(RecordDataConstructor {+(Identifier)+} {+(Statements @@ -213,13 +230,15 @@ {+(Identifier)+})+} {+(Type {+(Identifier)+} - {+(TypeParameters)+})+})+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+})+} {+(Empty)+})+} (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -228,7 +247,8 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (RecordDataConstructor (Identifier) (Statements @@ -237,13 +257,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) {-(Datatype {-(Empty)-} {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(RecordDataConstructor {-(Identifier)-} {-(Statements @@ -252,7 +274,8 @@ {-(Identifier)-})-} {-(Type {-(Identifier)-} - {-(TypeParameters)-})-})-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-})-} {-(RecordDataConstructor {-(Identifier)-} {-(Statements @@ -261,13 +284,15 @@ {-(Identifier)-})-} {-(Type {-(Identifier)-} - {-(TypeParameters)-})-})-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-})-} {-(Empty)-})-} (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -278,7 +303,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -301,7 +327,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -327,7 +354,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -352,7 +380,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -365,7 +394,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Context' (Identifier)) @@ -380,7 +410,8 @@ (Identifier) (TypeParameters { (Identifier) - ->(Identifier) })) + ->(Identifier) }) + (Empty)) (Constructor (Context' (Class diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt index 58e85ecbe..1ee4ad899 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt @@ -5,14 +5,16 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Empty)) (Datatype (Empty) (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -24,7 +26,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -38,7 +41,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -51,7 +55,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -81,7 +86,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -90,13 +96,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -106,13 +114,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -123,19 +133,22 @@ (StrictType (Identifier) (TypeParameters)) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -149,19 +162,22 @@ (StrictType (Identifier) (TypeParameters))) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -170,7 +186,8 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (RecordDataConstructor (Identifier) (Statements @@ -179,13 +196,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -194,7 +213,8 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (RecordDataConstructor (Identifier) (Statements @@ -203,13 +223,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -220,7 +242,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -241,7 +264,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -266,7 +290,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -290,7 +315,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -303,7 +329,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Context' (Identifier)) @@ -316,7 +343,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Context' (Class diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt index 58e85ecbe..1ee4ad899 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt @@ -5,14 +5,16 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Empty)) (Datatype (Empty) (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -24,7 +26,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -38,7 +41,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -51,7 +55,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -81,7 +86,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -90,13 +96,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -106,13 +114,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -123,19 +133,22 @@ (StrictType (Identifier) (TypeParameters)) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -149,19 +162,22 @@ (StrictType (Identifier) (TypeParameters))) - (TypeParameters))) + (TypeParameters) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -170,7 +186,8 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (RecordDataConstructor (Identifier) (Statements @@ -179,13 +196,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (RecordDataConstructor (Identifier) (Statements @@ -194,7 +213,8 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (RecordDataConstructor (Identifier) (Statements @@ -203,13 +223,15 @@ (Identifier)) (Type (Identifier) - (TypeParameters))))) + (TypeParameters) + (Empty))))) (Empty)) (Datatype (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -220,7 +242,8 @@ (Empty) (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Constructor (Empty) (Identifier) @@ -241,7 +264,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -266,7 +290,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -290,7 +315,8 @@ (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Empty) (Identifier) @@ -303,7 +329,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Context' (Identifier)) @@ -316,7 +343,8 @@ (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Constructor (Context' (Class diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs index 8fd8f0938..631ca05fb 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.A.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -3,3 +3,5 @@ data Foo a b c where data Foo f a where Bar :: { jolo :: Maybe String, runJolo :: f a } -> Foo f a + +data Foo a :: [*] -> * where diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs index 98b8165bf..9a676dfff 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.B.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -3,3 +3,5 @@ data Bar a b c where data Bar f a where Baz :: { jolo :: Maybe String, runJolo :: f a } -> Bar f a + +data Bar a :: [*] -> [*] where diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt index 527d830e2..76dc49032 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -9,7 +9,8 @@ (Statements (Identifier) (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -17,22 +18,26 @@ (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type { (Identifier) ->(Identifier) } (TypeParameters (Identifier) (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))))) (GADT (Empty) (Type @@ -40,7 +45,8 @@ ->(Identifier) } (Statements (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -55,18 +61,39 @@ (Type (Identifier) (TypeParameters - (Identifier)))) + (Identifier)) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) (TypeParameters - (Identifier))))) - (TypeParameters)) + (Identifier)) + (Empty)))) + (TypeParameters) + (Empty)) (Type { (Identifier) ->(Identifier) } (TypeParameters (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier)) + (KindSignature + (KindFunctionType + (Kind + (KindListType + (Star))) + (Kind + { (Star) + ->(KindListType + {+(Star)+}) })))) + (Statements)))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt index 527d830e2..284274376 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -9,7 +9,8 @@ (Statements (Identifier) (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -17,22 +18,26 @@ (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type { (Identifier) ->(Identifier) } (TypeParameters (Identifier) (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))))) (GADT (Empty) (Type @@ -40,7 +45,8 @@ ->(Identifier) } (Statements (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -55,18 +61,39 @@ (Type (Identifier) (TypeParameters - (Identifier)))) + (Identifier)) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) (TypeParameters - (Identifier))))) - (TypeParameters)) + (Identifier)) + (Empty)))) + (TypeParameters) + (Empty)) (Type { (Identifier) ->(Identifier) } (TypeParameters (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier)) + (KindSignature + (KindFunctionType + (Kind + (KindListType + (Star))) + (Kind + { (KindListType + {-(Star)-}) + ->(Star) })))) + (Statements)))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt index 1cbb67e0e..8089547ed 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -8,7 +8,8 @@ (Statements (Identifier) (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -16,28 +17,33 @@ (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))))) (GADT (Empty) (Type (Identifier) (Statements (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -51,17 +57,35 @@ (Type (Identifier) (TypeParameters - (Identifier)))) + (Identifier)) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) (TypeParameters - (Identifier))))) - (TypeParameters)) + (Identifier)) + (Empty)))) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier)) + (KindSignature + (KindFunctionType + (Kind + (KindListType + (Star))) + (Kind + (Star))))) + (Statements)))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt index 1cbb67e0e..82f5f6cc7 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -8,7 +8,8 @@ (Statements (Identifier) (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -16,28 +17,33 @@ (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))))) (GADT (Empty) (Type (Identifier) (Statements (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Statements (GADTConstructor (Empty) @@ -51,17 +57,36 @@ (Type (Identifier) (TypeParameters - (Identifier)))) + (Identifier)) + (Empty))) (Field (Statements (Identifier)) (Type (Identifier) (TypeParameters - (Identifier))))) - (TypeParameters)) + (Identifier)) + (Empty)))) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) - (Identifier))))))))) + (Identifier)) + (Empty)))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier)) + (KindSignature + (KindFunctionType + (Kind + (KindListType + (Star))) + (Kind + (KindListType + (Star)))))) + (Statements)))) diff --git a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt index 3ff813744..daf16df2a 100644 --- a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt @@ -6,67 +6,83 @@ {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(Type {-(Identifier)-} {-(TypeParameters - {-(Identifier)-})-})-})-})-})-})-})-} + {-(Identifier)-})-} + {-(Empty)-})-})-})-})-})-})-} {-(TypeSignature {-(Identifier)-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Array {-(Type {-(Identifier)-} - {-(TypeParameters)-})-})-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(Type {-(Identifier)-} {-(TypeParameters - {-(Identifier)-})-})-})-})-})-})-})-}) + {-(Identifier)-})-} + {-(Empty)-})-})-})-})-})-})-}) ->(TypeSignature {+(Identifier)+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(Type {+(Identifier)+} {+(TypeParameters - {+(Identifier)+})+})+})+})+})+})+}) }) + {+(Identifier)+})+} + {+(Empty)+})+})+})+})+})+}) }) diff --git a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt index 1d8eb2ff0..91e8a397f 100644 --- a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt @@ -5,68 +5,84 @@ {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(FunctionType {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(Type {-(Identifier)-} {-(TypeParameters - {-(Identifier)-})-})-})-})-})-})-}) + {-(Identifier)-})-} + {-(Empty)-})-})-})-})-})-}) ->(Statements {+(TypeSignature {+(Identifier)+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(Type {+(Identifier)+} {+(TypeParameters - {+(Identifier)+})+})+})+})+})+})+})+} + {+(Identifier)+})+} + {+(Empty)+})+})+})+})+})+})+} {+(TypeSignature {+(Identifier)+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(FunctionType {+(Type {+(Array {+(Type {+(Identifier)+} - {+(TypeParameters)+})+})+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(Type {+(Identifier)+} {+(TypeParameters - {+(Identifier)+})+})+})+})+})+})+})+}) }) + {+(Identifier)+})+} + {+(Empty)+})+})+})+})+})+})+}) }) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseA.txt b/test/fixtures/haskell/corpus/type-signatures.parseA.txt index c9291b776..6c399ffab 100644 --- a/test/fixtures/haskell/corpus/type-signatures.parseA.txt +++ b/test/fixtures/haskell/corpus/type-signatures.parseA.txt @@ -6,45 +6,56 @@ (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters - (Identifier)))))))) + (Identifier)) + (Empty))))))) (TypeSignature (Identifier) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Array (Type (Identifier) - (TypeParameters))) - (TypeParameters)) + (TypeParameters) + (Empty))) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters - (Identifier)))))))))) + (Identifier)) + (Empty))))))))) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseB.txt b/test/fixtures/haskell/corpus/type-signatures.parseB.txt index 016943570..23f35c341 100644 --- a/test/fixtures/haskell/corpus/type-signatures.parseB.txt +++ b/test/fixtures/haskell/corpus/type-signatures.parseB.txt @@ -5,20 +5,25 @@ (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (FunctionType (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (Identifier) (TypeParameters - (Identifier))))))))) + (Identifier)) + (Empty)))))))) diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt index 7c1cd7a70..bb4865b4e 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt @@ -5,77 +5,96 @@ (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Type { (Identifier) ->(Identifier) } - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (ListConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters (Identifier) - {+(Identifier)+})) + {+(Identifier)+}) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) - {+(Identifier)+}))) + {+(Identifier)+}) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Type (Array (Type { (Identifier) ->(Identifier) } (TypeParameters - (Identifier)))) - (TypeParameters))) + (Identifier)) + (Empty))) + (TypeParameters) + (Empty))) (TypeSynonym (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (UnitConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) {-(TypeSynonym {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(Type {-(TupleConstructor)-} - {-(TypeParameters)-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-})-} (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (TupleConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type { (FunctionConstructor) ->(TupleConstructor) } - (TypeParameters))) + (TypeParameters) + (Empty))) {+(TypeSynonym {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(Type {+(FunctionConstructor)+} - {+(TypeParameters)+})+})+})) + {+(TypeParameters)+} + {+(Empty)+})+})+})) diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt index aa94abbdb..eb1b39e1c 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt @@ -5,77 +5,96 @@ (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Type { (Identifier) ->(Identifier) } - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (ListConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters (Identifier) - {-(Identifier)-})) + {-(Identifier)-}) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) - {-(Identifier)-}))) + {-(Identifier)-}) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Type (Array (Type { (Identifier) ->(Identifier) } (TypeParameters - (Identifier)))) - (TypeParameters))) + (Identifier)) + (Empty))) + (TypeParameters) + (Empty))) (TypeSynonym (Type { (Identifier) ->(Identifier) } - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (UnitConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) {+(TypeSynonym {+(Type {+(Identifier)+} - {+(TypeParameters)+})+} + {+(TypeParameters)+} + {+(Empty)+})+} {+(Type {+(TupleConstructor)+} - {+(TypeParameters)+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+})+} (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (TupleConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type { (TupleConstructor) ->(FunctionConstructor) } - (TypeParameters))) + (TypeParameters) + (Empty))) {-(TypeSynonym {-(Type {-(Identifier)-} - {-(TypeParameters)-})-} + {-(TypeParameters)-} + {-(Empty)-})-} {-(Type {-(FunctionConstructor)-} - {-(TypeParameters)-})-})-})) + {-(TypeParameters)-} + {-(Empty)-})-})-})) diff --git a/test/fixtures/haskell/corpus/type-synonyms.parseA.txt b/test/fixtures/haskell/corpus/type-synonyms.parseA.txt index be412a8b0..458577730 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.parseA.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.parseA.txt @@ -4,63 +4,80 @@ (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (Identifier) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (ListConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Type (Identifier) (TypeParameters - (Identifier)))) + (Identifier)) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Type (Array (Type (Identifier) (TypeParameters - (Identifier)))) - (TypeParameters))) + (Identifier)) + (Empty))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (UnitConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (TupleConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (TupleConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (FunctionConstructor) - (TypeParameters))))) + (TypeParameters) + (Empty))))) diff --git a/test/fixtures/haskell/corpus/type-synonyms.parseB.txt b/test/fixtures/haskell/corpus/type-synonyms.parseB.txt index c4e3c118a..6e99c1e99 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.parseB.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.parseB.txt @@ -4,65 +4,82 @@ (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (Identifier) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (ListConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters (Identifier) - (Identifier))) + (Identifier)) + (Empty)) (Type (Identifier) (TypeParameters (Identifier) - (Identifier)))) + (Identifier)) + (Empty))) (TypeSynonym (Type (Identifier) (TypeParameters - (Identifier))) + (Identifier)) + (Empty)) (Type (Array (Type (Identifier) (TypeParameters - (Identifier)))) - (TypeParameters))) + (Identifier)) + (Empty))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (UnitConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (TupleConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (TupleConstructor) - (TypeParameters))) + (TypeParameters) + (Empty))) (TypeSynonym (Type (Identifier) - (TypeParameters)) + (TypeParameters) + (Empty)) (Type (FunctionConstructor) - (TypeParameters))))) + (TypeParameters) + (Empty))))) From a7795bca03010b6d72895f74a730eb967949502f Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 16:53:48 -0700 Subject: [PATCH 07/11] Assign qualified type constructor identifiers --- src/Language/Haskell/Assignment.hs | 6 ++ src/Language/Haskell/Syntax.hs | 9 +++ ...lgebraic-datatype-declarations.diffA-B.txt | 8 +-- ...lgebraic-datatype-declarations.diffB-A.txt | 13 ++-- .../haskell/corpus/gadt-declarations.A.hs | 5 ++ .../haskell/corpus/gadt-declarations.B.hs | 5 ++ .../corpus/gadt-declarations.diffA-B.txt | 67 ++++++++++++++++++- .../corpus/gadt-declarations.diffB-A.txt | 67 ++++++++++++++++++- .../corpus/gadt-declarations.parseA.txt | 63 ++++++++++++++++- .../corpus/gadt-declarations.parseB.txt | 63 ++++++++++++++++- 10 files changed, 290 insertions(+), 16 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index a0aaf0f23..cfb98f83b 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -52,6 +52,7 @@ type Syntax = '[ , Syntax.ListConstructor , Syntax.Module , Syntax.Pragma + , Syntax.QualifiedTypeConstructorIdentifier , Syntax.RecordDataConstructor , Syntax.Star , Syntax.StrictType @@ -134,6 +135,7 @@ expressionChoices = [ , listExpression , listType , moduleIdentifier + , qualifiedTypeConstructorIdentifier , star , strictType , string @@ -246,6 +248,9 @@ parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children typeParam pragma :: Assignment pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) +qualifiedTypeConstructorIdentifier :: Assignment +qualifiedTypeConstructorIdentifier = makeTerm <$> symbol QualifiedTypeConstructorIdentifier <*> children (Syntax.QualifiedTypeConstructorIdentifier <$> (many expression)) + star :: Assignment star = makeTerm <$> token Star <*> pure Syntax.Star @@ -301,6 +306,7 @@ typeConstructor = constructorIdentifier <|> functionConstructor <|> listConstructor <|> listType + <|> qualifiedTypeConstructorIdentifier <|> typeClassIdentifier <|> typeConstructorIdentifier <|> tuplingConstructor diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 15da30297..ac2a6c6e4 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -225,3 +225,12 @@ instance Ord1 Star where liftCompare = genericLiftCompare instance Show1 Star where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Star + +data QualifiedTypeConstructorIdentifier a = QualifiedTypeConstructorIdentifier { qualifiedTypeConstructorIdentifierName :: [a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 QualifiedTypeConstructorIdentifier where liftEq = genericLiftEq +instance Ord1 QualifiedTypeConstructorIdentifier where liftCompare = genericLiftCompare +instance Show1 QualifiedTypeConstructorIdentifier where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable QualifiedTypeConstructorIdentifier diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index bbfff3dd9..a045ed128 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -75,15 +75,15 @@ { (Identifier) ->(Identifier) } (TypeParameters)) - {+(Constructor - {+(Empty)+} - {+(Identifier)+} - {+(TypeParameters)+})+} (Constructor (Empty) { (Identifier) ->(Identifier) } (TypeParameters)) + {+(Constructor + {+(Empty)+} + {+(Identifier)+} + {+(TypeParameters)+})+} (Constructor (Empty) { (Identifier) diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index 0dd399d37..e06482c14 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -75,6 +75,11 @@ { (Identifier) ->(Identifier) } (TypeParameters)) + (Constructor + (Empty) + { (Identifier) + ->(Identifier) } + (TypeParameters)) {+(Constructor {+(Empty)+} {+(Identifier)+} @@ -87,14 +92,6 @@ {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(Empty)+} - {+(Identifier)+} - {+(TypeParameters)+})+} - {-(Constructor - {-(Empty)-} - {-(Identifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(Empty)-} {-(Identifier)-} diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs index 631ca05fb..86efbd056 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.A.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -5,3 +5,8 @@ data Foo f a where Bar :: { jolo :: Maybe String, runJolo :: f a } -> Foo f a data Foo a :: [*] -> * where + +data Number a where + Integer :: !Prelude.Integer -> Number Prelude.Integer + Ratio :: !Prelude.Rational -> Number Prelude.Rational + Decimal :: !Scientific -> Number Scientific diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs index 9a676dfff..58598b7cd 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.B.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -5,3 +5,8 @@ data Bar f a where Baz :: { jolo :: Maybe String, runJolo :: f a } -> Bar f a data Bar a :: [*] -> [*] where + +data Number' a where + Integer' :: !Prelude.Integer -> Number Prelude.Integer + Ratio' :: !Prelude.Rational -> Number Prelude.Rational + Decimal' :: !Scientific -> Number Scientific diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt index 76dc49032..6e8ffa95c 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -96,4 +96,69 @@ { (Star) ->(KindListType {+(Star)+}) })))) - (Statements)))) + (Statements)) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (StrictType + (Identifier) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt index 284274376..8baac6330 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -96,4 +96,69 @@ { (KindListType {-(Star)-}) ->(Star) })))) - (Statements)))) + (Statements)) + (GADT + (Empty) + (Type + { (Identifier) + ->(Identifier) } + (Statements + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + { (Identifier) + ->(Identifier) } + (FunctionType + (Type + (StrictType + (Identifier) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt index 8089547ed..4176e6f8c 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -88,4 +88,65 @@ (Star))) (Kind (Star))))) - (Statements)))) + (Statements)) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (StrictType + (Identifier) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt index 82f5f6cc7..34035624c 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -89,4 +89,65 @@ (Kind (KindListType (Star)))))) - (Statements)))) + (Statements)) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (StrictType + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier)) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (QualifiedTypeConstructorIdentifier + (Identifier) + (Identifier))) + (Empty)))) + (GADTConstructor + (Empty) + (Identifier) + (FunctionType + (Type + (StrictType + (Identifier) + (TypeParameters)) + (TypeParameters) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)))))))) From fc7c578b9bdbcb0dbc73be88d4a80d4f870286f6 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 16:58:54 -0700 Subject: [PATCH 08/11] Allow pragmas within gadt constructors --- src/Language/Haskell/Assignment.hs | 2 +- .../haskell/corpus/gadt-declarations.A.hs | 3 ++ .../haskell/corpus/gadt-declarations.B.hs | 3 ++ .../corpus/gadt-declarations.diffA-B.txt | 36 ++++++++++++++++++- .../corpus/gadt-declarations.diffB-A.txt | 36 ++++++++++++++++++- .../corpus/gadt-declarations.parseA.txt | 35 +++++++++++++++++- .../corpus/gadt-declarations.parseB.txt | 35 +++++++++++++++++- 7 files changed, 145 insertions(+), 5 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index cfb98f83b..2998f85ea 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -191,7 +191,7 @@ gadtConstructor = makeTerm <$> (context' <|> emptyTerm) <*> typeConstructor <* token Annotation - <*> type') + <*> term type') gadtDeclaration :: Assignment gadtDeclaration = makeTerm diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs index 86efbd056..60162af60 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.A.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -10,3 +10,6 @@ data Number a where Integer :: !Prelude.Integer -> Number Prelude.Integer Ratio :: !Prelude.Rational -> Number Prelude.Rational Decimal :: !Scientific -> Number Scientific + +data Union r v where + Union :: {-# UNPACK #-} !Int -> t v -> Union r v diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs index 58598b7cd..172c064f9 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.B.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -10,3 +10,6 @@ data Number' a where Integer' :: !Prelude.Integer -> Number Prelude.Integer Ratio' :: !Prelude.Rational -> Number Prelude.Rational Decimal' :: !Scientific -> Number Scientific + +data Union r v where + Union :: {-# UNPACK #-} !Integer -> t v -> Union r v diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt index 6e8ffa95c..58cc0f5aa 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -161,4 +161,38 @@ (Identifier) (TypeParameters (Identifier)) - (Empty)))))))) + (Empty)))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (Context + (Pragma) + (FunctionType + (Type + (StrictType + { (Identifier) + ->(Identifier) } + (TypeParameters)) + (TypeParameters) + (Empty)) + (FunctionType + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier)) + (Empty)))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt index 8baac6330..6a444b491 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -161,4 +161,38 @@ (Identifier) (TypeParameters (Identifier)) - (Empty)))))))) + (Empty)))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (Context + (Pragma) + (FunctionType + (Type + (StrictType + { (Identifier) + ->(Identifier) } + (TypeParameters)) + (TypeParameters) + (Empty)) + (FunctionType + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier)) + (Empty)))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt index 4176e6f8c..dcced9135 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -149,4 +149,37 @@ (Identifier) (TypeParameters (Identifier)) - (Empty)))))))) + (Empty)))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (Context + (Pragma) + (FunctionType + (Type + (StrictType + (Identifier) + (TypeParameters)) + (TypeParameters) + (Empty)) + (FunctionType + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier)) + (Empty)))))))))) diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt index 34035624c..254ac19c4 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -150,4 +150,37 @@ (Identifier) (TypeParameters (Identifier)) - (Empty)))))))) + (Empty)))))) + (GADT + (Empty) + (Type + (Identifier) + (Statements + (Identifier) + (Identifier)) + (Empty)) + (Statements + (GADTConstructor + (Empty) + (Identifier) + (Context + (Pragma) + (FunctionType + (Type + (StrictType + (Identifier) + (TypeParameters)) + (TypeParameters) + (Empty)) + (FunctionType + (Type + (Identifier) + (TypeParameters + (Identifier)) + (Empty)) + (Type + (Identifier) + (TypeParameters + (Identifier) + (Identifier)) + (Empty)))))))))) From bd43959cb0a9a4afbe9e4d992f7f5beb2ec71f2d Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 17:03:27 -0700 Subject: [PATCH 09/11] Assign annotated type variables --- src/Language/Haskell/Assignment.hs | 5 +++++ src/Language/Haskell/Syntax.hs | 9 +++++++++ .../algebraic-datatype-declarations.diffA-B.txt | 13 +++++-------- .../algebraic-datatype-declarations.diffB-A.txt | 13 +++++-------- .../fixtures/haskell/corpus/gadt-declarations.A.hs | 2 +- .../fixtures/haskell/corpus/gadt-declarations.B.hs | 2 +- .../haskell/corpus/gadt-declarations.diffA-B.txt | 13 +++++++++++-- .../haskell/corpus/gadt-declarations.diffB-A.txt | 13 +++++++++++-- .../haskell/corpus/gadt-declarations.parseA.txt | 13 +++++++++++-- .../haskell/corpus/gadt-declarations.parseB.txt | 13 +++++++++++-- test/fixtures/haskell/corpus/literals.diffA-B.txt | 14 ++++++-------- 11 files changed, 76 insertions(+), 34 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 2998f85ea..c604b0537 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -33,6 +33,7 @@ type Syntax = '[ , Literal.Float , Literal.Integer , Literal.TextElement + , Syntax.AnnotatedTypeVariable , Syntax.Class , Syntax.Context , Syntax.Context' @@ -83,6 +84,9 @@ algebraicDatatypeDeclaration = makeTerm <|> pure []) <*> (derivingClause <|> emptyTerm)) +annotatedTypeVariable :: Assignment +annotatedTypeVariable = makeTerm <$> symbol AnnotatedTypeVariable <*> children (Syntax.AnnotatedTypeVariable <$> typeVariableIdentifier <* token Annotation <*> (kind <|> type')) + character :: Assignment character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) @@ -117,6 +121,7 @@ expression = term (handleError (choice expressionChoices)) expressionChoices :: [Assignment.Assignment [] Grammar Term] expressionChoices = [ algebraicDatatypeDeclaration + , annotatedTypeVariable , character , comment , context' diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index ac2a6c6e4..f928aa351 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -234,3 +234,12 @@ instance Ord1 QualifiedTypeConstructorIdentifier where liftCompare = genericLift instance Show1 QualifiedTypeConstructorIdentifier where liftShowsPrec = genericLiftShowsPrec instance Evaluatable QualifiedTypeConstructorIdentifier + +data AnnotatedTypeVariable a = AnnotatedTypeVariable { annotatedTypeVariableIdentifier :: a, annotatedTypeVariableannotation :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 AnnotatedTypeVariable where liftEq = genericLiftEq +instance Ord1 AnnotatedTypeVariable where liftCompare = genericLiftCompare +instance Show1 AnnotatedTypeVariable where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable AnnotatedTypeVariable diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt index a045ed128..3a46b95c9 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -80,10 +80,6 @@ { (Identifier) ->(Identifier) } (TypeParameters)) - {+(Constructor - {+(Empty)+} - {+(Identifier)+} - {+(TypeParameters)+})+} (Constructor (Empty) { (Identifier) @@ -93,10 +89,11 @@ {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} - {-(Constructor - {-(Empty)-} - {-(Identifier)-} - {-(TypeParameters)-})-} + (Constructor + (Empty) + { (Identifier) + ->(Identifier) } + (TypeParameters)) {-(Constructor {-(Empty)-} {-(Identifier)-} diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt index e06482c14..56e963130 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -80,6 +80,11 @@ { (Identifier) ->(Identifier) } (TypeParameters)) + (Constructor + (Empty) + { (Identifier) + ->(Identifier) } + (TypeParameters)) {+(Constructor {+(Empty)+} {+(Identifier)+} @@ -88,14 +93,6 @@ {+(Empty)+} {+(Identifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(Empty)+} - {+(Identifier)+} - {+(TypeParameters)+})+} - {-(Constructor - {-(Empty)-} - {-(Identifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(Empty)-} {-(Identifier)-} diff --git a/test/fixtures/haskell/corpus/gadt-declarations.A.hs b/test/fixtures/haskell/corpus/gadt-declarations.A.hs index 60162af60..8876c4126 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.A.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.A.hs @@ -11,5 +11,5 @@ data Number a where Ratio :: !Prelude.Rational -> Number Prelude.Rational Decimal :: !Scientific -> Number Scientific -data Union r v where +data Union (r :: [ * -> * ]) (v :: *) where Union :: {-# UNPACK #-} !Int -> t v -> Union r v diff --git a/test/fixtures/haskell/corpus/gadt-declarations.B.hs b/test/fixtures/haskell/corpus/gadt-declarations.B.hs index 172c064f9..4c089cc2f 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.B.hs +++ b/test/fixtures/haskell/corpus/gadt-declarations.B.hs @@ -11,5 +11,5 @@ data Number' a where Ratio' :: !Prelude.Rational -> Number Prelude.Rational Decimal' :: !Scientific -> Number Scientific -data Union r v where +data Union (r :: [ * -> * ]) (v :: *) where Union :: {-# UNPACK #-} !Integer -> t v -> Union r v diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt index 58cc0f5aa..56734d575 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffA-B.txt @@ -167,8 +167,17 @@ (Type (Identifier) (Statements - (Identifier) - (Identifier)) + (AnnotatedTypeVariable + (Identifier) + (KindListType + (KindFunctionType + (Kind + (Star)) + (Kind + (Star))))) + (AnnotatedTypeVariable + (Identifier) + (Star))) (Empty)) (Statements (GADTConstructor diff --git a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt index 6a444b491..52a33ff2e 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.diffB-A.txt @@ -167,8 +167,17 @@ (Type (Identifier) (Statements - (Identifier) - (Identifier)) + (AnnotatedTypeVariable + (Identifier) + (KindListType + (KindFunctionType + (Kind + (Star)) + (Kind + (Star))))) + (AnnotatedTypeVariable + (Identifier) + (Star))) (Empty)) (Statements (GADTConstructor diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt index dcced9135..5d2750deb 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseA.txt @@ -155,8 +155,17 @@ (Type (Identifier) (Statements - (Identifier) - (Identifier)) + (AnnotatedTypeVariable + (Identifier) + (KindListType + (KindFunctionType + (Kind + (Star)) + (Kind + (Star))))) + (AnnotatedTypeVariable + (Identifier) + (Star))) (Empty)) (Statements (GADTConstructor diff --git a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt index 254ac19c4..a6513365b 100644 --- a/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/gadt-declarations.parseB.txt @@ -156,8 +156,17 @@ (Type (Identifier) (Statements - (Identifier) - (Identifier)) + (AnnotatedTypeVariable + (Identifier) + (KindListType + (KindFunctionType + (Kind + (Star)) + (Kind + (Star))))) + (AnnotatedTypeVariable + (Identifier) + (Star))) (Empty)) (Statements (GADTConstructor diff --git a/test/fixtures/haskell/corpus/literals.diffA-B.txt b/test/fixtures/haskell/corpus/literals.diffA-B.txt index e428f0440..462bfd807 100644 --- a/test/fixtures/haskell/corpus/literals.diffA-B.txt +++ b/test/fixtures/haskell/corpus/literals.diffA-B.txt @@ -49,10 +49,12 @@ {+(Identifier)+} {+(Statements {+(Float)+})+})+} - {+(Function - {+(Identifier)+} - {+(Statements - {+(Float)+})+})+} + (Function + { (Identifier) + ->(Identifier) } + (Statements + {+(Float)+} + {-(Integer)-})) {+(Function {+(Identifier)+} {+(Statements @@ -283,10 +285,6 @@ {-(Identifier)-} {-(Statements {-(Integer)-})-})-} - {-(Function - {-(Identifier)-} - {-(Statements - {-(Integer)-})-})-} {-(Function {-(Identifier)-} {-(Statements From c9998e2ada475ee419d59d88c52dfadce81f273c Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 17:17:59 -0700 Subject: [PATCH 10/11] hlint suggestions --- src/Language/Haskell/Assignment.hs | 4 ++-- src/Language/Haskell/Syntax.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index c604b0537..79174c455 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -206,7 +206,7 @@ gadtDeclaration = makeTerm <*> (makeTerm <$> location <*> (Syntax.Type <$> typeConstructor <*> typeParameters' <*> (kindSignature <|> emptyTerm))) <*> where') where - typeParameters' = makeTerm <$> location <*> (manyTermsTill expression (symbol KindSignature <|> symbol Where')) + typeParameters' = makeTerm <$> location <*> manyTermsTill expression (symbol KindSignature <|> symbol Where') integer :: Assignment integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source) @@ -254,7 +254,7 @@ pragma :: Assignment pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) qualifiedTypeConstructorIdentifier :: Assignment -qualifiedTypeConstructorIdentifier = makeTerm <$> symbol QualifiedTypeConstructorIdentifier <*> children (Syntax.QualifiedTypeConstructorIdentifier <$> (many expression)) +qualifiedTypeConstructorIdentifier = makeTerm <$> symbol QualifiedTypeConstructorIdentifier <*> children (Syntax.QualifiedTypeConstructorIdentifier <$> many expression) star :: Assignment star = makeTerm <$> token Star <*> pure Syntax.Star diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index f928aa351..be1acc529 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -226,7 +226,7 @@ instance Show1 Star where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Star -data QualifiedTypeConstructorIdentifier a = QualifiedTypeConstructorIdentifier { qualifiedTypeConstructorIdentifierName :: [a] } +newtype QualifiedTypeConstructorIdentifier a = QualifiedTypeConstructorIdentifier { qualifiedTypeConstructorIdentifierName :: [a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 QualifiedTypeConstructorIdentifier where liftEq = genericLiftEq From 8ab606654cfdf1501f019b00145eb5127220a209 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 6 Jun 2018 20:42:04 -0700 Subject: [PATCH 11/11] Update go test fixtures --- test/fixtures/go/corpus/channel-types.diffA-B.txt | 2 ++ test/fixtures/go/corpus/channel-types.diffB-A.txt | 2 ++ test/fixtures/go/corpus/channel-types.parseA.txt | 1 + test/fixtures/go/corpus/channel-types.parseB.txt | 1 + test/fixtures/go/corpus/struct-field-declarations.diffA-B.txt | 1 + test/fixtures/go/corpus/struct-field-declarations.diffB-A.txt | 1 + test/fixtures/go/corpus/struct-field-declarations.parseA.txt | 1 + test/fixtures/go/corpus/struct-field-declarations.parseB.txt | 1 + test/fixtures/go/corpus/struct-literals.diffA-B.txt | 1 + test/fixtures/go/corpus/struct-literals.diffB-A.txt | 1 + test/fixtures/go/corpus/struct-literals.parseA.txt | 1 + test/fixtures/go/corpus/struct-literals.parseB.txt | 1 + test/fixtures/go/corpus/struct-types.diffA-B.txt | 4 ++++ test/fixtures/go/corpus/struct-types.diffB-A.txt | 4 ++++ test/fixtures/go/corpus/struct-types.parseA.txt | 4 ++++ test/fixtures/go/corpus/struct-types.parseB.txt | 4 ++++ test/fixtures/go/corpus/type-declarations.diffA-B.txt | 1 + test/fixtures/go/corpus/type-declarations.diffB-A.txt | 1 + test/fixtures/go/corpus/type-declarations.parseA.txt | 1 + test/fixtures/go/corpus/type-declarations.parseB.txt | 1 + 20 files changed, 34 insertions(+) diff --git a/test/fixtures/go/corpus/channel-types.diffA-B.txt b/test/fixtures/go/corpus/channel-types.diffA-B.txt index efabef389..0bb4c5d10 100644 --- a/test/fixtures/go/corpus/channel-types.diffA-B.txt +++ b/test/fixtures/go/corpus/channel-types.diffA-B.txt @@ -16,6 +16,7 @@ {+(SendChannel {+(SendChannel {+(Constructor + {+(Empty)+} {+(Empty)+} {+(Statements)+})+})+})+})+} {+(Type @@ -44,6 +45,7 @@ {-(SendChannel {-(SendChannel {-(Constructor + {-(Empty)-} {-(Empty)-} {-(Statements)-})-})-})-})-} {-(Type diff --git a/test/fixtures/go/corpus/channel-types.diffB-A.txt b/test/fixtures/go/corpus/channel-types.diffB-A.txt index efabef389..0bb4c5d10 100644 --- a/test/fixtures/go/corpus/channel-types.diffB-A.txt +++ b/test/fixtures/go/corpus/channel-types.diffB-A.txt @@ -16,6 +16,7 @@ {+(SendChannel {+(SendChannel {+(Constructor + {+(Empty)+} {+(Empty)+} {+(Statements)+})+})+})+})+} {+(Type @@ -44,6 +45,7 @@ {-(SendChannel {-(SendChannel {-(Constructor + {-(Empty)-} {-(Empty)-} {-(Statements)-})-})-})-})-} {-(Type diff --git a/test/fixtures/go/corpus/channel-types.parseA.txt b/test/fixtures/go/corpus/channel-types.parseA.txt index 1fac3aefe..4e94d7b52 100644 --- a/test/fixtures/go/corpus/channel-types.parseA.txt +++ b/test/fixtures/go/corpus/channel-types.parseA.txt @@ -16,6 +16,7 @@ (SendChannel (SendChannel (Constructor + (Empty) (Empty) (Statements))))) (Type diff --git a/test/fixtures/go/corpus/channel-types.parseB.txt b/test/fixtures/go/corpus/channel-types.parseB.txt index 1fac3aefe..4e94d7b52 100644 --- a/test/fixtures/go/corpus/channel-types.parseB.txt +++ b/test/fixtures/go/corpus/channel-types.parseB.txt @@ -16,6 +16,7 @@ (SendChannel (SendChannel (Constructor + (Empty) (Empty) (Statements))))) (Type diff --git a/test/fixtures/go/corpus/struct-field-declarations.diffA-B.txt b/test/fixtures/go/corpus/struct-field-declarations.diffA-B.txt index 1d0b7c811..51770074a 100644 --- a/test/fixtures/go/corpus/struct-field-declarations.diffA-B.txt +++ b/test/fixtures/go/corpus/struct-field-declarations.diffA-B.txt @@ -9,6 +9,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) diff --git a/test/fixtures/go/corpus/struct-field-declarations.diffB-A.txt b/test/fixtures/go/corpus/struct-field-declarations.diffB-A.txt index b7a5a2f01..dcd89776f 100644 --- a/test/fixtures/go/corpus/struct-field-declarations.diffB-A.txt +++ b/test/fixtures/go/corpus/struct-field-declarations.diffB-A.txt @@ -9,6 +9,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) diff --git a/test/fixtures/go/corpus/struct-field-declarations.parseA.txt b/test/fixtures/go/corpus/struct-field-declarations.parseA.txt index a177758b5..53b7f27ab 100644 --- a/test/fixtures/go/corpus/struct-field-declarations.parseA.txt +++ b/test/fixtures/go/corpus/struct-field-declarations.parseA.txt @@ -9,6 +9,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) diff --git a/test/fixtures/go/corpus/struct-field-declarations.parseB.txt b/test/fixtures/go/corpus/struct-field-declarations.parseB.txt index a35c7eba2..3bbf256f0 100644 --- a/test/fixtures/go/corpus/struct-field-declarations.parseB.txt +++ b/test/fixtures/go/corpus/struct-field-declarations.parseB.txt @@ -9,6 +9,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) diff --git a/test/fixtures/go/corpus/struct-literals.diffA-B.txt b/test/fixtures/go/corpus/struct-literals.diffA-B.txt index fa62a4845..5033dc7f7 100644 --- a/test/fixtures/go/corpus/struct-literals.diffA-B.txt +++ b/test/fixtures/go/corpus/struct-literals.diffA-B.txt @@ -22,6 +22,7 @@ (Identifier) (Composite (Constructor + (Empty) (Empty) (Field { (Identifier) diff --git a/test/fixtures/go/corpus/struct-literals.diffB-A.txt b/test/fixtures/go/corpus/struct-literals.diffB-A.txt index fa62a4845..5033dc7f7 100644 --- a/test/fixtures/go/corpus/struct-literals.diffB-A.txt +++ b/test/fixtures/go/corpus/struct-literals.diffB-A.txt @@ -22,6 +22,7 @@ (Identifier) (Composite (Constructor + (Empty) (Empty) (Field { (Identifier) diff --git a/test/fixtures/go/corpus/struct-literals.parseA.txt b/test/fixtures/go/corpus/struct-literals.parseA.txt index 52dcb474d..a743a0c5e 100644 --- a/test/fixtures/go/corpus/struct-literals.parseA.txt +++ b/test/fixtures/go/corpus/struct-literals.parseA.txt @@ -21,6 +21,7 @@ (Identifier) (Composite (Constructor + (Empty) (Empty) (Field (Identifier) diff --git a/test/fixtures/go/corpus/struct-literals.parseB.txt b/test/fixtures/go/corpus/struct-literals.parseB.txt index 52dcb474d..a743a0c5e 100644 --- a/test/fixtures/go/corpus/struct-literals.parseB.txt +++ b/test/fixtures/go/corpus/struct-literals.parseB.txt @@ -21,6 +21,7 @@ (Identifier) (Composite (Constructor + (Empty) (Empty) (Field (Identifier) diff --git a/test/fixtures/go/corpus/struct-types.diffA-B.txt b/test/fixtures/go/corpus/struct-types.diffA-B.txt index 00224e093..28080db5b 100644 --- a/test/fixtures/go/corpus/struct-types.diffA-B.txt +++ b/test/fixtures/go/corpus/struct-types.diffA-B.txt @@ -11,6 +11,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Statements)))) (Statements @@ -18,6 +19,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Field (Identifier) @@ -27,6 +29,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Field (Identifier) @@ -38,6 +41,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/struct-types.diffB-A.txt b/test/fixtures/go/corpus/struct-types.diffB-A.txt index 00224e093..28080db5b 100644 --- a/test/fixtures/go/corpus/struct-types.diffB-A.txt +++ b/test/fixtures/go/corpus/struct-types.diffB-A.txt @@ -11,6 +11,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Statements)))) (Statements @@ -18,6 +19,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Field (Identifier) @@ -27,6 +29,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Field (Identifier) @@ -38,6 +41,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/struct-types.parseA.txt b/test/fixtures/go/corpus/struct-types.parseA.txt index bd6e6cb4d..3c0d740f7 100644 --- a/test/fixtures/go/corpus/struct-types.parseA.txt +++ b/test/fixtures/go/corpus/struct-types.parseA.txt @@ -10,12 +10,14 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Statements)))) (Statements (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) @@ -24,6 +26,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) @@ -34,6 +37,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/struct-types.parseB.txt b/test/fixtures/go/corpus/struct-types.parseB.txt index bd6e6cb4d..3c0d740f7 100644 --- a/test/fixtures/go/corpus/struct-types.parseB.txt +++ b/test/fixtures/go/corpus/struct-types.parseB.txt @@ -10,12 +10,14 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Statements)))) (Statements (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) @@ -24,6 +26,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Field (Identifier) @@ -34,6 +37,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/type-declarations.diffA-B.txt b/test/fixtures/go/corpus/type-declarations.diffA-B.txt index 07b5f067b..22748e379 100644 --- a/test/fixtures/go/corpus/type-declarations.diffA-B.txt +++ b/test/fixtures/go/corpus/type-declarations.diffA-B.txt @@ -30,6 +30,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/type-declarations.diffB-A.txt b/test/fixtures/go/corpus/type-declarations.diffB-A.txt index 07b5f067b..22748e379 100644 --- a/test/fixtures/go/corpus/type-declarations.diffB-A.txt +++ b/test/fixtures/go/corpus/type-declarations.diffB-A.txt @@ -30,6 +30,7 @@ { (Identifier) ->(Identifier) } (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/type-declarations.parseA.txt b/test/fixtures/go/corpus/type-declarations.parseA.txt index 0833c568a..61f1b0b35 100644 --- a/test/fixtures/go/corpus/type-declarations.parseA.txt +++ b/test/fixtures/go/corpus/type-declarations.parseA.txt @@ -23,6 +23,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Statements (Field diff --git a/test/fixtures/go/corpus/type-declarations.parseB.txt b/test/fixtures/go/corpus/type-declarations.parseB.txt index 0833c568a..61f1b0b35 100644 --- a/test/fixtures/go/corpus/type-declarations.parseB.txt +++ b/test/fixtures/go/corpus/type-declarations.parseB.txt @@ -23,6 +23,7 @@ (Type (Identifier) (Constructor + (Empty) (Empty) (Statements (Field