From 5824ea1b730038a9f0df4045755d9e9cb47b8d28 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Fri, 8 Jun 2018 15:03:49 -0700 Subject: [PATCH 01/23] Add additional type signature tests --- .../haskell/corpus/type-signatures.A.hs | 10 + .../haskell/corpus/type-signatures.B.hs | 10 + .../corpus/type-signatures.diffA-B.txt | 344 ++++++++++++++- .../corpus/type-signatures.diffB-A.txt | 391 ++++++++++++++++-- .../haskell/corpus/type-signatures.parseA.txt | 173 +++++++- .../haskell/corpus/type-signatures.parseB.txt | 173 +++++++- 6 files changed, 1072 insertions(+), 29 deletions(-) diff --git a/test/fixtures/haskell/corpus/type-signatures.A.hs b/test/fixtures/haskell/corpus/type-signatures.A.hs index 7f05bc1d5..6ff019c42 100644 --- a/test/fixtures/haskell/corpus/type-signatures.A.hs +++ b/test/fixtures/haskell/corpus/type-signatures.A.hs @@ -10,3 +10,13 @@ f :: a -> B c (D (E g ': h)) -> I [J k] (L m (N (O p ': q))) f :: forall a. [a] -> [a] f :: forall a b. (a, b) -> [a] apply :: proxy c -> (forall g . c g => g a -> b) -> Union fs a -> b + +f :: a ~ Int => a +f :: (a ~ Int) => a +sumCollects :: forall c1 c2. (B c1, B c2, E c1 ~ E c2) => c1 -> c2 -> c2 + +foo :: (Bar m) => Baz [Fiz Fuzz, Wiz, Wax, Woz] bar => a -> Baz m +bar :: (Baz '[Foo Wix a] biz, Waz woo) => Out a -> [Foo] -> Baz biz Waz + +foo :: (f :< Bar) => Bar -> f +yield :: ((Yield a b) :< e) => a diff --git a/test/fixtures/haskell/corpus/type-signatures.B.hs b/test/fixtures/haskell/corpus/type-signatures.B.hs index 4390ea80e..f3914a929 100644 --- a/test/fixtures/haskell/corpus/type-signatures.B.hs +++ b/test/fixtures/haskell/corpus/type-signatures.B.hs @@ -9,3 +9,13 @@ g :: b -> B a (D (E g ': h)) -> I [J k] (L m (O (N p ': q))) g :: forall a. [a] -> [a] g :: forall a b. (a, b) -> [a] apply :: proxy d -> (forall g . d g => g a -> b) -> Union fs a -> b + +g :: a ~ Int => a +g :: (a ~ Int) => a +sumCollects :: forall d1 d2. (B d1, B d2, E d1 ~ E d2) => d1 -> d2 -> d2 + +bar :: (Bar m) => Baz [Fiz Fuzz, Wiz, Wax, Woz] bar => a -> Waz m +foo :: (Baz '[Foo Wix a] biz, Waz woo) => Out a -> [Foo] -> Waz biz Baz + +bar :: (f :< Bar) => Bar -> f +yield :: ((Yield b c) :< e) => b diff --git a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt index 5174da51a..599f1df94 100644 --- a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt @@ -232,6 +232,177 @@ {+(TypeVariableIdentifier)+} {+(TypeParameters)+} {+(Empty)+})+})+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+})+} + {+(TypeVariableIdentifier)+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+})+} + {+(TypeVariableIdentifier)+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(ScopedTypeVariables + {+(Statements + {+(TypeVariableIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+} + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+} + {+(Statements + {+(EqualityConstraint + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+})+})+} + {+(FunctionType + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(FunctionType + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeConstructorIdentifier)+})+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeVariableIdentifier)+})+})+})+})+} + {+(FunctionType + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(QuotedName + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeConstructorIdentifier)+} + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+})+})+} + {+(TypeVariableIdentifier)+})+})+})+} + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+})+} + {+(FunctionType + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+} + {+(FunctionType + {+(Type + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+} + {+(Empty)+})+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(TypeVariableIdentifier)+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+} + {+(TypeConstructorIdentifier)+})+})+} + {+(FunctionType + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+} + {+(TypeVariableIdentifier)+})+})+} + {+(TypeVariableIdentifier)+})+} {-(TypeSignature {-(VariableIdentifier)-} {-(FunctionType @@ -471,4 +642,175 @@ {-(Type {-(TypeVariableIdentifier)-} {-(TypeParameters)-} - {-(Empty)-})-})-})-})-})-})) + {-(Empty)-})-})-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-})-} + {-(TypeVariableIdentifier)-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-})-} + {-(TypeVariableIdentifier)-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(ScopedTypeVariables + {-(Statements + {-(TypeVariableIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-} + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-} + {-(Statements + {-(EqualityConstraint + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-})-})-} + {-(FunctionType + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(FunctionType + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeConstructorIdentifier)-})-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeVariableIdentifier)-})-})-})-})-} + {-(FunctionType + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(QuotedName + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeConstructorIdentifier)-} + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-})-})-} + {-(TypeVariableIdentifier)-})-})-})-} + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-})-} + {-(FunctionType + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-} + {-(FunctionType + {-(Type + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-} + {-(Empty)-})-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(TypeVariableIdentifier)-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-} + {-(TypeConstructorIdentifier)-})-})-} + {-(FunctionType + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-} + {-(TypeVariableIdentifier)-})-})-} + {-(TypeVariableIdentifier)-})-})) diff --git a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt index 1d511880c..40a84d4d5 100644 --- a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt @@ -94,30 +94,21 @@ {+(TypeConstructorIdentifier)+} {+(TypeParameters)+} {+(Empty)+})+})+})+} - (TypeSignature - { (VariableIdentifier) - ->(VariableIdentifier) } - {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} - (FunctionType - (Type - { (TypeVariableIdentifier) - ->(Array + {+(TypeSignature + {+(VariableIdentifier)+} + {+(FunctionType + {+(Type + {+(Array {+(Type {+(TypeConstructorIdentifier)+} {+(TypeParameters)+} - {+(Empty)+})+}) } - (TypeParameters) - (Empty)) - (Type - { (TypeVariableIdentifier) - ->(TypeConstructorIdentifier) } - (TypeParameters) - (Empty)))) + {+(Empty)+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+} {+(TypeSignature {+(VariableIdentifier)+} {+(FunctionType @@ -278,9 +269,185 @@ {+(TypeVariableIdentifier)+} {+(TypeParameters)+} {+(Empty)+})+})+})+})+})+} - {-(TypeSignature - {-(VariableIdentifier)-} - {-(FunctionType + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+})+} + {+(TypeVariableIdentifier)+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+})+} + {+(TypeVariableIdentifier)+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(ScopedTypeVariables + {+(Statements + {+(TypeVariableIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+} + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+} + {+(Statements + {+(EqualityConstraint + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+})+})+} + {+(FunctionType + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(FunctionType + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeConstructorIdentifier)+})+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeVariableIdentifier)+})+})+})+})+} + {+(FunctionType + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+})+})+} + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(QuotedName + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeConstructorIdentifier)+} + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+})+})+} + {+(TypeVariableIdentifier)+})+})+})+} + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+})+})+})+} + {+(FunctionType + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+} + {+(FunctionType + {+(Type + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+} + {+(Empty)+})+})+})+})+} + (TypeSignature + { (VariableIdentifier) + ->(VariableIdentifier) } + (Context' + (Statements + {+(TypeVariableIdentifier)+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+} + {+(TypeConstructorIdentifier)+} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})) + (FunctionType + (Type + { (TypeVariableIdentifier) + ->(TypeConstructorIdentifier) } + (TypeParameters) + (Empty)) + (Type + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) } + (TypeParameters) + (Empty)))) + (TypeSignature + { (VariableIdentifier) + ->(VariableIdentifier) } + {+(Context' + {+(Statements + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeParameters + {+(TypeVariableIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+} + {+(TypeVariableIdentifier)+})+})+} + { (FunctionType {-(Type {-(TypeConstructorIdentifier)-} {-(TypeParameters)-} @@ -288,7 +455,8 @@ {-(Type {-(TypeConstructorIdentifier)-} {-(TypeParameters)-} - {-(Empty)-})-})-})-} + {-(Empty)-})-}) + ->(TypeVariableIdentifier) }) {-(TypeSignature {-(VariableIdentifier)-} {-(FunctionType @@ -463,4 +631,175 @@ {-(Type {-(TypeVariableIdentifier)-} {-(TypeParameters)-} - {-(Empty)-})-})-})-})-})-})) + {-(Empty)-})-})-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-})-} + {-(TypeVariableIdentifier)-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-})-} + {-(TypeVariableIdentifier)-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(ScopedTypeVariables + {-(Statements + {-(TypeVariableIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-} + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-} + {-(Statements + {-(EqualityConstraint + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-})-})-} + {-(FunctionType + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(FunctionType + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeConstructorIdentifier)-})-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeVariableIdentifier)-})-})-})-})-} + {-(FunctionType + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(QuotedName + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeConstructorIdentifier)-} + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-})-})-} + {-(TypeVariableIdentifier)-})-})-})-} + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-})-})-})-} + {-(FunctionType + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-} + {-(FunctionType + {-(Type + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-} + {-(Empty)-})-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(TypeVariableIdentifier)-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-} + {-(TypeConstructorIdentifier)-})-})-} + {-(FunctionType + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeVariableIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-})-} + {-(TypeSignature + {-(VariableIdentifier)-} + {-(Context' + {-(Statements + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeParameters + {-(TypeVariableIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-} + {-(TypeVariableIdentifier)-})-})-} + {-(TypeVariableIdentifier)-})-})) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseA.txt b/test/fixtures/haskell/corpus/type-signatures.parseA.txt index 3dceadee9..c15a85bda 100644 --- a/test/fixtures/haskell/corpus/type-signatures.parseA.txt +++ b/test/fixtures/haskell/corpus/type-signatures.parseA.txt @@ -267,4 +267,175 @@ (Type (TypeVariableIdentifier) (TypeParameters) - (Empty)))))))) + (Empty)))))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier)))) + (TypeVariableIdentifier)) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier)))) + (TypeVariableIdentifier)) + (TypeSignature + (VariableIdentifier) + (ScopedTypeVariables + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier)))) + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier)))) + (Statements + (EqualityConstraint + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier))) + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier)))))) + (FunctionType + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)) + (FunctionType + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty))))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier))))) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeConstructorIdentifier)) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty))) + (TypeVariableIdentifier))))) + (FunctionType + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeVariableIdentifier)) + (Empty)))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (QuotedName + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeConstructorIdentifier) + (TypeVariableIdentifier)) + (Empty)))) + (TypeVariableIdentifier)))) + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier))))) + (FunctionType + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeVariableIdentifier)) + (Empty)) + (FunctionType + (Type + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty))) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeVariableIdentifier) + (TypeConstructorIdentifier)) + (Empty))))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (TypeVariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (TypeConstructorIdentifier))) + (FunctionType + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (ConstructorOperator + (ConstructorSymbol)) + (TypeVariableIdentifier))) + (TypeVariableIdentifier)))) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseB.txt b/test/fixtures/haskell/corpus/type-signatures.parseB.txt index 107692d14..1ae9563a8 100644 --- a/test/fixtures/haskell/corpus/type-signatures.parseB.txt +++ b/test/fixtures/haskell/corpus/type-signatures.parseB.txt @@ -230,4 +230,175 @@ (Type (TypeVariableIdentifier) (TypeParameters) - (Empty)))))))) + (Empty)))))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier)))) + (TypeVariableIdentifier)) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier)))) + (TypeVariableIdentifier)) + (TypeSignature + (VariableIdentifier) + (ScopedTypeVariables + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier)))) + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier)))) + (Statements + (EqualityConstraint + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier))) + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier)))))) + (FunctionType + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)) + (FunctionType + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty))))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier))))) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeConstructorIdentifier)) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty))) + (TypeVariableIdentifier))))) + (FunctionType + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeVariableIdentifier)) + (Empty)))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (QuotedName + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeConstructorIdentifier) + (TypeVariableIdentifier)) + (Empty)))) + (TypeVariableIdentifier)))) + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier))))) + (FunctionType + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeVariableIdentifier)) + (Empty)) + (FunctionType + (Type + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty))) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeVariableIdentifier) + (TypeConstructorIdentifier)) + (Empty))))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (TypeVariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (TypeConstructorIdentifier))) + (FunctionType + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeVariableIdentifier) + (TypeParameters) + (Empty)))) + (TypeSignature + (VariableIdentifier) + (Context' + (Statements + (Class + (TypeClassIdentifier) + (TypeParameters + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (ConstructorOperator + (ConstructorSymbol)) + (TypeVariableIdentifier))) + (TypeVariableIdentifier)))) From fadf84870efe8a412a340768662509ee2db597d2 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Fri, 8 Jun 2018 15:46:03 -0700 Subject: [PATCH 02/23] Assign standalone deriving instances --- src/Language/Haskell/Assignment.hs | 16 +- src/Language/Haskell/Syntax.hs | 13 +- ...lgebraic-datatype-declarations.diffA-B.txt | 65 ++-- ...lgebraic-datatype-declarations.diffB-A.txt | 73 ++--- ...algebraic-datatype-declarations.parseA.txt | 49 +-- ...algebraic-datatype-declarations.parseB.txt | 49 +-- .../haskell/corpus/literals.diffA-B.txt | 13 +- .../haskell/corpus/literals.diffB-A.txt | 27 +- .../corpus/newtype-declaration.diffA-B.txt | 8 +- .../corpus/newtype-declaration.diffB-A.txt | 8 +- .../corpus/newtype-declaration.parseA.txt | 8 +- .../corpus/newtype-declaration.parseB.txt | 8 +- .../standalone-deriving-declaration.A.hs | 4 + .../standalone-deriving-declaration.B.hs | 4 + ...tandalone-deriving-declaration.diffA-B.txt | 72 +++++ ...tandalone-deriving-declaration.diffB-A.txt | 72 +++++ ...standalone-deriving-declaration.parseA.txt | 60 ++++ ...standalone-deriving-declaration.parseB.txt | 60 ++++ .../corpus/type-signatures.diffA-B.txt | 236 ++++++-------- .../corpus/type-signatures.diffB-A.txt | 292 ++++++++---------- .../haskell/corpus/type-signatures.parseA.txt | 122 +++----- .../haskell/corpus/type-signatures.parseB.txt | 114 +++---- .../haskell/corpus/type-synonyms.diffA-B.txt | 182 ++++------- .../haskell/corpus/type-synonyms.diffB-A.txt | 24 +- .../haskell/corpus/type-synonyms.parseA.txt | 3 +- .../haskell/corpus/type-synonyms.parseB.txt | 3 +- 26 files changed, 823 insertions(+), 762 deletions(-) create mode 100644 test/fixtures/haskell/corpus/standalone-deriving-declaration.A.hs create mode 100644 test/fixtures/haskell/corpus/standalone-deriving-declaration.B.hs create mode 100644 test/fixtures/haskell/corpus/standalone-deriving-declaration.diffA-B.txt create mode 100644 test/fixtures/haskell/corpus/standalone-deriving-declaration.diffB-A.txt create mode 100644 test/fixtures/haskell/corpus/standalone-deriving-declaration.parseA.txt create mode 100644 test/fixtures/haskell/corpus/standalone-deriving-declaration.parseB.txt diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index ddc53e133..fe38e228a 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -72,6 +72,7 @@ type Syntax = '[ , Syntax.QuotedName , Syntax.RecordDataConstructor , Syntax.ScopedTypeVariables + , Syntax.StandaloneDerivingInstance , Syntax.Star , Syntax.StrictType , Syntax.StrictTypeVariable @@ -120,7 +121,7 @@ character :: Assignment character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) class' :: Assignment -class' = makeTerm <$> symbol Class <*> children (Syntax.Class <$> typeConstructor <*> typeParameters) +class' = makeTerm <$> symbol Class <*> children (Syntax.Class <$> manyTerm expression) comment :: Assignment comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) @@ -139,10 +140,10 @@ constructorSymbol :: Assignment constructorSymbol = makeTerm <$> symbol ConstructorSymbol <*> (Syntax.ConstructorSymbol . Name.name <$> source) context' :: Assignment -context' = makeTerm <$> symbol Context <*> children (Syntax.Context' <$> manyTerm expression) +context' = makeTerm <$> symbol Context <*> children (Syntax.Context' <$> expressions) contextPattern :: Assignment -contextPattern = makeTerm <$> symbol ContextPattern <*> children (manyTerm expression) +contextPattern = symbol ContextPattern *> children (expressions) defaultDeclaration :: Assignment defaultDeclaration = makeTerm <$> symbol DefaultDeclaration <*> children (Syntax.DefaultDeclaration <$> manyTerm expression) @@ -204,12 +205,14 @@ expressionChoices = [ , qualifiedTypeConstructorIdentifier , quotedName , scopedTypeVariables + , standaloneDerivingInstance , star , strictType , string , tupleType , type' , type'' + , typeClassIdentifier , typePattern , typeConstructorExport , typeConstructorIdentifier @@ -358,6 +361,11 @@ quotedName = makeTerm <$> symbol QuotedName <*> children (Syntax.QuotedName <$> scopedTypeVariables :: Assignment scopedTypeVariables = makeTerm <$> symbol ScopedTypeVariables <*> children (Syntax.ScopedTypeVariables <$> expressions <* token Dot) +standaloneDerivingInstance :: Assignment +standaloneDerivingInstance = makeTerm <$> symbol StandaloneDerivingDeclaration <*> children (Syntax.StandaloneDerivingInstance <$> manyTerm (context' <|> scopedTypeVariables) <*> expression <*> instance') + where + instance' = symbol Instance *> children (expressions) + star :: Assignment star = makeTerm <$> token Star <*> pure Syntax.Star @@ -386,7 +394,7 @@ typeOperator :: Assignment typeOperator = makeTerm <$> symbol TypeOperator <*> (Syntax.TypeOperator . Name.name <$> source) typeSignature :: Assignment -typeSignature = makeTerm <$> symbol TypeSignature <*> children (Syntax.TypeSignature <$> variableIdentifier <* token Annotation <*> manyTerm (context' <|> scopedTypeVariables) <*> expression) +typeSignature = makeTerm <$> symbol TypeSignature <*> children (Syntax.TypeSignature <$> variableIdentifier <* token Annotation <*> manyTerm (context' <|> scopedTypeVariables) <*> expressions) typeVariableIdentifier :: Assignment typeVariableIdentifier = makeTerm <$> symbol TypeVariableIdentifier <*> (Syntax.TypeVariableIdentifier . Name.name <$> source) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 8d20d6942..dcb3f7816 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -126,7 +126,7 @@ instance Ord1 Deriving where liftCompare = genericLiftCompare instance Show1 Deriving where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Deriving -newtype Context' a = Context' [a] +newtype Context' a = Context' a deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Context' where liftEq = genericLiftEq @@ -135,7 +135,7 @@ instance Show1 Context' where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Context' -data Class a = Class { classType :: a, classTypeParameters :: a } +data Class a = Class { classContent :: [a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Class where liftEq = genericLiftEq @@ -460,3 +460,12 @@ instance Ord1 VariableSymbol where liftCompare = genericLiftCompare instance Show1 VariableSymbol where liftShowsPrec = genericLiftShowsPrec instance Evaluatable VariableSymbol + +data StandaloneDerivingInstance a = StandaloneDerivingInstance { standaloneDerivingInstanceContext :: [a], standaloneDerivingInstanceClass :: a, standaloneDerivingInstanceInstance :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 StandaloneDerivingInstance where liftEq = genericLiftEq +instance Ord1 StandaloneDerivingInstance where liftCompare = genericLiftCompare +instance Show1 StandaloneDerivingInstance where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable StandaloneDerivingInstance 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 f9f5a0fab..bfa045ad6 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -62,6 +62,10 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -78,12 +82,6 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} @@ -306,12 +304,10 @@ (TypeClassIdentifier))) (Datatype (Context' - (Statements - (Class - { (TypeClassIdentifier) - ->(TypeClassIdentifier) } - (TypeParameters - (TypeVariableIdentifier))))) + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (TypeVariableIdentifier))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -328,18 +324,13 @@ (Class { (TypeClassIdentifier) ->(TypeClassIdentifier) } - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -357,16 +348,13 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (Statements - (TypeVariableIdentifier) - (TypeVariableIdentifier))))) - (Statements + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) (Class { (TypeClassIdentifier) ->(TypeClassIdentifier) } - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -388,8 +376,7 @@ (Empty)) (Constructor (Context' - (Statements - (TypeConstructorIdentifier))) + (TypeConstructorIdentifier)) { (ConstructorIdentifier) ->(ConstructorIdentifier) } (TypeParameters @@ -405,12 +392,10 @@ (Empty)) (Constructor (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - { (TypeVariableIdentifier) - ->(TypeVariableIdentifier) })))) + (Class + (TypeClassIdentifier) + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) (ConstructorIdentifier) (TypeParameters { (TypeVariableIdentifier) @@ -441,12 +426,10 @@ { (TypeVariableIdentifier) ->(TypeVariableIdentifier) }) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - { (TypeVariableIdentifier) - ->(TypeVariableIdentifier) })))) + (Class + (TypeClassIdentifier) + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) (ConstructorIdentifier) (TypeParameters (Statements 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 99276a2b6..3054526c2 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -62,15 +62,6 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} (Constructor { (ConstructorIdentifier) ->(ConstructorIdentifier) } @@ -81,6 +72,15 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} @@ -306,12 +306,10 @@ (TypeClassIdentifier))) (Datatype (Context' - (Statements - (Class - { (TypeClassIdentifier) - ->(TypeClassIdentifier) } - (TypeParameters - (TypeVariableIdentifier))))) + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (TypeVariableIdentifier))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -328,18 +326,13 @@ (Class { (TypeClassIdentifier) ->(TypeClassIdentifier) } - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -357,16 +350,13 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (Statements - (TypeVariableIdentifier) - (TypeVariableIdentifier))))) - (Statements + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) (Class { (TypeClassIdentifier) ->(TypeClassIdentifier) } - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -388,8 +378,7 @@ (Empty)) (Constructor (Context' - (Statements - (TypeConstructorIdentifier))) + (TypeConstructorIdentifier)) { (ConstructorIdentifier) ->(ConstructorIdentifier) } (TypeParameters @@ -405,12 +394,10 @@ (Empty)) (Constructor (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - { (TypeVariableIdentifier) - ->(TypeVariableIdentifier) })))) + (Class + (TypeClassIdentifier) + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) (ConstructorIdentifier) (TypeParameters { (TypeVariableIdentifier) @@ -441,12 +428,10 @@ { (TypeVariableIdentifier) ->(TypeVariableIdentifier) }) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - { (TypeVariableIdentifier) - ->(TypeVariableIdentifier) })))) + (Class + (TypeClassIdentifier) + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) (ConstructorIdentifier) (TypeParameters (Statements diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt index a3022c6c1..c73c9192c 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseA.txt @@ -246,11 +246,9 @@ (TypeClassIdentifier))) (Datatype (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -266,18 +264,13 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -295,15 +288,12 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (Statements - (TypeVariableIdentifier) - (TypeVariableIdentifier))))) - (Statements + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -325,8 +315,7 @@ (Empty)) (Constructor (Context' - (Statements - (TypeConstructorIdentifier))) + (TypeConstructorIdentifier)) (ConstructorIdentifier) (TypeParameters (TypeVariableIdentifier))) @@ -340,11 +329,9 @@ (Empty)) (Constructor (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (ConstructorIdentifier) (TypeParameters (TypeVariableIdentifier))) @@ -371,11 +358,9 @@ (ScopedTypeVariables (TypeVariableIdentifier)) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (ConstructorIdentifier) (TypeParameters (Statements diff --git a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt index a3022c6c1..c73c9192c 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.parseB.txt @@ -246,11 +246,9 @@ (TypeClassIdentifier))) (Datatype (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -266,18 +264,13 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -295,15 +288,12 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (Statements - (TypeVariableIdentifier) - (TypeVariableIdentifier))))) - (Statements + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (Type (TypeConstructorIdentifier) (TypeParameters @@ -325,8 +315,7 @@ (Empty)) (Constructor (Context' - (Statements - (TypeConstructorIdentifier))) + (TypeConstructorIdentifier)) (ConstructorIdentifier) (TypeParameters (TypeVariableIdentifier))) @@ -340,11 +329,9 @@ (Empty)) (Constructor (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (ConstructorIdentifier) (TypeParameters (TypeVariableIdentifier))) @@ -371,11 +358,9 @@ (ScopedTypeVariables (TypeVariableIdentifier)) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (ConstructorIdentifier) (TypeParameters (Statements diff --git a/test/fixtures/haskell/corpus/literals.diffA-B.txt b/test/fixtures/haskell/corpus/literals.diffA-B.txt index 316dd79d5..4f0defa69 100644 --- a/test/fixtures/haskell/corpus/literals.diffA-B.txt +++ b/test/fixtures/haskell/corpus/literals.diffA-B.txt @@ -1,11 +1,10 @@ (Module (ModuleIdentifier) (Statements - (Function - { (VariableIdentifier) - ->(VariableIdentifier) } - (Statements - (Integer))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Integer)+})+})+} {+(Function {+(VariableIdentifier)+} {+(Statements @@ -284,6 +283,10 @@ {-(VariableIdentifier)-} {-(Statements {-(Integer)-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(Integer)-})-})-} {-(Function {-(VariableIdentifier)-} {-(Statements diff --git a/test/fixtures/haskell/corpus/literals.diffB-A.txt b/test/fixtures/haskell/corpus/literals.diffB-A.txt index 9c3428b9d..4f0defa69 100644 --- a/test/fixtures/haskell/corpus/literals.diffB-A.txt +++ b/test/fixtures/haskell/corpus/literals.diffB-A.txt @@ -1,11 +1,10 @@ (Module (ModuleIdentifier) (Statements - (Function - { (VariableIdentifier) - ->(VariableIdentifier) } - (Statements - (Integer))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Integer)+})+})+} {+(Function {+(VariableIdentifier)+} {+(Statements @@ -150,12 +149,10 @@ {+(VariableIdentifier)+} {+(Statements {+(Character)+})+})+} - (Function - { (VariableIdentifier) - ->(VariableIdentifier) } - (Statements - {+(Character)+} - {-(Integer)-})) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Character)+})+})+} {+(Function {+(VariableIdentifier)+} {+(Statements @@ -282,6 +279,14 @@ {-(VariableIdentifier)-} {-(Statements {-(Integer)-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(Integer)-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(Integer)-})-})-} {-(Function {-(VariableIdentifier)-} {-(Statements diff --git a/test/fixtures/haskell/corpus/newtype-declaration.diffA-B.txt b/test/fixtures/haskell/corpus/newtype-declaration.diffA-B.txt index e6eb37bf6..49c3707a2 100644 --- a/test/fixtures/haskell/corpus/newtype-declaration.diffA-B.txt +++ b/test/fixtures/haskell/corpus/newtype-declaration.diffA-B.txt @@ -13,11 +13,9 @@ (Empty)) (NewType (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Statements { (TypeConstructorIdentifier) ->(TypeConstructorIdentifier) }) diff --git a/test/fixtures/haskell/corpus/newtype-declaration.diffB-A.txt b/test/fixtures/haskell/corpus/newtype-declaration.diffB-A.txt index e6eb37bf6..49c3707a2 100644 --- a/test/fixtures/haskell/corpus/newtype-declaration.diffB-A.txt +++ b/test/fixtures/haskell/corpus/newtype-declaration.diffB-A.txt @@ -13,11 +13,9 @@ (Empty)) (NewType (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Statements { (TypeConstructorIdentifier) ->(TypeConstructorIdentifier) }) diff --git a/test/fixtures/haskell/corpus/newtype-declaration.parseA.txt b/test/fixtures/haskell/corpus/newtype-declaration.parseA.txt index 31b758185..91efd1345 100644 --- a/test/fixtures/haskell/corpus/newtype-declaration.parseA.txt +++ b/test/fixtures/haskell/corpus/newtype-declaration.parseA.txt @@ -11,11 +11,9 @@ (Empty)) (NewType (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Statements (TypeConstructorIdentifier)) (Constructor diff --git a/test/fixtures/haskell/corpus/newtype-declaration.parseB.txt b/test/fixtures/haskell/corpus/newtype-declaration.parseB.txt index 31b758185..91efd1345 100644 --- a/test/fixtures/haskell/corpus/newtype-declaration.parseB.txt +++ b/test/fixtures/haskell/corpus/newtype-declaration.parseB.txt @@ -11,11 +11,9 @@ (Empty)) (NewType (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Statements (TypeConstructorIdentifier)) (Constructor diff --git a/test/fixtures/haskell/corpus/standalone-deriving-declaration.A.hs b/test/fixtures/haskell/corpus/standalone-deriving-declaration.A.hs new file mode 100644 index 000000000..cb4233642 --- /dev/null +++ b/test/fixtures/haskell/corpus/standalone-deriving-declaration.A.hs @@ -0,0 +1,4 @@ +deriving instance Eq b => Eq (Bar b) +deriving instance Baz a (m a b c) => Baz a (Bar m a b c) +deriving instance Bar Baz foo => BazFail (BarEval foo bix waz) +deriving instance Bar (Foo (Baz waz)) bix => BazHeap bix (BarEval bix wax) diff --git a/test/fixtures/haskell/corpus/standalone-deriving-declaration.B.hs b/test/fixtures/haskell/corpus/standalone-deriving-declaration.B.hs new file mode 100644 index 000000000..c371c20af --- /dev/null +++ b/test/fixtures/haskell/corpus/standalone-deriving-declaration.B.hs @@ -0,0 +1,4 @@ +deriving instance Eq a => Eq (Foo a) +deriving instance Bar a (m a b c) => Bar a (Baz m a b c) +deriving instance Foo Baz foo => BazFail (FooEval foo bix waz) +deriving instance Far (Boo (Baz waz)) bix => BooHeap bix (FarEval bix wax) diff --git a/test/fixtures/haskell/corpus/standalone-deriving-declaration.diffA-B.txt b/test/fixtures/haskell/corpus/standalone-deriving-declaration.diffA-B.txt new file mode 100644 index 000000000..819ea7306 --- /dev/null +++ b/test/fixtures/haskell/corpus/standalone-deriving-declaration.diffA-B.txt @@ -0,0 +1,72 @@ +(Module + (Empty) + (Statements + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) + (TypeClassIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) + (StandaloneDerivingInstance + (Context' + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (TypeVariableIdentifier) + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (Statements + (TypeVariableIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (StandaloneDerivingInstance + (Context' + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (StandaloneDerivingInstance + (Context' + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeVariableIdentifier))) + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (Statements + (TypeVariableIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier)))))) diff --git a/test/fixtures/haskell/corpus/standalone-deriving-declaration.diffB-A.txt b/test/fixtures/haskell/corpus/standalone-deriving-declaration.diffB-A.txt new file mode 100644 index 000000000..819ea7306 --- /dev/null +++ b/test/fixtures/haskell/corpus/standalone-deriving-declaration.diffB-A.txt @@ -0,0 +1,72 @@ +(Module + (Empty) + (Statements + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) + (TypeClassIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + { (TypeVariableIdentifier) + ->(TypeVariableIdentifier) })) + (StandaloneDerivingInstance + (Context' + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (TypeVariableIdentifier) + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (Statements + (TypeVariableIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (StandaloneDerivingInstance + (Context' + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (StandaloneDerivingInstance + (Context' + (Class + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeVariableIdentifier))) + { (TypeClassIdentifier) + ->(TypeClassIdentifier) } + (Statements + (TypeVariableIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier)))))) diff --git a/test/fixtures/haskell/corpus/standalone-deriving-declaration.parseA.txt b/test/fixtures/haskell/corpus/standalone-deriving-declaration.parseA.txt new file mode 100644 index 000000000..7e560508e --- /dev/null +++ b/test/fixtures/haskell/corpus/standalone-deriving-declaration.parseA.txt @@ -0,0 +1,60 @@ +(Module + (Empty) + (Statements + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier) + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (TypeClassIdentifier) + (Statements + (TypeVariableIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (Statements + (TypeConstructorIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + (TypeVariableIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))))) diff --git a/test/fixtures/haskell/corpus/standalone-deriving-declaration.parseB.txt b/test/fixtures/haskell/corpus/standalone-deriving-declaration.parseB.txt new file mode 100644 index 000000000..7e560508e --- /dev/null +++ b/test/fixtures/haskell/corpus/standalone-deriving-declaration.parseB.txt @@ -0,0 +1,60 @@ +(Module + (Empty) + (Statements + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier) + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (TypeClassIdentifier) + (Statements + (TypeVariableIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (StandaloneDerivingInstance + (Context' + (Class + (TypeClassIdentifier) + (Statements + (TypeConstructorIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier))) + (TypeVariableIdentifier))) + (TypeClassIdentifier) + (Statements + (TypeVariableIdentifier) + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))))) diff --git a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt index 599f1df94..21fb0dd52 100644 --- a/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-signatures.diffA-B.txt @@ -32,11 +32,9 @@ {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} {+(FunctionType {+(Type {+(TypeVariableIdentifier)+} @@ -235,18 +233,16 @@ {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(EqualityConstraint - {+(TypeVariableIdentifier)+} - {+(TypeConstructorIdentifier)+})+})+})+} + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+} {+(TypeVariableIdentifier)+})+} {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(EqualityConstraint - {+(TypeVariableIdentifier)+} - {+(TypeConstructorIdentifier)+})+})+})+} + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+} {+(TypeVariableIdentifier)+})+} {+(TypeSignature {+(VariableIdentifier)+} @@ -258,23 +254,17 @@ {+(Statements {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+} - {+(Statements + {+(TypeVariableIdentifier)+})+} {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+} - {+(Statements + {+(TypeVariableIdentifier)+})+} {+(EqualityConstraint {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+} + {+(TypeVariableIdentifier)+})+} {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+})+} + {+(TypeVariableIdentifier)+})+})+})+})+} {+(FunctionType {+(Type {+(TypeVariableIdentifier)+} @@ -292,35 +282,31 @@ {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(Array - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters - {+(TypeConstructorIdentifier)+})+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+})+} - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeConstructorIdentifier)+})+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeVariableIdentifier)+})+})+} {+(FunctionType {+(Type {+(TypeVariableIdentifier)+} @@ -337,21 +323,18 @@ {+(Statements {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(QuotedName - {+(Array - {+(Type + {+(QuotedName + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters {+(TypeConstructorIdentifier)+} - {+(TypeParameters - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+})+} - {+(Empty)+})+})+})+} - {+(TypeVariableIdentifier)+})+})+})+} - {+(Statements + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+})+})+} + {+(TypeVariableIdentifier)+})+} {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(TypeVariableIdentifier)+})+})+})+} {+(FunctionType {+(Type {+(TypeConstructorIdentifier)+} @@ -396,9 +379,8 @@ {+(Statements {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+} + {+(TypeVariableIdentifier)+} + {+(TypeVariableIdentifier)+})+} {+(ConstructorOperator {+(ConstructorSymbol)+})+} {+(TypeVariableIdentifier)+})+})+} @@ -437,17 +419,13 @@ {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} {-(FunctionType {-(Type {-(TypeVariableIdentifier)-} @@ -646,18 +624,16 @@ {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(EqualityConstraint - {-(TypeVariableIdentifier)-} - {-(TypeConstructorIdentifier)-})-})-})-} + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-} {-(TypeVariableIdentifier)-})-} {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(EqualityConstraint - {-(TypeVariableIdentifier)-} - {-(TypeConstructorIdentifier)-})-})-})-} + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-} {-(TypeVariableIdentifier)-})-} {-(TypeSignature {-(VariableIdentifier)-} @@ -669,23 +645,17 @@ {-(Statements {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-} - {-(Statements + {-(TypeVariableIdentifier)-})-} {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-} - {-(Statements + {-(TypeVariableIdentifier)-})-} {-(EqualityConstraint {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-} + {-(TypeVariableIdentifier)-})-} {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-})-} + {-(TypeVariableIdentifier)-})-})-})-})-} {-(FunctionType {-(Type {-(TypeVariableIdentifier)-} @@ -703,35 +673,31 @@ {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(Array - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters - {-(TypeConstructorIdentifier)-})-} - {-(Empty)-})-} - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters)-} - {-(Empty)-})-} - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters)-} - {-(Empty)-})-} - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters)-} - {-(Empty)-})-})-} - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeConstructorIdentifier)-})-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeVariableIdentifier)-})-})-} {-(FunctionType {-(Type {-(TypeVariableIdentifier)-} @@ -748,21 +714,18 @@ {-(Statements {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(QuotedName - {-(Array - {-(Type + {-(QuotedName + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters {-(TypeConstructorIdentifier)-} - {-(TypeParameters - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-})-} - {-(Empty)-})-})-})-} - {-(TypeVariableIdentifier)-})-})-})-} - {-(Statements + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-})-})-} + {-(TypeVariableIdentifier)-})-} {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(TypeVariableIdentifier)-})-})-})-} {-(FunctionType {-(Type {-(TypeConstructorIdentifier)-} @@ -807,9 +770,8 @@ {-(Statements {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-} + {-(TypeVariableIdentifier)-} + {-(TypeVariableIdentifier)-})-} {-(ConstructorOperator {-(ConstructorSymbol)-})-} {-(TypeVariableIdentifier)-})-})-} diff --git a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt index 40a84d4d5..3a597a43f 100644 --- a/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-signatures.diffB-A.txt @@ -63,17 +63,13 @@ {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} {+(FunctionType {+(Type {+(TypeVariableIdentifier)+} @@ -94,21 +90,28 @@ {+(TypeConstructorIdentifier)+} {+(TypeParameters)+} {+(Empty)+})+})+})+} - {+(TypeSignature - {+(VariableIdentifier)+} - {+(FunctionType - {+(Type - {+(Array + (TypeSignature + { (VariableIdentifier) + ->(VariableIdentifier) } + {-(Context' + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} + (FunctionType + (Type + { (TypeVariableIdentifier) + ->(Array {+(Type {+(TypeConstructorIdentifier)+} {+(TypeParameters)+} - {+(Empty)+})+})+} - {+(TypeParameters)+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+})+})+} + {+(Empty)+})+}) } + (TypeParameters) + (Empty)) + (Type + { (TypeVariableIdentifier) + ->(TypeConstructorIdentifier) } + (TypeParameters) + (Empty)))) {+(TypeSignature {+(VariableIdentifier)+} {+(FunctionType @@ -272,18 +275,16 @@ {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(EqualityConstraint - {+(TypeVariableIdentifier)+} - {+(TypeConstructorIdentifier)+})+})+})+} + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+} {+(TypeVariableIdentifier)+})+} {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(EqualityConstraint - {+(TypeVariableIdentifier)+} - {+(TypeConstructorIdentifier)+})+})+})+} + {+(EqualityConstraint + {+(TypeVariableIdentifier)+} + {+(TypeConstructorIdentifier)+})+})+} {+(TypeVariableIdentifier)+})+} {+(TypeSignature {+(VariableIdentifier)+} @@ -295,23 +296,17 @@ {+(Statements {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+} - {+(Statements + {+(TypeVariableIdentifier)+})+} {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+} - {+(Statements + {+(TypeVariableIdentifier)+})+} {+(EqualityConstraint {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+} + {+(TypeVariableIdentifier)+})+} {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+})+} + {+(TypeVariableIdentifier)+})+})+})+})+} {+(FunctionType {+(Type {+(TypeVariableIdentifier)+} @@ -329,35 +324,31 @@ {+(TypeSignature {+(VariableIdentifier)+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(TypeVariableIdentifier)+})+})+} {+(Context' - {+(Statements - {+(Class - {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(Array - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters - {+(TypeConstructorIdentifier)+})+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+} - {+(Type - {+(TypeConstructorIdentifier)+} - {+(TypeParameters)+} - {+(Empty)+})+})+} - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(Class + {+(TypeClassIdentifier)+} + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters + {+(TypeConstructorIdentifier)+})+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+} + {+(TypeVariableIdentifier)+})+})+} {+(FunctionType {+(Type {+(TypeVariableIdentifier)+} @@ -374,21 +365,18 @@ {+(Statements {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(QuotedName - {+(Array - {+(Type + {+(QuotedName + {+(Array + {+(Type + {+(TypeConstructorIdentifier)+} + {+(TypeParameters {+(TypeConstructorIdentifier)+} - {+(TypeParameters - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+})+} - {+(Empty)+})+})+})+} - {+(TypeVariableIdentifier)+})+})+})+} - {+(Statements + {+(TypeVariableIdentifier)+})+} + {+(Empty)+})+})+})+} + {+(TypeVariableIdentifier)+})+} {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+})+})+})+})+} + {+(TypeVariableIdentifier)+})+})+})+} {+(FunctionType {+(Type {+(TypeConstructorIdentifier)+} @@ -410,30 +398,23 @@ {+(TypeVariableIdentifier)+} {+(TypeConstructorIdentifier)+})+} {+(Empty)+})+})+})+})+} - (TypeSignature - { (VariableIdentifier) - ->(VariableIdentifier) } - (Context' - (Statements + {+(TypeSignature + {+(VariableIdentifier)+} + {+(Context' + {+(Statements {+(TypeVariableIdentifier)+} {+(ConstructorOperator {+(ConstructorSymbol)+})+} + {+(TypeConstructorIdentifier)+})+})+} + {+(FunctionType + {+(Type {+(TypeConstructorIdentifier)+} - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})) - (FunctionType - (Type - { (TypeVariableIdentifier) - ->(TypeConstructorIdentifier) } - (TypeParameters) - (Empty)) - (Type - { (TypeVariableIdentifier) - ->(TypeVariableIdentifier) } - (TypeParameters) - (Empty)))) + {+(TypeParameters)+} + {+(Empty)+})+} + {+(Type + {+(TypeVariableIdentifier)+} + {+(TypeParameters)+} + {+(Empty)+})+})+})+} (TypeSignature { (VariableIdentifier) ->(VariableIdentifier) } @@ -441,9 +422,8 @@ {+(Statements {+(Class {+(TypeClassIdentifier)+} - {+(TypeParameters - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+} + {+(TypeVariableIdentifier)+} + {+(TypeVariableIdentifier)+})+} {+(ConstructorOperator {+(ConstructorSymbol)+})+} {+(TypeVariableIdentifier)+})+})+} @@ -635,18 +615,16 @@ {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(EqualityConstraint - {-(TypeVariableIdentifier)-} - {-(TypeConstructorIdentifier)-})-})-})-} + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-} {-(TypeVariableIdentifier)-})-} {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(EqualityConstraint - {-(TypeVariableIdentifier)-} - {-(TypeConstructorIdentifier)-})-})-})-} + {-(EqualityConstraint + {-(TypeVariableIdentifier)-} + {-(TypeConstructorIdentifier)-})-})-} {-(TypeVariableIdentifier)-})-} {-(TypeSignature {-(VariableIdentifier)-} @@ -658,23 +636,17 @@ {-(Statements {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-} - {-(Statements + {-(TypeVariableIdentifier)-})-} {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-} - {-(Statements + {-(TypeVariableIdentifier)-})-} {-(EqualityConstraint {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-} + {-(TypeVariableIdentifier)-})-} {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-})-} + {-(TypeVariableIdentifier)-})-})-})-})-} {-(FunctionType {-(Type {-(TypeVariableIdentifier)-} @@ -692,35 +664,31 @@ {-(TypeSignature {-(VariableIdentifier)-} {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(TypeVariableIdentifier)-})-})-} {-(Context' - {-(Statements - {-(Class - {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(Array - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters - {-(TypeConstructorIdentifier)-})-} - {-(Empty)-})-} - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters)-} - {-(Empty)-})-} - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters)-} - {-(Empty)-})-} - {-(Type - {-(TypeConstructorIdentifier)-} - {-(TypeParameters)-} - {-(Empty)-})-})-} - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(Class + {-(TypeClassIdentifier)-} + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters + {-(TypeConstructorIdentifier)-})-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-} + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters)-} + {-(Empty)-})-})-} + {-(TypeVariableIdentifier)-})-})-} {-(FunctionType {-(Type {-(TypeVariableIdentifier)-} @@ -737,21 +705,18 @@ {-(Statements {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(QuotedName - {-(Array - {-(Type + {-(QuotedName + {-(Array + {-(Type + {-(TypeConstructorIdentifier)-} + {-(TypeParameters {-(TypeConstructorIdentifier)-} - {-(TypeParameters - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-})-} - {-(Empty)-})-})-})-} - {-(TypeVariableIdentifier)-})-})-})-} - {-(Statements + {-(TypeVariableIdentifier)-})-} + {-(Empty)-})-})-})-} + {-(TypeVariableIdentifier)-})-} {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-})-})-})-})-} + {-(TypeVariableIdentifier)-})-})-})-} {-(FunctionType {-(Type {-(TypeConstructorIdentifier)-} @@ -796,9 +761,8 @@ {-(Statements {-(Class {-(TypeClassIdentifier)-} - {-(TypeParameters - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-} + {-(TypeVariableIdentifier)-} + {-(TypeVariableIdentifier)-})-} {-(ConstructorOperator {-(ConstructorSymbol)-})-} {-(TypeVariableIdentifier)-})-})-} diff --git a/test/fixtures/haskell/corpus/type-signatures.parseA.txt b/test/fixtures/haskell/corpus/type-signatures.parseA.txt index c15a85bda..d7f1176fc 100644 --- a/test/fixtures/haskell/corpus/type-signatures.parseA.txt +++ b/test/fixtures/haskell/corpus/type-signatures.parseA.txt @@ -62,17 +62,13 @@ (TypeSignature (VariableIdentifier) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (FunctionType (Type (TypeVariableIdentifier) @@ -271,18 +267,16 @@ (TypeSignature (VariableIdentifier) (Context' - (Statements - (EqualityConstraint - (TypeVariableIdentifier) - (TypeConstructorIdentifier)))) + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier))) (TypeVariableIdentifier)) (TypeSignature (VariableIdentifier) (Context' - (Statements - (EqualityConstraint - (TypeVariableIdentifier) - (TypeConstructorIdentifier)))) + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier))) (TypeVariableIdentifier)) (TypeSignature (VariableIdentifier) @@ -294,23 +288,17 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (EqualityConstraint (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))) + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))))) + (TypeVariableIdentifier))))) (FunctionType (Type (TypeVariableIdentifier) @@ -328,35 +316,31 @@ (TypeSignature (VariableIdentifier) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (Array - (Type - (TypeConstructorIdentifier) - (TypeParameters - (TypeConstructorIdentifier)) - (Empty)) - (Type - (TypeConstructorIdentifier) - (TypeParameters) - (Empty)) - (Type - (TypeConstructorIdentifier) - (TypeParameters) - (Empty)) - (Type - (TypeConstructorIdentifier) - (TypeParameters) - (Empty))) - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeConstructorIdentifier)) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty))) + (TypeVariableIdentifier))) (FunctionType (Type (TypeVariableIdentifier) @@ -373,21 +357,18 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (QuotedName - (Array - (Type + (QuotedName + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters (TypeConstructorIdentifier) - (TypeParameters - (TypeConstructorIdentifier) - (TypeVariableIdentifier)) - (Empty)))) - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) + (Empty)))) + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (FunctionType (Type (TypeConstructorIdentifier) @@ -432,9 +413,8 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier) - (TypeVariableIdentifier))) + (TypeVariableIdentifier) + (TypeVariableIdentifier)) (ConstructorOperator (ConstructorSymbol)) (TypeVariableIdentifier))) diff --git a/test/fixtures/haskell/corpus/type-signatures.parseB.txt b/test/fixtures/haskell/corpus/type-signatures.parseB.txt index 1ae9563a8..2df1e295a 100644 --- a/test/fixtures/haskell/corpus/type-signatures.parseB.txt +++ b/test/fixtures/haskell/corpus/type-signatures.parseB.txt @@ -31,11 +31,9 @@ (TypeSignature (VariableIdentifier) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (FunctionType (Type (TypeVariableIdentifier) @@ -234,18 +232,16 @@ (TypeSignature (VariableIdentifier) (Context' - (Statements - (EqualityConstraint - (TypeVariableIdentifier) - (TypeConstructorIdentifier)))) + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier))) (TypeVariableIdentifier)) (TypeSignature (VariableIdentifier) (Context' - (Statements - (EqualityConstraint - (TypeVariableIdentifier) - (TypeConstructorIdentifier)))) + (EqualityConstraint + (TypeVariableIdentifier) + (TypeConstructorIdentifier))) (TypeVariableIdentifier)) (TypeSignature (VariableIdentifier) @@ -257,23 +253,17 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) (EqualityConstraint (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))) + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier)))))) + (TypeVariableIdentifier))))) (FunctionType (Type (TypeVariableIdentifier) @@ -291,35 +281,31 @@ (TypeSignature (VariableIdentifier) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (TypeVariableIdentifier))) (Context' - (Statements - (Class - (TypeClassIdentifier) - (TypeParameters - (Array - (Type - (TypeConstructorIdentifier) - (TypeParameters - (TypeConstructorIdentifier)) - (Empty)) - (Type - (TypeConstructorIdentifier) - (TypeParameters) - (Empty)) - (Type - (TypeConstructorIdentifier) - (TypeParameters) - (Empty)) - (Type - (TypeConstructorIdentifier) - (TypeParameters) - (Empty))) - (TypeVariableIdentifier))))) + (Class + (TypeClassIdentifier) + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters + (TypeConstructorIdentifier)) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty)) + (Type + (TypeConstructorIdentifier) + (TypeParameters) + (Empty))) + (TypeVariableIdentifier))) (FunctionType (Type (TypeVariableIdentifier) @@ -336,21 +322,18 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (QuotedName - (Array - (Type + (QuotedName + (Array + (Type + (TypeConstructorIdentifier) + (TypeParameters (TypeConstructorIdentifier) - (TypeParameters - (TypeConstructorIdentifier) - (TypeVariableIdentifier)) - (Empty)))) - (TypeVariableIdentifier)))) - (Statements + (TypeVariableIdentifier)) + (Empty)))) + (TypeVariableIdentifier)) (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier))))) + (TypeVariableIdentifier)))) (FunctionType (Type (TypeConstructorIdentifier) @@ -395,9 +378,8 @@ (Statements (Class (TypeClassIdentifier) - (TypeParameters - (TypeVariableIdentifier) - (TypeVariableIdentifier))) + (TypeVariableIdentifier) + (TypeVariableIdentifier)) (ConstructorOperator (ConstructorSymbol)) (TypeVariableIdentifier))) diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt index 11e9f58b4..4fff50387 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt @@ -52,17 +52,17 @@ (TypeConstructorIdentifier)) (TypePattern (TupleConstructor))) + (TypeSynonym + (Statements + (TypeConstructorIdentifier)) + (TypePattern + { (FunctionConstructor) + ->(TupleConstructor) })) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+})+} {+(TypePattern - {+(TupleConstructor)+})+})+} - (TypeSynonym - (Statements - { (TypeConstructorIdentifier) - ->(TypeConstructorIdentifier) }) - (TypePattern - (FunctionConstructor))) + {+(FunctionConstructor)+})+})+} (TypeSynonym (Statements (TypeConstructorIdentifier)) @@ -126,111 +126,65 @@ (TypeConstructorIdentifier) (TypeVariableIdentifier))) (Empty)))))) - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeConstructorIdentifier)+})+} - {+(TextElement)+})+} - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+} - {+(TypePattern - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+})+} - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+})+} - {+(Context' - {+(Statements - {+(TypeConstructorIdentifier)+})+})+} - {+(TypePattern - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(ListConstructor)+})+})+})+} - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+} - {+(ScopedTypeVariables - {+(Statements - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+} - {+(TypePattern - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+})+} - {+(TypeSynonym - {+(Statements - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+} - {+(TypePattern - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeVariableIdentifier)+} - {+(TypeVariableIdentifier)+})+})+})+})+} - {-(TypeSynonym - {-(Statements + (TypeSynonym + (Statements {-(TypeConstructorIdentifier)-} - {-(TypeConstructorIdentifier)-})-} - {-(TextElement)-})-} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-} - {-(TypePattern - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-})-} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-})-} - {-(Context' - {-(Statements - {-(TypeConstructorIdentifier)-})-})-} - {-(TypePattern - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(ListConstructor)-})-})-})-} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-} - {-(ScopedTypeVariables - {-(Statements - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-} - {-(TypePattern - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-})-} - {-(TypeSynonym - {-(Statements - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-} - {-(TypePattern - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(Statements - {-(TypeConstructorIdentifier)-} - {-(TypeVariableIdentifier)-} - {-(TypeVariableIdentifier)-})-})-})-})-})) + (TypeConstructorIdentifier) + {+(TypeConstructorIdentifier)+}) + (TextElement)) + (TypeSynonym + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (TypePattern + (Statements + (TypeConstructorIdentifier) + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (TypeSynonym + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) }) + (Context' + (TypeConstructorIdentifier)) + (TypePattern + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (ListConstructor)))) + (TypeSynonym + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier)) + (ScopedTypeVariables + (Statements + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (TypePattern + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier)))) + (TypeSynonym + (Statements + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier))) + (TypePattern + (Statements + (TypeConstructorIdentifier) + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + (TypeVariableIdentifier) + (TypeVariableIdentifier))))))) diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt index 2861353eb..d03474db8 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt @@ -52,11 +52,12 @@ (TypeConstructorIdentifier)) (TypePattern (TupleConstructor))) - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+})+} - {+(TypePattern - {+(FunctionConstructor)+})+})+} + (TypeSynonym + (Statements + (TypeConstructorIdentifier)) + (TypePattern + { (TupleConstructor) + ->(FunctionConstructor) })) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+})+} @@ -120,7 +121,7 @@ ->(TypeConstructorIdentifier) } {+(TypeConstructorIdentifier)+}) { (TypePattern - {-(TupleConstructor)-}) + {-(FunctionConstructor)-}) ->(TextElement) }) {+(TypeSynonym {+(Statements @@ -138,8 +139,7 @@ {+(Statements {+(TypeConstructorIdentifier)+})+} {+(Context' - {+(Statements - {+(TypeConstructorIdentifier)+})+})+} + {+(TypeConstructorIdentifier)+})+} {+(TypePattern {+(Statements {+(TypeConstructorIdentifier)+} @@ -171,11 +171,6 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+} {+(TypeVariableIdentifier)+})+})+})+})+} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-})-} - {-(TypePattern - {-(FunctionConstructor)-})-})-} {-(TypeSynonym {-(Statements {-(TypeConstructorIdentifier)-})-} @@ -254,8 +249,7 @@ {-(Statements {-(TypeConstructorIdentifier)-})-} {-(Context' - {-(Statements - {-(TypeConstructorIdentifier)-})-})-} + {-(TypeConstructorIdentifier)-})-} {-(TypePattern {-(Statements {-(TypeConstructorIdentifier)-} diff --git a/test/fixtures/haskell/corpus/type-synonyms.parseA.txt b/test/fixtures/haskell/corpus/type-synonyms.parseA.txt index 02c4c5d07..25807ecdf 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.parseA.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.parseA.txt @@ -128,8 +128,7 @@ (Statements (TypeConstructorIdentifier)) (Context' - (Statements - (TypeConstructorIdentifier))) + (TypeConstructorIdentifier)) (TypePattern (Statements (TypeConstructorIdentifier) diff --git a/test/fixtures/haskell/corpus/type-synonyms.parseB.txt b/test/fixtures/haskell/corpus/type-synonyms.parseB.txt index 1188f81e4..804a2b607 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.parseB.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.parseB.txt @@ -130,8 +130,7 @@ (Statements (TypeConstructorIdentifier)) (Context' - (Statements - (TypeConstructorIdentifier))) + (TypeConstructorIdentifier)) (TypePattern (Statements (TypeConstructorIdentifier) From 9317972ca2c5aaf16cd9281e019a9a8c61251ac9 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Fri, 8 Jun 2018 17:18:39 -0700 Subject: [PATCH 03/23] Assign import declarations (not hidden) --- src/Language/Haskell/Assignment.hs | 52 ++- src/Language/Haskell/Syntax.hs | 54 +++ ...lgebraic-datatype-declarations.diffA-B.txt | 8 +- ...lgebraic-datatype-declarations.diffB-A.txt | 18 +- .../haskell/corpus/import-declaration.A.hs | 27 ++ .../haskell/corpus/import-declaration.B.hs | 27 ++ .../corpus/import-declaration.diffA-B.txt | 321 ++++++++++++++++++ .../corpus/import-declaration.diffB-A.txt | 321 ++++++++++++++++++ .../corpus/import-declaration.parseA.txt | 151 ++++++++ .../corpus/import-declaration.parseB.txt | 173 ++++++++++ 10 files changed, 1138 insertions(+), 14 deletions(-) create mode 100644 test/fixtures/haskell/corpus/import-declaration.A.hs create mode 100644 test/fixtures/haskell/corpus/import-declaration.B.hs create mode 100644 test/fixtures/haskell/corpus/import-declaration.diffA-B.txt create mode 100644 test/fixtures/haskell/corpus/import-declaration.diffB-A.txt create mode 100644 test/fixtures/haskell/corpus/import-declaration.parseA.txt create mode 100644 test/fixtures/haskell/corpus/import-declaration.parseB.txt diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index fe38e228a..b4235e328 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -54,7 +54,11 @@ type Syntax = '[ , Syntax.FunctionType , Syntax.GADT , Syntax.GADTConstructor + , Syntax.HiddenImport , Syntax.Identifier + , Syntax.Import + , Syntax.ImportAlias + , Syntax.ImportDeclaration , Syntax.InfixOperatorPattern , Syntax.Kind , Syntax.KindFunctionType @@ -67,6 +71,8 @@ type Syntax = '[ , Syntax.NewType , Syntax.Pragma , Syntax.PrimitiveConstructorIdentifier + , Syntax.PrimitiveVariableIdentifier + , Syntax.QualifiedImportDeclaration , Syntax.QualifiedModuleIdentifier , Syntax.QualifiedTypeConstructorIdentifier , Syntax.QuotedName @@ -187,6 +193,8 @@ expressionChoices = [ , functionType , gadtConstructor , gadtDeclaration + , importAlias + , importDeclaration , infixOperatorPattern , integer , kind @@ -201,6 +209,8 @@ expressionChoices = [ , parenthesizedTypePattern , pragma , primitiveConstructorIdentifier + , primitiveVariableIdentifier + , qualifiedImportDeclaration , qualifiedModuleIdentifier , qualifiedTypeConstructorIdentifier , quotedName @@ -281,6 +291,29 @@ gadtDeclaration = makeTerm where typeParameters' = makeTerm <$> location <*> manyTermsTill expression (symbol KindSignature <|> symbol Where') +hiddenImport :: Assignment +hiddenImport = makeTerm <$> symbol HiddenImport <*> children (Syntax.HiddenImport <$> expressions) + +hiddenImportSpec :: Assignment.Assignment [] Grammar [Term] +hiddenImportSpec = symbol HiddenImportSpec *> children (manyTerm hiddenImport) + +import' :: Assignment +import' = makeTerm <$> symbol Import <*> children (Syntax.Import <$> expressions) + +importAlias :: Assignment +importAlias = makeTerm <$> symbol ImportAlias <*> children (Syntax.ImportAlias <$> expression <*> expression) + +importDeclaration :: Assignment +importDeclaration = makeTerm + <$> symbol ImportDeclaration + <*> children (Syntax.ImportDeclaration + <$> (packageQualifiedImport <|> emptyTerm) + <*> expression + <*> (importSpec <|> hiddenImportSpec <|> pure [])) + +importSpec :: Assignment.Assignment [] Grammar [Term] +importSpec = symbol ImportSpec *> children (manyTerm import') + infixOperatorPattern :: Assignment infixOperatorPattern = makeTerm <$> symbol InfixOperatorPattern <*> children (Syntax.InfixOperatorPattern <$> expression <*> operator <*> expression) @@ -318,7 +351,10 @@ listType = makeTerm <$> symbol ListType <*> children (Literal.Array <$> manyTerm module' :: Assignment module' = makeTerm <$> symbol Module - <*> children (Syntax.Module <$> (term moduleIdentifier <|> emptyTerm) <*> moduleExports <*> (where' <|> expressions <|> emptyTerm)) + <*> children (Syntax.Module + <$> (term moduleIdentifier <|> emptyTerm) + <*> moduleExports + <*> (where' <|> expressions <|> emptyTerm)) where moduleExports = symbol ModuleExports *> children (manyTerm export) <|> pure [] @@ -340,6 +376,9 @@ newType = makeTerm <$> symbol NewtypeDeclaration <*> children (Syntax.NewType <$ operator :: Assignment operator = typeOperator <|> constructorOperator <|> variableOperator +packageQualifiedImport :: Assignment +packageQualifiedImport = makeTerm <$> symbol PackageQualifiedImport <*> (Literal.TextElement <$> source) + parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children expressions @@ -349,6 +388,17 @@ pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) primitiveConstructorIdentifier :: Assignment primitiveConstructorIdentifier = makeTerm <$> symbol PrimitiveConstructorIdentifier <*> (Syntax.PrimitiveConstructorIdentifier . Name.name <$> source) +primitiveVariableIdentifier :: Assignment +primitiveVariableIdentifier = makeTerm <$> symbol PrimitiveVariableIdentifier <*> (Syntax.PrimitiveVariableIdentifier . Name.name <$> source) + +qualifiedImportDeclaration :: Assignment +qualifiedImportDeclaration = makeTerm + <$> symbol QualifiedImportDeclaration + <*> children (Syntax.QualifiedImportDeclaration + <$> (packageQualifiedImport <|> emptyTerm) + <*> expression + <*> (importSpec <|> hiddenImportSpec <|> pure [])) + qualifiedModuleIdentifier :: Assignment qualifiedModuleIdentifier = makeTerm <$> symbol QualifiedModuleIdentifier <*> children (Syntax.QualifiedModuleIdentifier <$> someTerm' expression) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index dcb3f7816..254082545 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -434,6 +434,15 @@ instance Show1 PrimitiveConstructorIdentifier where liftShowsPrec = genericLiftS instance Evaluatable PrimitiveConstructorIdentifier +newtype PrimitiveVariableIdentifier a = PrimitiveVariableIdentifier { primitiveVariableIdentifierName :: Name } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 PrimitiveVariableIdentifier where liftEq = genericLiftEq +instance Ord1 PrimitiveVariableIdentifier where liftCompare = genericLiftCompare +instance Show1 PrimitiveVariableIdentifier where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable PrimitiveVariableIdentifier + newtype ConstructorSymbol a = ConstructorSymbol { constructorSymbolName :: Name } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) @@ -469,3 +478,48 @@ instance Ord1 StandaloneDerivingInstance where liftCompare = genericLiftCompare instance Show1 StandaloneDerivingInstance where liftShowsPrec = genericLiftShowsPrec instance Evaluatable StandaloneDerivingInstance + +data ImportDeclaration a = ImportDeclaration { importPackageQualifiedContent :: a, importModule :: a, importSpec :: [a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ImportDeclaration where liftEq = genericLiftEq +instance Ord1 ImportDeclaration where liftCompare = genericLiftCompare +instance Show1 ImportDeclaration where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ImportDeclaration + +data QualifiedImportDeclaration a = QualifiedImportDeclaration { qualifiedImportPackageQualifiedContent :: a, qualifiedImportModule :: a, qualifiedImportSpec :: [a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 QualifiedImportDeclaration where liftEq = genericLiftEq +instance Ord1 QualifiedImportDeclaration where liftCompare = genericLiftCompare +instance Show1 QualifiedImportDeclaration where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable QualifiedImportDeclaration + +newtype Import a = Import { importContent :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Import where liftEq = genericLiftEq +instance Ord1 Import where liftCompare = genericLiftCompare +instance Show1 Import where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Import + +newtype HiddenImport a = HiddenImport { hiddenimportContent :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 HiddenImport where liftEq = genericLiftEq +instance Ord1 HiddenImport where liftCompare = genericLiftCompare +instance Show1 HiddenImport where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable HiddenImport + +data ImportAlias a = ImportAlias { importAliasSource :: a, importAliasName :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ImportAlias where liftEq = genericLiftEq +instance Ord1 ImportAlias where liftCompare = genericLiftCompare +instance Show1 ImportAlias where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ImportAlias 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 bfa045ad6..9096dc967 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -62,10 +62,6 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -79,6 +75,10 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} 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 3054526c2..4c7b58dc6 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -62,6 +62,15 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} (Constructor { (ConstructorIdentifier) ->(ConstructorIdentifier) } @@ -72,15 +81,6 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/import-declaration.A.hs b/test/fixtures/haskell/corpus/import-declaration.A.hs new file mode 100644 index 000000000..287f1744d --- /dev/null +++ b/test/fixtures/haskell/corpus/import-declaration.A.hs @@ -0,0 +1,27 @@ +module A where + +import Maybe +import Either() +import Data.Maybe (Maybe(..)) +import Data.Aeson ((.:)) +import Control.Comonad.Cofree ((:<)) +import Data.Maybe (fromMaybe, fromJust) +import Data.Maybe (Maybe(..), fromMaybe, fromJust) + +import qualified Data.Maybe +import qualified Either () +import qualified Data.Function (fix) + +import Data.Maybe as DM (Maybe(..)) + +import qualified Data.Maybe as DM +import qualified Either as E () +import qualified Data.Aeson as JSON +import qualified Data.Aeson as D.A + +import Data.Maybe as DM (Maybe(..), fromMaybe) +import qualified Data.Maybe as M (Maybe(..), fromMaybe) + +import GHC.Prim (Proxy#, proxy#) + +import "hint" HLint.Default diff --git a/test/fixtures/haskell/corpus/import-declaration.B.hs b/test/fixtures/haskell/corpus/import-declaration.B.hs new file mode 100644 index 000000000..fd430982c --- /dev/null +++ b/test/fixtures/haskell/corpus/import-declaration.B.hs @@ -0,0 +1,27 @@ +module A where + +import Data.Maybe +import Data.Either() +import Data.Util.Maybe (Maybe(..)) +import Data.Util.Aeson ((.:)) +import Control.Util.Comonad.Cofree ((:<)) +import Data.Util.Maybe (fromMaybe, fromJust) +import Data.Util.Maybe (Maybe(..), fromJust, fromMaybe) + +import qualified Data.Util.Maybe +import qualified Data.Either () +import qualified Data.Util.Function (fix) + +import Data.Util.Maybe as DM (Maybe(..)) + +import qualified Data.Util.Maybe as DM +import qualified Data.Either as E () +import qualified Data.Util.Aeson as JSON +import qualified Data.Util.Aeson as D.A + +import Data.Util.Maybe as DM (Maybe(..), fromMaybe) +import qualified Data.Util.Maybe as UM (Maybe(..), fromMaybe) + +import GHC.Prim (Box#, box#) + +import "hlint" HLint.Util.Default diff --git a/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt b/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt new file mode 100644 index 000000000..108e6b31e --- /dev/null +++ b/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt @@ -0,0 +1,321 @@ +(Module + (ModuleIdentifier) + (Statements + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(VariableOperator + {+(VariableSymbol)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(ConstructorOperator + {+(ConstructorSymbol)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(Import + {+(VariableIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(PrimitiveConstructorIdentifier)+})+} + {+(Import + {+(PrimitiveVariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(TextElement)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {-(ImportDeclaration + {-(Empty)-} + {-(ModuleIdentifier)-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(ModuleIdentifier)-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(VariableOperator + {-(VariableSymbol)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(ConstructorOperator + {-(ConstructorSymbol)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(Import + {-(VariableIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ModuleIdentifier)-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(PrimitiveConstructorIdentifier)-})-} + {-(Import + {-(PrimitiveVariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(TextElement)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-})) diff --git a/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt b/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt new file mode 100644 index 000000000..d84a34dbe --- /dev/null +++ b/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt @@ -0,0 +1,321 @@ +(Module + (ModuleIdentifier) + (Statements + {+(ImportDeclaration + {+(Empty)+} + {+(ModuleIdentifier)+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(ModuleIdentifier)+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(VariableOperator + {+(VariableSymbol)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(ConstructorOperator + {+(ConstructorSymbol)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(Import + {+(VariableIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ModuleIdentifier)+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(Import + {+(VariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(Import + {+(PrimitiveConstructorIdentifier)+})+} + {+(Import + {+(PrimitiveVariableIdentifier)+})+})+} + {+(ImportDeclaration + {+(TextElement)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(VariableOperator + {-(VariableSymbol)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(ConstructorOperator + {-(ConstructorSymbol)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(Import + {-(VariableIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(Import + {-(VariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(Import + {-(PrimitiveConstructorIdentifier)-})-} + {-(Import + {-(PrimitiveVariableIdentifier)-})-})-} + {-(ImportDeclaration + {-(TextElement)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-})) diff --git a/test/fixtures/haskell/corpus/import-declaration.parseA.txt b/test/fixtures/haskell/corpus/import-declaration.parseA.txt new file mode 100644 index 000000000..3116b16e2 --- /dev/null +++ b/test/fixtures/haskell/corpus/import-declaration.parseA.txt @@ -0,0 +1,151 @@ +(Module + (ModuleIdentifier) + (Statements + (ImportDeclaration + (Empty) + (ModuleIdentifier)) + (ImportDeclaration + (Empty) + (ModuleIdentifier)) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors)))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (VariableOperator + (VariableSymbol)))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (ConstructorOperator + (ConstructorSymbol)))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (VariableIdentifier)) + (Import + (VariableIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (Import + (VariableIdentifier)) + (Import + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ModuleIdentifier)) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (VariableIdentifier))) + (ImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors)))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (ModuleIdentifier) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)))) + (ImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (Import + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (Import + (VariableIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (PrimitiveConstructorIdentifier)) + (Import + (PrimitiveVariableIdentifier))) + (ImportDeclaration + (TextElement) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier))))) diff --git a/test/fixtures/haskell/corpus/import-declaration.parseB.txt b/test/fixtures/haskell/corpus/import-declaration.parseB.txt new file mode 100644 index 000000000..46fe560da --- /dev/null +++ b/test/fixtures/haskell/corpus/import-declaration.parseB.txt @@ -0,0 +1,173 @@ +(Module + (ModuleIdentifier) + (Statements + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors)))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (VariableOperator + (VariableSymbol)))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (ConstructorOperator + (ConstructorSymbol)))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (VariableIdentifier)) + (Import + (VariableIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (Import + (VariableIdentifier)) + (Import + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (VariableIdentifier))) + (ImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors)))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)))) + (ImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (Import + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (Import + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (Import + (VariableIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (Import + (PrimitiveConstructorIdentifier)) + (Import + (PrimitiveVariableIdentifier))) + (ImportDeclaration + (TextElement) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier))))) From 336cf2d4f3d6859b0b7036ba64604dfe4e7e523e Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Mon, 11 Jun 2018 15:04:04 -0700 Subject: [PATCH 04/23] Bump haskell-tree-sitter --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index d21ac9e3c..0b065125c 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit d21ac9e3c2730cf785ecee31b3c152cfff559dd2 +Subproject commit 0b065125cc1318a3daa65dc26819d3be97286688 From 36f80acba13880352a9c34daecf5af51e528fb94 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Mon, 11 Jun 2018 15:22:51 -0700 Subject: [PATCH 05/23] Update hidden imports and add fixtures --- src/Language/Haskell/Assignment.hs | 2 +- .../haskell/corpus/import-declaration.A.hs | 7 ++ .../haskell/corpus/import-declaration.B.hs | 7 ++ .../corpus/import-declaration.diffA-B.txt | 93 ++++++++++++++++++- .../corpus/import-declaration.diffB-A.txt | 93 ++++++++++++++++++- .../corpus/import-declaration.parseA.txt | 45 ++++++++- .../corpus/import-declaration.parseB.txt | 50 +++++++++- 7 files changed, 292 insertions(+), 5 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 5022631fe..1b0fb49af 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -283,7 +283,7 @@ gadtDeclaration = makeTerm typeParameters' = makeTerm <$> location <*> manyTermsTill expression (symbol KindSignature <|> symbol Where') hiddenImport :: Assignment -hiddenImport = makeTerm <$> symbol HiddenImport <*> children (Syntax.HiddenImport <$> expressions) +hiddenImport = makeTerm <$> symbol Import <*> children (Syntax.HiddenImport <$> expressions) hiddenImportSpec :: Assignment.Assignment [] Grammar [Term] hiddenImportSpec = symbol HiddenImportSpec *> children (manyTerm hiddenImport) diff --git a/test/fixtures/haskell/corpus/import-declaration.A.hs b/test/fixtures/haskell/corpus/import-declaration.A.hs index 287f1744d..69a77ad89 100644 --- a/test/fixtures/haskell/corpus/import-declaration.A.hs +++ b/test/fixtures/haskell/corpus/import-declaration.A.hs @@ -25,3 +25,10 @@ import qualified Data.Maybe as M (Maybe(..), fromMaybe) import GHC.Prim (Proxy#, proxy#) import "hint" HLint.Default + +import Data.Maybe hiding (Maybe(..), fromMaybe) + +import qualified Data.Maybe hiding () +import qualified Data.Either hiding (Either(..), decodeEither) +import qualified Data.Function hiding (fix) +import qualified Data.List as DL hiding (head) diff --git a/test/fixtures/haskell/corpus/import-declaration.B.hs b/test/fixtures/haskell/corpus/import-declaration.B.hs index fd430982c..2049f6c69 100644 --- a/test/fixtures/haskell/corpus/import-declaration.B.hs +++ b/test/fixtures/haskell/corpus/import-declaration.B.hs @@ -25,3 +25,10 @@ import qualified Data.Util.Maybe as UM (Maybe(..), fromMaybe) import GHC.Prim (Box#, box#) import "hlint" HLint.Util.Default + +import Data.Util.Maybe hiding (Maybe(..), fromMaybe) + +import qualified Data.Util.Maybe hiding () +import qualified Data.Util.Either hiding (Either(..), decodeEither) +import qualified Data.Util.Function hiding (fix) +import qualified Data.Util.List as DL hiding (head) diff --git a/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt b/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt index 108e6b31e..bae5ac4a0 100644 --- a/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt +++ b/test/fixtures/haskell/corpus/import-declaration.diffA-B.txt @@ -171,6 +171,54 @@ {+(ModuleIdentifier)+} {+(ModuleIdentifier)+} {+(ModuleIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} {-(ImportDeclaration {-(Empty)-} {-(ModuleIdentifier)-})-} @@ -318,4 +366,47 @@ {-(TextElement)-} {-(QualifiedModuleIdentifier {-(ModuleIdentifier)-} - {-(ModuleIdentifier)-})-})-})) + {-(ModuleIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-})) diff --git a/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt b/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt index d84a34dbe..2396c65c3 100644 --- a/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt +++ b/test/fixtures/haskell/corpus/import-declaration.diffB-A.txt @@ -149,6 +149,49 @@ {+(QualifiedModuleIdentifier {+(ModuleIdentifier)+} {+(ModuleIdentifier)+})+})+} + {+(ImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(AllConstructors)+})+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} + {+(QualifiedImportDeclaration + {+(Empty)+} + {+(ImportAlias + {+(QualifiedModuleIdentifier + {+(ModuleIdentifier)+} + {+(ModuleIdentifier)+})+} + {+(ModuleIdentifier)+})+} + {+(HiddenImport + {+(VariableIdentifier)+})+})+} {-(ImportDeclaration {-(Empty)-} {-(QualifiedModuleIdentifier @@ -318,4 +361,52 @@ {-(QualifiedModuleIdentifier {-(ModuleIdentifier)-} {-(ModuleIdentifier)-} - {-(ModuleIdentifier)-})-})-})) + {-(ModuleIdentifier)-})-})-} + {-(ImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(Statements + {-(TypeConstructorIdentifier)-} + {-(AllConstructors)-})-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-} + {-(QualifiedImportDeclaration + {-(Empty)-} + {-(ImportAlias + {-(QualifiedModuleIdentifier + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-} + {-(ModuleIdentifier)-})-} + {-(ModuleIdentifier)-})-} + {-(HiddenImport + {-(VariableIdentifier)-})-})-})) diff --git a/test/fixtures/haskell/corpus/import-declaration.parseA.txt b/test/fixtures/haskell/corpus/import-declaration.parseA.txt index 3116b16e2..b7cfc8467 100644 --- a/test/fixtures/haskell/corpus/import-declaration.parseA.txt +++ b/test/fixtures/haskell/corpus/import-declaration.parseA.txt @@ -148,4 +148,47 @@ (TextElement) (QualifiedModuleIdentifier (ModuleIdentifier) - (ModuleIdentifier))))) + (ModuleIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (HiddenImport + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (HiddenImport + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (HiddenImport + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (HiddenImport + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (HiddenImport + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (HiddenImport + (VariableIdentifier))))) diff --git a/test/fixtures/haskell/corpus/import-declaration.parseB.txt b/test/fixtures/haskell/corpus/import-declaration.parseB.txt index 46fe560da..b42341119 100644 --- a/test/fixtures/haskell/corpus/import-declaration.parseB.txt +++ b/test/fixtures/haskell/corpus/import-declaration.parseB.txt @@ -170,4 +170,52 @@ (QualifiedModuleIdentifier (ModuleIdentifier) (ModuleIdentifier) - (ModuleIdentifier))))) + (ModuleIdentifier))) + (ImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (HiddenImport + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (HiddenImport + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (HiddenImport + (Statements + (TypeConstructorIdentifier) + (AllConstructors))) + (HiddenImport + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (HiddenImport + (VariableIdentifier))) + (QualifiedImportDeclaration + (Empty) + (ImportAlias + (QualifiedModuleIdentifier + (ModuleIdentifier) + (ModuleIdentifier) + (ModuleIdentifier)) + (ModuleIdentifier)) + (HiddenImport + (VariableIdentifier))))) From b1c1a2526730f3682fe01ec4c9f0b19e6c74d0cf Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Mon, 11 Jun 2018 15:54:01 -0700 Subject: [PATCH 06/23] Assign list comprehensions, generators, tuple patterns --- src/Language/Haskell/Assignment.hs | 33 +++++ src/Language/Haskell/Syntax.hs | 45 +++++++ ...lgebraic-datatype-declarations.diffA-B.txt | 10 +- ...lgebraic-datatype-declarations.diffB-A.txt | 10 +- test/fixtures/haskell/corpus/expressions.A.hs | 12 ++ test/fixtures/haskell/corpus/expressions.B.hs | 12 ++ .../haskell/corpus/expressions.diffA-B.txt | 120 ++++++++++++++++++ .../haskell/corpus/expressions.diffB-A.txt | 120 ++++++++++++++++++ .../haskell/corpus/expressions.parseA.txt | 101 +++++++++++++++ .../haskell/corpus/expressions.parseB.txt | 101 +++++++++++++++ .../haskell/corpus/literals.diffB-A.txt | 14 +- .../haskell/corpus/type-synonyms.diffB-A.txt | 18 +-- 12 files changed, 572 insertions(+), 24 deletions(-) create mode 100644 test/fixtures/haskell/corpus/expressions.A.hs create mode 100644 test/fixtures/haskell/corpus/expressions.B.hs create mode 100644 test/fixtures/haskell/corpus/expressions.diffA-B.txt create mode 100644 test/fixtures/haskell/corpus/expressions.diffB-A.txt create mode 100644 test/fixtures/haskell/corpus/expressions.parseA.txt create mode 100644 test/fixtures/haskell/corpus/expressions.parseB.txt diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 1b0fb49af..df8d5503e 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -37,6 +37,7 @@ type Syntax = '[ , Literal.Tuple , Syntax.AllConstructors , Syntax.AnnotatedTypeVariable + , Syntax.App , Syntax.Class , Syntax.ConstructorSymbol , Syntax.Context @@ -53,6 +54,7 @@ type Syntax = '[ , Syntax.FunctionType , Syntax.GADT , Syntax.GADTConstructor + , Syntax.Generator , Syntax.HiddenImport , Syntax.Identifier , Syntax.Import @@ -63,6 +65,7 @@ type Syntax = '[ , Syntax.KindFunctionType , Syntax.KindListType , Syntax.KindSignature + , Syntax.ListComprehension , Syntax.ListConstructor , Syntax.Module , Syntax.ModuleExport @@ -79,7 +82,9 @@ type Syntax = '[ , Syntax.Star , Syntax.StrictType , Syntax.StrictTypeVariable + , Syntax.Tuple , Syntax.TupleConstructor + , Syntax.TuplePattern , Syntax.Type , Syntax.TypeConstructorExport , Syntax.TypePattern @@ -114,6 +119,9 @@ allConstructors = makeTerm <$> token AllConstructors <*> pure Syntax.AllConstruc annotatedTypeVariable :: Assignment annotatedTypeVariable = makeTerm <$> symbol AnnotatedTypeVariable <*> children (Syntax.AnnotatedTypeVariable <$> typeVariableIdentifier <* token Annotation <*> (kind <|> type')) +app :: Assignment +app = makeTerm <$> symbol FunctionApplication <*> children (Syntax.App <$> expression <*> expression) + character :: Assignment character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) @@ -157,6 +165,9 @@ equalityConstraint = makeTerm <$> symbol EqualityConstraint <*> children (Syntax export :: Assignment export = makeTerm <$> symbol Export <*> children (Syntax.Export <$> expressions) +expression' :: Assignment +expression' = symbol Expression *> children (expression) + expressions :: Assignment expressions = makeTerm'' <$> location <*> manyTerm expression @@ -168,6 +179,7 @@ expressionChoices = [ algebraicDatatypeDeclaration , allConstructors , annotatedTypeVariable + , app , character , comment , context' @@ -178,12 +190,14 @@ expressionChoices = [ , defaultDeclaration , derivingClause , equalityConstraint + , expression' , float , functionConstructor , functionDeclaration , functionType , gadtConstructor , gadtDeclaration + , generator , importAlias , importDeclaration , infixOperatorPattern @@ -191,6 +205,7 @@ expressionChoices = [ , kind , kindSignature , listConstructor + , listComprehension , listExpression , listType , moduleExport @@ -198,6 +213,7 @@ expressionChoices = [ , newType , operator , parenthesizedTypePattern + , pattern , pragma , primitiveConstructorIdentifier , primitiveVariableIdentifier @@ -210,6 +226,8 @@ expressionChoices = [ , star , strictType , string + , tuple + , tuplePattern , tupleType , type' , type'' @@ -282,6 +300,9 @@ gadtDeclaration = makeTerm where typeParameters' = makeTerm <$> location <*> manyTermsTill expression (symbol KindSignature <|> symbol Where') +generator :: Assignment +generator = makeTerm <$> symbol Generator <*> children (Syntax.Generator <$> expression <*> expression) + hiddenImport :: Assignment hiddenImport = makeTerm <$> symbol Import <*> children (Syntax.HiddenImport <$> expressions) @@ -329,6 +350,9 @@ kindListType = makeTerm <$> symbol KindListType <*> children (Syntax.KindListTyp kindSignature :: Assignment kindSignature = makeTerm <$> symbol KindSignature <*> children (Syntax.KindSignature <$ token Annotation <*> kind) +listComprehension :: Assignment +listComprehension = makeTerm <$> symbol ListComprehension <*> children (Syntax.ListComprehension <$> expression <*> manyTerm expression) + listConstructor :: Assignment listConstructor = makeTerm <$> token ListConstructor <*> pure Syntax.ListConstructor @@ -373,6 +397,9 @@ packageQualifiedImport = makeTerm <$> symbol PackageQualifiedImport <*> (Literal parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children expressions +pattern :: Assignment +pattern = symbol Pattern *> children (expression) + pragma :: Assignment pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) @@ -419,6 +446,9 @@ strictType = makeTerm' string :: Assignment string = makeTerm <$> symbol String <*> (Literal.TextElement <$> source) +tuplePattern :: Assignment +tuplePattern = makeTerm <$> symbol TuplePattern <*> children (Syntax.TuplePattern <$> manyTerm expression) + tupleType :: Assignment tupleType = makeTerm <$> symbol TupleType <*> children (Literal.Tuple <$> manyTerm type') @@ -440,6 +470,9 @@ typeSignature = makeTerm <$> symbol TypeSignature <*> children (Syntax.TypeSigna typeVariableIdentifier :: Assignment typeVariableIdentifier = makeTerm <$> symbol TypeVariableIdentifier <*> (Syntax.TypeVariableIdentifier . Name.name <$> source) +tuple :: Assignment +tuple = makeTerm <$> symbol TupleExpression <*> children (Syntax.Tuple <$> manyTerm expression) + 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. diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index a9bd563db..3daa44f13 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -451,3 +451,48 @@ instance Ord1 ImportAlias where liftCompare = genericLiftCompare instance Show1 ImportAlias where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ImportAlias + +data App a = App { appLeft :: a, appRight :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 App where liftEq = genericLiftEq +instance Ord1 App where liftCompare = genericLiftCompare +instance Show1 App where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable App + +data ListComprehension a = ListComprehension { comprehensionValue :: a, comprehensionSource :: [a] } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ListComprehension where liftEq = genericLiftEq +instance Ord1 ListComprehension where liftCompare = genericLiftCompare +instance Show1 ListComprehension where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ListComprehension + +data Generator a = Generator { generatorValue :: a, generatorSource :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Generator where liftEq = genericLiftEq +instance Ord1 Generator where liftCompare = genericLiftCompare +instance Show1 Generator where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Generator + +newtype Tuple a = Tuple [a] + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Tuple where liftEq = genericLiftEq +instance Ord1 Tuple where liftCompare = genericLiftCompare +instance Show1 Tuple where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Tuple + +newtype TuplePattern a = TuplePattern [a] + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 TuplePattern where liftEq = genericLiftEq +instance Ord1 TuplePattern where liftCompare = genericLiftCompare +instance Show1 TuplePattern where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable TuplePattern 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 b6755437c..a385cdebf 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -62,10 +62,6 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -82,6 +78,12 @@ { (ConstructorIdentifier) ->(ConstructorIdentifier) } (TypeParameters)) + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} 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 05c4b0e21..ce031ff48 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -62,10 +62,9 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -91,6 +90,9 @@ {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs new file mode 100644 index 000000000..446be0064 --- /dev/null +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -0,0 +1,12 @@ +f = a b +f = a b c +f = a b c d + +f = Just b +f = Right b +f = Example a c d +f = () + +a = [x | x <- xs] +a = [(x, y) | x <- xs, y <- ys] +a = [ x | xs <- [ [(1,2),(3,4)], [(5,4),(3,2)] ], (3,x) <- xs ] diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs new file mode 100644 index 000000000..7917ec9b1 --- /dev/null +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -0,0 +1,12 @@ +g = a b +g = a b c +g = a b c d + +g = Just b +g = Right b +g = Example a c d +g = () + +b = [x | x <- xs] +b = [(x, y) | x <- xs, y <- ys] +b = [ x | xs <- [ [(10,20),(30,40)], [(50,40),(30,20)] ], (30,x) <- xs ] diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt new file mode 100644 index 000000000..ee289563a --- /dev/null +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -0,0 +1,120 @@ +(Module + (Empty) + (Statements + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (VariableIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (App + (ConstructorIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (UnitConstructor))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (Array + (Array + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }) + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) })) + (Array + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }) + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) })))) + (Generator + (TuplePattern + { (Integer) + ->(Integer) } + (VariableIdentifier)) + (VariableIdentifier))))))) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt new file mode 100644 index 000000000..ee289563a --- /dev/null +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -0,0 +1,120 @@ +(Module + (Empty) + (Statements + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (VariableIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (App + (ConstructorIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (UnitConstructor))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (Array + (Array + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }) + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) })) + (Array + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }) + (Tuple + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) })))) + (Generator + (TuplePattern + { (Integer) + ->(Integer) } + (VariableIdentifier)) + (VariableIdentifier))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt new file mode 100644 index 000000000..438e3f47a --- /dev/null +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -0,0 +1,101 @@ +(Module + (Empty) + (Statements + (Function + (VariableIdentifier) + (Statements + (App + (VariableIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (App + (ConstructorIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (UnitConstructor))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (Array + (Array + (Tuple + (Integer) + (Integer)) + (Tuple + (Integer) + (Integer))) + (Array + (Tuple + (Integer) + (Integer)) + (Tuple + (Integer) + (Integer))))) + (Generator + (TuplePattern + (Integer) + (VariableIdentifier)) + (VariableIdentifier))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt new file mode 100644 index 000000000..438e3f47a --- /dev/null +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -0,0 +1,101 @@ +(Module + (Empty) + (Statements + (Function + (VariableIdentifier) + (Statements + (App + (VariableIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (App + (VariableIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (ConstructorIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (App + (ConstructorIdentifier) + (VariableIdentifier)) + (VariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (UnitConstructor))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (VariableIdentifier))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (VariableIdentifier) + (Generator + (VariableIdentifier) + (Array + (Array + (Tuple + (Integer) + (Integer)) + (Tuple + (Integer) + (Integer))) + (Array + (Tuple + (Integer) + (Integer)) + (Tuple + (Integer) + (Integer))))) + (Generator + (TuplePattern + (Integer) + (VariableIdentifier)) + (VariableIdentifier))))))) diff --git a/test/fixtures/haskell/corpus/literals.diffB-A.txt b/test/fixtures/haskell/corpus/literals.diffB-A.txt index 4f0defa69..aec6b2b9f 100644 --- a/test/fixtures/haskell/corpus/literals.diffB-A.txt +++ b/test/fixtures/haskell/corpus/literals.diffB-A.txt @@ -121,10 +121,12 @@ {+(VariableIdentifier)+} {+(Statements {+(Character)+})+})+} - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(Character)+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + {+(Character)+} + {-(Integer)-})) {+(Function {+(VariableIdentifier)+} {+(Statements @@ -283,10 +285,6 @@ {-(VariableIdentifier)-} {-(Statements {-(Integer)-})-})-} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(Integer)-})-})-} {-(Function {-(VariableIdentifier)-} {-(Statements diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt index d03474db8..8b3b1f8e1 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt @@ -115,14 +115,11 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+})+})+} {+(Empty)+})+})+})+})+})+} - (TypeSynonym - (Statements - { (TypeConstructorIdentifier) - ->(TypeConstructorIdentifier) } - {+(TypeConstructorIdentifier)+}) - { (TypePattern - {-(FunctionConstructor)-}) - ->(TextElement) }) + {+(TypeSynonym + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(TypeConstructorIdentifier)+})+} + {+(TextElement)+})+} {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+} @@ -171,6 +168,11 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+} {+(TypeVariableIdentifier)+})+})+})+})+} + {-(TypeSynonym + {-(Statements + {-(TypeConstructorIdentifier)-})-} + {-(TypePattern + {-(FunctionConstructor)-})-})-} {-(TypeSynonym {-(Statements {-(TypeConstructorIdentifier)-})-} From 1063bd91bd0b23a72cf33c31a40184838ac57395 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 10:47:48 -0700 Subject: [PATCH 07/23] Assign arithmetic sequences --- src/Language/Haskell/Assignment.hs | 13 +++ src/Language/Haskell/Syntax.hs | 12 +++ ...lgebraic-datatype-declarations.diffA-B.txt | 10 +- ...lgebraic-datatype-declarations.diffB-A.txt | 30 +++--- test/fixtures/haskell/corpus/expressions.A.hs | 10 ++ test/fixtures/haskell/corpus/expressions.B.hs | 10 ++ .../haskell/corpus/expressions.diffA-B.txt | 98 ++++++++++++++++++- .../haskell/corpus/expressions.diffB-A.txt | 98 ++++++++++++++++++- .../haskell/corpus/expressions.parseA.txt | 81 ++++++++++++++- .../haskell/corpus/expressions.parseB.txt | 83 +++++++++++++++- .../haskell/corpus/literals.diffA-B.txt | 14 ++- .../haskell/corpus/literals.diffB-A.txt | 14 +-- .../haskell/corpus/type-synonyms.diffB-A.txt | 18 ++-- 13 files changed, 441 insertions(+), 50 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index df8d5503e..c950837b5 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -38,6 +38,7 @@ type Syntax = '[ , Syntax.AllConstructors , Syntax.AnnotatedTypeVariable , Syntax.App + , Syntax.ArithmeticSequence , Syntax.Class , Syntax.ConstructorSymbol , Syntax.Context @@ -122,6 +123,17 @@ annotatedTypeVariable = makeTerm <$> symbol AnnotatedTypeVariable <*> children ( app :: Assignment app = makeTerm <$> symbol FunctionApplication <*> children (Syntax.App <$> expression <*> expression) +arithmeticSequence :: Assignment +arithmeticSequence = symbol ArithmeticSequence *> children ( enumFrom + <|> enumFromThen + <|> enumFromTo + <|> enumFromThenTo) + where + enumFrom = makeTerm <$> symbol EnumFrom <*> children (Syntax.EnumFrom <$> expression) + enumFromThen = makeTerm <$> symbol EnumFromThen <*> children (Syntax.EnumFromThen <$> expression <*> expression) + enumFromTo = makeTerm <$> symbol EnumFromTo <*> children (Syntax.EnumFromTo <$> expression <*> expression) + enumFromThenTo = makeTerm <$> symbol EnumFromThenTo <*> children (Syntax.EnumFromThenTo <$> expression <*> expression <*> expression) + character :: Assignment character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) @@ -180,6 +192,7 @@ expressionChoices = [ , allConstructors , annotatedTypeVariable , app + , arithmeticSequence , character , comment , context' diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 3daa44f13..750fdf499 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -496,3 +496,15 @@ instance Ord1 TuplePattern where liftCompare = genericLiftCompare instance Show1 TuplePattern where liftShowsPrec = genericLiftShowsPrec instance Evaluatable TuplePattern + +data ArithmeticSequence a = EnumFrom a -- e.g. [1..] + | EnumFromThen a a -- e.g. [1,2..] + | EnumFromTo a a -- e.g. [1..2] + | EnumFromThenTo a a a -- e.g. [1,2..10] + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ArithmeticSequence where liftEq = genericLiftEq +instance Ord1 ArithmeticSequence where liftCompare = genericLiftCompare +instance Show1 ArithmeticSequence where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ArithmeticSequence 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 a385cdebf..2eff06678 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -74,13 +74,15 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} 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 ce031ff48..9f79d366b 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -62,15 +62,6 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -81,15 +72,18 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs index 446be0064..e67bcbf27 100644 --- a/test/fixtures/haskell/corpus/expressions.A.hs +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -7,6 +7,16 @@ f = Right b f = Example a c d f = () +a = [1..] +a = [1,2..] +a = [1..2] +a = [1,2..10] + a = [x | x <- xs] a = [(x, y) | x <- xs, y <- ys] a = [ x | xs <- [ [(1,2),(3,4)], [(5,4),(3,2)] ], (3,x) <- xs ] +a = [(i,j) | i <- [1,2], + j <- [1..4] ] +a = [ [ (i,j) | i <- [1,2] ] | j <- [1..] ] + +f = take 5 [ [ (i,j) | i <- [1,2] ] | j <- [1..] ] diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs index 7917ec9b1..83218004e 100644 --- a/test/fixtures/haskell/corpus/expressions.B.hs +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -7,6 +7,16 @@ g = Right b g = Example a c d g = () +a = [2..] +a = [2,3..] +a = [2..9] +a = [2,3..18] + b = [x | x <- xs] b = [(x, y) | x <- xs, y <- ys] b = [ x | xs <- [ [(10,20),(30,40)], [(50,40),(30,20)] ], (30,x) <- xs ] +b = [(i,j) | i <- [1,2,3,4], + j <- [1..10] ] +b = [ [ (i,j) | i <- [2,4] ] | j <- [5..] ] + +b = take 7 [ [ (i,j) | i <- [1,2] ] | j <- [1..] ] diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt index ee289563a..62b343ed4 100644 --- a/test/fixtures/haskell/corpus/expressions.diffA-B.txt +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -58,6 +58,38 @@ ->(VariableIdentifier) } (Statements (UnitConstructor))) + (Function + (VariableIdentifier) + (Statements + (EnumFrom + { (Integer) + ->(Integer) }))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThen + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }))) + (Function + (VariableIdentifier) + (Statements + (EnumFromTo + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThenTo + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }))) (Function { (VariableIdentifier) ->(VariableIdentifier) } @@ -117,4 +149,68 @@ { (Integer) ->(Integer) } (VariableIdentifier)) - (VariableIdentifier))))))) + (VariableIdentifier))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer) + {+(Integer)+} + {+(Integer)+})) + (Generator + (VariableIdentifier) + (EnumFromTo + (Integer) + { (Integer) + ->(Integer) }))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + {-(Integer)-} + (Integer) + {+(Integer)+}))) + (Generator + (VariableIdentifier) + (EnumFrom + { (Integer) + ->(Integer) }))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (VariableIdentifier) + { (Integer) + ->(Integer) }) + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer)))) + (Generator + (VariableIdentifier) + (EnumFrom + (Integer))))))))) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt index ee289563a..d1a2c0807 100644 --- a/test/fixtures/haskell/corpus/expressions.diffB-A.txt +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -58,6 +58,38 @@ ->(VariableIdentifier) } (Statements (UnitConstructor))) + (Function + (VariableIdentifier) + (Statements + (EnumFrom + { (Integer) + ->(Integer) }))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThen + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }))) + (Function + (VariableIdentifier) + (Statements + (EnumFromTo + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThenTo + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) } + { (Integer) + ->(Integer) }))) (Function { (VariableIdentifier) ->(VariableIdentifier) } @@ -117,4 +149,68 @@ { (Integer) ->(Integer) } (VariableIdentifier)) - (VariableIdentifier))))))) + (VariableIdentifier))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer) + {-(Integer)-} + {-(Integer)-})) + (Generator + (VariableIdentifier) + (EnumFromTo + (Integer) + { (Integer) + ->(Integer) }))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + {+(Integer)+} + (Integer) + {-(Integer)-}))) + (Generator + (VariableIdentifier) + (EnumFrom + { (Integer) + ->(Integer) }))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (App + (App + (VariableIdentifier) + { (Integer) + ->(Integer) }) + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer)))) + (Generator + (VariableIdentifier) + (EnumFrom + (Integer))))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt index 438e3f47a..2d8fb0026 100644 --- a/test/fixtures/haskell/corpus/expressions.parseA.txt +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -51,6 +51,30 @@ (VariableIdentifier) (Statements (UnitConstructor))) + (Function + (VariableIdentifier) + (Statements + (EnumFrom + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThen + (Integer) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (EnumFromTo + (Integer) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThenTo + (Integer) + (Integer) + (Integer)))) (Function (VariableIdentifier) (Statements @@ -98,4 +122,59 @@ (TuplePattern (Integer) (VariableIdentifier)) - (VariableIdentifier))))))) + (VariableIdentifier))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer))) + (Generator + (VariableIdentifier) + (EnumFromTo + (Integer) + (Integer)))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer)))) + (Generator + (VariableIdentifier) + (EnumFrom + (Integer)))))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (VariableIdentifier) + (Integer)) + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer)))) + (Generator + (VariableIdentifier) + (EnumFrom + (Integer))))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt index 438e3f47a..f073c3b74 100644 --- a/test/fixtures/haskell/corpus/expressions.parseB.txt +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -51,6 +51,30 @@ (VariableIdentifier) (Statements (UnitConstructor))) + (Function + (VariableIdentifier) + (Statements + (EnumFrom + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThen + (Integer) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (EnumFromTo + (Integer) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (EnumFromThenTo + (Integer) + (Integer) + (Integer)))) (Function (VariableIdentifier) (Statements @@ -98,4 +122,61 @@ (TuplePattern (Integer) (VariableIdentifier)) - (VariableIdentifier))))))) + (VariableIdentifier))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer) + (Integer) + (Integer))) + (Generator + (VariableIdentifier) + (EnumFromTo + (Integer) + (Integer)))))) + (Function + (VariableIdentifier) + (Statements + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer)))) + (Generator + (VariableIdentifier) + (EnumFrom + (Integer)))))) + (Function + (VariableIdentifier) + (Statements + (App + (App + (VariableIdentifier) + (Integer)) + (ListComprehension + (ListComprehension + (Tuple + (VariableIdentifier) + (VariableIdentifier)) + (Generator + (VariableIdentifier) + (Array + (Integer) + (Integer)))) + (Generator + (VariableIdentifier) + (EnumFrom + (Integer))))))))) diff --git a/test/fixtures/haskell/corpus/literals.diffA-B.txt b/test/fixtures/haskell/corpus/literals.diffA-B.txt index 4f0defa69..aec6b2b9f 100644 --- a/test/fixtures/haskell/corpus/literals.diffA-B.txt +++ b/test/fixtures/haskell/corpus/literals.diffA-B.txt @@ -121,10 +121,12 @@ {+(VariableIdentifier)+} {+(Statements {+(Character)+})+})+} - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(Character)+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + {+(Character)+} + {-(Integer)-})) {+(Function {+(VariableIdentifier)+} {+(Statements @@ -283,10 +285,6 @@ {-(VariableIdentifier)-} {-(Statements {-(Integer)-})-})-} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(Integer)-})-})-} {-(Function {-(VariableIdentifier)-} {-(Statements diff --git a/test/fixtures/haskell/corpus/literals.diffB-A.txt b/test/fixtures/haskell/corpus/literals.diffB-A.txt index aec6b2b9f..4f0defa69 100644 --- a/test/fixtures/haskell/corpus/literals.diffB-A.txt +++ b/test/fixtures/haskell/corpus/literals.diffB-A.txt @@ -121,12 +121,10 @@ {+(VariableIdentifier)+} {+(Statements {+(Character)+})+})+} - (Function - { (VariableIdentifier) - ->(VariableIdentifier) } - (Statements - {+(Character)+} - {-(Integer)-})) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Character)+})+})+} {+(Function {+(VariableIdentifier)+} {+(Statements @@ -285,6 +283,10 @@ {-(VariableIdentifier)-} {-(Statements {-(Integer)-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(Integer)-})-})-} {-(Function {-(VariableIdentifier)-} {-(Statements diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt index 8b3b1f8e1..d03474db8 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt @@ -115,11 +115,14 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+})+})+} {+(Empty)+})+})+})+})+})+} - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeConstructorIdentifier)+})+} - {+(TextElement)+})+} + (TypeSynonym + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + {+(TypeConstructorIdentifier)+}) + { (TypePattern + {-(FunctionConstructor)-}) + ->(TextElement) }) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+} @@ -168,11 +171,6 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+} {+(TypeVariableIdentifier)+})+})+})+})+} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-})-} - {-(TypePattern - {-(FunctionConstructor)-})-})-} {-(TypeSynonym {-(Statements {-(TypeConstructorIdentifier)-})-} From d6d865c90bca32ea1cb5c147ac8c8285be914868 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 13:18:44 -0700 Subject: [PATCH 08/23] Assign left and right operator sections --- src/Language/Haskell/Assignment.hs | 6 +++ src/Language/Haskell/Syntax.hs | 10 ++++ ...lgebraic-datatype-declarations.diffA-B.txt | 10 ++-- ...lgebraic-datatype-declarations.diffB-A.txt | 30 +++++++----- test/fixtures/haskell/corpus/expressions.A.hs | 6 +++ test/fixtures/haskell/corpus/expressions.B.hs | 6 +++ .../haskell/corpus/expressions.diffA-B.txt | 46 ++++++++++++++++++- .../haskell/corpus/expressions.diffB-A.txt | 46 ++++++++++++++++++- .../haskell/corpus/expressions.parseA.txt | 30 +++++++++++- .../haskell/corpus/expressions.parseB.txt | 30 +++++++++++- 10 files changed, 198 insertions(+), 22 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index c950837b5..0d833ad67 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -72,6 +72,7 @@ type Syntax = '[ , Syntax.ModuleExport , Syntax.NewType , Syntax.Operator + , Syntax.OperatorSection , Syntax.Pragma , Syntax.QualifiedImportDeclaration , Syntax.QualifiedModuleIdentifier @@ -225,6 +226,7 @@ expressionChoices = [ , moduleIdentifier , newType , operator + , operatorSection , parenthesizedTypePattern , pattern , pragma @@ -404,6 +406,10 @@ newType = makeTerm <$> symbol NewtypeDeclaration <*> children (Syntax.NewType <$ operator :: Assignment operator = typeOperator <|> constructorOperator <|> variableOperator +operatorSection :: Assignment +operatorSection = (makeTerm <$> symbol RightOperatorSection <*> children (Syntax.RightOperatorSection <$> expression <*> expression)) + <|> (makeTerm <$> symbol LeftOperatorSection <*> children (Syntax.LeftOperatorSection <$> expression <*> expression)) + packageQualifiedImport :: Assignment packageQualifiedImport = makeTerm <$> symbol PackageQualifiedImport <*> (Literal.TextElement <$> source) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 750fdf499..c34fff8ec 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -508,3 +508,13 @@ instance Ord1 ArithmeticSequence where liftCompare = genericLiftCompare instance Show1 ArithmeticSequence where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ArithmeticSequence + +data OperatorSection a = RightOperatorSection a a + | LeftOperatorSection a a + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 OperatorSection where liftEq = genericLiftEq +instance Ord1 OperatorSection where liftCompare = genericLiftCompare +instance Show1 OperatorSection where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable OperatorSection 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 2eff06678..957d9c670 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -65,6 +65,10 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -77,12 +81,6 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} 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 9f79d366b..e64e25577 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -72,18 +72,24 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs index e67bcbf27..d0af7c7a7 100644 --- a/test/fixtures/haskell/corpus/expressions.A.hs +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -20,3 +20,9 @@ a = [(i,j) | i <- [1,2], a = [ [ (i,j) | i <- [1,2] ] | j <- [1..] ] f = take 5 [ [ (i,j) | i <- [1,2] ] | j <- [1..] ] + +a = (: a) +a = (:< a) + +a = (a :) +a = (a :|) diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs index 83218004e..1a09f8f95 100644 --- a/test/fixtures/haskell/corpus/expressions.B.hs +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -20,3 +20,9 @@ b = [(i,j) | i <- [1,2,3,4], b = [ [ (i,j) | i <- [2,4] ] | j <- [5..] ] b = take 7 [ [ (i,j) | i <- [1,2] ] | j <- [1..] ] + +b = (: a) +b = (:< a) + +b = (b :) +b = (b :|) diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt index 62b343ed4..f86c70398 100644 --- a/test/fixtures/haskell/corpus/expressions.diffA-B.txt +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -213,4 +213,48 @@ (Generator (VariableIdentifier) (EnumFrom - (Integer))))))))) + (Integer))))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(LeftOperatorSection + {+(VariableIdentifier)+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(LeftOperatorSection + {+(VariableIdentifier)+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+})+})+})+} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(LeftOperatorSection + {-(VariableIdentifier)-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(LeftOperatorSection + {-(VariableIdentifier)-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-})-})-})-})) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt index d1a2c0807..03a9263c4 100644 --- a/test/fixtures/haskell/corpus/expressions.diffB-A.txt +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -213,4 +213,48 @@ (Generator (VariableIdentifier) (EnumFrom - (Integer))))))))) + (Integer))))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(LeftOperatorSection + {+(VariableIdentifier)+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(LeftOperatorSection + {+(VariableIdentifier)+} + {+(ConstructorOperator + {+(ConstructorSymbol)+})+})+})+})+} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(LeftOperatorSection + {-(VariableIdentifier)-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(LeftOperatorSection + {-(VariableIdentifier)-} + {-(ConstructorOperator + {-(ConstructorSymbol)-})-})-})-})-})) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt index 2d8fb0026..633638d23 100644 --- a/test/fixtures/haskell/corpus/expressions.parseA.txt +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -177,4 +177,32 @@ (Generator (VariableIdentifier) (EnumFrom - (Integer))))))))) + (Integer))))))) + (Function + (VariableIdentifier) + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (LeftOperatorSection + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol))))) + (Function + (VariableIdentifier) + (Statements + (LeftOperatorSection + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt index f073c3b74..3f55f42da 100644 --- a/test/fixtures/haskell/corpus/expressions.parseB.txt +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -179,4 +179,32 @@ (Generator (VariableIdentifier) (EnumFrom - (Integer))))))))) + (Integer))))))) + (Function + (VariableIdentifier) + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (RightOperatorSection + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (LeftOperatorSection + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol))))) + (Function + (VariableIdentifier) + (Statements + (LeftOperatorSection + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol))))))) From 1120561e78ccf1fa8997f7eff6d57076b9f7b09e Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:15:27 -0700 Subject: [PATCH 09/23] Add QualifiedEntityIdentifier data type --- src/Language/Haskell/Syntax.hs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index c34fff8ec..05cdc1902 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -225,15 +225,19 @@ instance Show1 Star where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Star -newtype QualifiedTypeConstructorIdentifier a = QualifiedTypeConstructorIdentifier { qualifiedTypeConstructorIdentifierName :: NonEmpty a } +data QualifiedEntityIdentifier a = QualifiedTypeConstructorIdentifier (NonEmpty a) + | QualifiedConstructorIdentifier (NonEmpty a) + | QualifiedInfixVariableIdentifier (NonEmpty a) + | QualifiedModuleIdentifier (NonEmpty a) + | QualifiedVariableIdentifier (NonEmpty a) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Mergeable, Ord, Show, ToJSONFields1, Traversable) -instance Eq1 QualifiedTypeConstructorIdentifier where liftEq = genericLiftEq -instance Ord1 QualifiedTypeConstructorIdentifier where liftCompare = genericLiftCompare -instance Show1 QualifiedTypeConstructorIdentifier where liftShowsPrec = genericLiftShowsPrec -instance Hashable1 QualifiedTypeConstructorIdentifier where liftHashWithSalt = foldl +instance Eq1 QualifiedEntityIdentifier where liftEq = genericLiftEq +instance Ord1 QualifiedEntityIdentifier where liftCompare = genericLiftCompare +instance Show1 QualifiedEntityIdentifier where liftShowsPrec = genericLiftShowsPrec +instance Hashable1 QualifiedEntityIdentifier where liftHashWithSalt = foldl -instance Evaluatable QualifiedTypeConstructorIdentifier +instance Evaluatable QualifiedEntityIdentifier data AnnotatedTypeVariable a = AnnotatedTypeVariable { annotatedTypeVariableIdentifier :: a, annotatedTypeVariableannotation :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) @@ -244,16 +248,6 @@ instance Show1 AnnotatedTypeVariable where liftShowsPrec = genericLiftShowsPrec instance Evaluatable AnnotatedTypeVariable -newtype QualifiedModuleIdentifier a = QualifiedModuleIdentifier { qualifiedModuleIdentifierName :: NonEmpty a } - deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Mergeable, Ord, Show, ToJSONFields1, Traversable) - -instance Eq1 QualifiedModuleIdentifier where liftEq = genericLiftEq -instance Ord1 QualifiedModuleIdentifier where liftCompare = genericLiftCompare -instance Show1 QualifiedModuleIdentifier where liftShowsPrec = genericLiftShowsPrec -instance Hashable1 QualifiedModuleIdentifier where liftHashWithSalt = foldl - -instance Evaluatable QualifiedModuleIdentifier - newtype Export a = Export { exportContent :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) From bb48fe6d50750a9e5bf87e75b0a7a49064bebe2c Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:15:57 -0700 Subject: [PATCH 10/23] Assign InfixVariableIdentifier --- src/Language/Haskell/Assignment.hs | 4 ++++ src/Language/Haskell/Syntax.hs | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 0d833ad67..6fc9ce827 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -215,6 +215,7 @@ expressionChoices = [ , importAlias , importDeclaration , infixOperatorPattern + , infixVariableIdentifier , integer , kind , kindSignature @@ -344,6 +345,9 @@ importSpec = symbol ImportSpec *> children (manyTerm import') infixOperatorPattern :: Assignment infixOperatorPattern = makeTerm <$> symbol InfixOperatorPattern <*> children (Syntax.InfixOperatorPattern <$> expression <*> operator <*> expression) +infixVariableIdentifier :: Assignment +infixVariableIdentifier = makeTerm <$> symbol InfixVariableIdentifier <*> children (Syntax.InfixVariableIdentifier . Name.name <$> source) + integer :: Assignment integer = makeTerm <$> symbol Integer <*> (Literal.Integer <$> source) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 05cdc1902..8e679a7e7 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -351,6 +351,7 @@ data EntityIdentifier a = TypeVariableIdentifier Name | TypeConstructorIdentifier Name | ModuleIdentifier Name | ConstructorIdentifier Name + | InfixVariableIdentifier Name | TypeClassIdentifier Name | VariableIdentifier Name | PrimitiveConstructorIdentifier Name From 7c38ddf4a20c84e77741fd259cdb7954b8cde02e Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:16:25 -0700 Subject: [PATCH 11/23] Assign infix operator applications --- src/Language/Haskell/Assignment.hs | 4 ++++ src/Language/Haskell/Syntax.hs | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 6fc9ce827..39c49b405 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -214,6 +214,7 @@ expressionChoices = [ , generator , importAlias , importDeclaration + , infixOperatorApp , infixOperatorPattern , infixVariableIdentifier , integer @@ -342,6 +343,9 @@ importDeclaration = makeTerm importSpec :: Assignment.Assignment [] Grammar [Term] importSpec = symbol ImportSpec *> children (manyTerm import') +infixOperatorApp :: Assignment +infixOperatorApp = makeTerm <$> symbol InfixOperatorApplication <*> children (Syntax.InfixOperatorApp <$> expression <*> expression <*> expression) + infixOperatorPattern :: Assignment infixOperatorPattern = makeTerm <$> symbol InfixOperatorPattern <*> children (Syntax.InfixOperatorPattern <$> expression <*> operator <*> expression) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 8e679a7e7..7bb2b3634 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -448,6 +448,7 @@ instance Show1 ImportAlias where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ImportAlias data App a = App { appLeft :: a, appRight :: a } + | InfixOperatorApp { appLeft :: a, infixOperator :: a, appRight :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 App where liftEq = genericLiftEq From c385468ba735ea17bbaa0c9a158d40174cc42408 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:16:55 -0700 Subject: [PATCH 12/23] Assign constructor pattern --- src/Language/Haskell/Assignment.hs | 5 +++++ src/Language/Haskell/Syntax.hs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 39c49b405..685fc0806 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -40,6 +40,7 @@ type Syntax = '[ , Syntax.App , Syntax.ArithmeticSequence , Syntax.Class + , Syntax.ConstructorPattern , Syntax.ConstructorSymbol , Syntax.Context , Syntax.Context' @@ -154,6 +155,9 @@ constructorIdentifier = makeTerm <$> symbol ConstructorIdentifier <*> (Syntax.Co constructorOperator :: Assignment constructorOperator = makeTerm <$> symbol ConstructorOperator <*> children (Syntax.ConstructorOperator <$> expression) +constructorPattern :: Assignment +constructorPattern = makeTerm <$> symbol ConstructorPattern <*> children (Syntax.ConstructorPattern <$> expressions) + constructorSymbol :: Assignment constructorSymbol = makeTerm <$> symbol ConstructorSymbol <*> (Syntax.ConstructorSymbol . Name.name <$> source) @@ -200,6 +204,7 @@ expressionChoices = [ , contextPattern , constructorIdentifier , constructorOperator + , constructorPattern , constructorSymbol , defaultDeclaration , derivingClause diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 7bb2b3634..e6ac94bab 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -514,3 +514,13 @@ instance Ord1 OperatorSection where liftCompare = genericLiftCompare instance Show1 OperatorSection where liftShowsPrec = genericLiftShowsPrec instance Evaluatable OperatorSection + +newtype ConstructorPattern a = ConstructorPattern a + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 ConstructorPattern where liftEq = genericLiftEq +instance Ord1 ConstructorPattern where liftCompare = genericLiftCompare +instance Show1 ConstructorPattern where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable ConstructorPattern + From bea637d6ce91bc463ef57afebdf6c6253870a69c Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:17:59 -0700 Subject: [PATCH 13/23] Assign qualified infix variable identifiers, qualified constructor identifiers, and qualified variable identifiers --- src/Language/Haskell/Assignment.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 685fc0806..68fad4e70 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -75,9 +75,8 @@ type Syntax = '[ , Syntax.Operator , Syntax.OperatorSection , Syntax.Pragma + , Syntax.QualifiedEntityIdentifier , Syntax.QualifiedImportDeclaration - , Syntax.QualifiedModuleIdentifier - , Syntax.QualifiedTypeConstructorIdentifier , Syntax.QuotedName , Syntax.RecordDataConstructor , Syntax.ScopedTypeVariables @@ -239,9 +238,12 @@ expressionChoices = [ , pragma , primitiveConstructorIdentifier , primitiveVariableIdentifier + , qualifiedConstructorIdentifier , qualifiedImportDeclaration + , qualifiedInfixVariableIdentifier , qualifiedModuleIdentifier , qualifiedTypeConstructorIdentifier + , qualifiedVariableIdentifier , quotedName , scopedTypeVariables , standaloneDerivingInstance @@ -441,6 +443,9 @@ primitiveConstructorIdentifier = makeTerm <$> symbol PrimitiveConstructorIdentif primitiveVariableIdentifier :: Assignment primitiveVariableIdentifier = makeTerm <$> symbol PrimitiveVariableIdentifier <*> (Syntax.PrimitiveVariableIdentifier . Name.name <$> source) +qualifiedConstructorIdentifier :: Assignment +qualifiedConstructorIdentifier = makeTerm <$> symbol QualifiedConstructorIdentifier <*> children (Syntax.QualifiedConstructorIdentifier <$> someTerm' expression) + qualifiedImportDeclaration :: Assignment qualifiedImportDeclaration = makeTerm <$> symbol QualifiedImportDeclaration @@ -449,12 +454,18 @@ qualifiedImportDeclaration = makeTerm <*> expression <*> (importSpec <|> hiddenImportSpec <|> pure [])) +qualifiedInfixVariableIdentifier :: Assignment +qualifiedInfixVariableIdentifier = makeTerm <$> symbol QualifiedInfixVariableIdentifier <*> children (Syntax.QualifiedInfixVariableIdentifier <$> someTerm' expression) + qualifiedModuleIdentifier :: Assignment qualifiedModuleIdentifier = makeTerm <$> symbol QualifiedModuleIdentifier <*> children (Syntax.QualifiedModuleIdentifier <$> someTerm' expression) qualifiedTypeConstructorIdentifier :: Assignment qualifiedTypeConstructorIdentifier = makeTerm <$> symbol QualifiedTypeConstructorIdentifier <*> children (Syntax.QualifiedTypeConstructorIdentifier <$> someTerm' expression) +qualifiedVariableIdentifier :: Assignment +qualifiedVariableIdentifier = makeTerm <$> symbol QualifiedVariableIdentifier <*> children (Syntax.QualifiedVariableIdentifier <$> someTerm' expression) + quotedName :: Assignment quotedName = makeTerm <$> symbol QuotedName <*> children (Syntax.QuotedName <$> expression) From 1542a78872fb2cff7518964effe8124e00146205 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:18:33 -0700 Subject: [PATCH 14/23] Assign bind pattern (e.g. `a <- b` in a do block) --- src/Language/Haskell/Assignment.hs | 5 +++++ src/Language/Haskell/Syntax.hs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 68fad4e70..e85b74978 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -39,6 +39,7 @@ type Syntax = '[ , Syntax.AnnotatedTypeVariable , Syntax.App , Syntax.ArithmeticSequence + , Syntax.BindPattern , Syntax.Class , Syntax.ConstructorPattern , Syntax.ConstructorSymbol @@ -135,6 +136,9 @@ arithmeticSequence = symbol ArithmeticSequence *> children ( enumFrom enumFromTo = makeTerm <$> symbol EnumFromTo <*> children (Syntax.EnumFromTo <$> expression <*> expression) enumFromThenTo = makeTerm <$> symbol EnumFromThenTo <*> children (Syntax.EnumFromThenTo <$> expression <*> expression <*> expression) +bindPattern :: Assignment +bindPattern = makeTerm <$> symbol BindPattern <*> children (Syntax.BindPattern <$> expression <*> expression) + character :: Assignment character = makeTerm <$> symbol Char <*> (Literal.Character <$> source) @@ -197,6 +201,7 @@ expressionChoices = [ , annotatedTypeVariable , app , arithmeticSequence + , bindPattern , character , comment , context' diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index e6ac94bab..3ed02c2e2 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -524,3 +524,13 @@ instance Show1 ConstructorPattern where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ConstructorPattern +-- e.g. `a <- b` in a Haskell do block +data BindPattern a = BindPattern { bindPatternLeft :: a, bindPatternRight :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 BindPattern where liftEq = genericLiftEq +instance Ord1 BindPattern where liftCompare = genericLiftCompare +instance Show1 BindPattern where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable BindPattern + From 2397c47e9af7abbcb8f0246bff201bab304fa4c6 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:18:48 -0700 Subject: [PATCH 15/23] Assign do blocks --- src/Language/Haskell/Assignment.hs | 5 +++++ src/Language/Haskell/Syntax.hs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index e85b74978..8eaaa7e71 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -47,6 +47,7 @@ type Syntax = '[ , Syntax.Context' , Syntax.DefaultDeclaration , Syntax.Deriving + , Syntax.Do , Syntax.Empty , Syntax.EntityIdentifier , Syntax.Error @@ -176,6 +177,9 @@ defaultDeclaration = makeTerm <$> symbol DefaultDeclaration <*> children (Syntax derivingClause :: Assignment derivingClause = makeTerm <$> symbol Deriving <*> children (Syntax.Deriving <$> manyTerm typeConstructor) +do' :: Assignment +do' = makeTerm <$> symbol Do <*> children (Syntax.Do <$> manyTerm expression) + equalityConstraint :: Assignment equalityConstraint = makeTerm <$> symbol EqualityConstraint <*> children (Syntax.EqualityConstraint <$> equalityLhs <*> equalityRhs) where @@ -212,6 +216,7 @@ expressionChoices = [ , constructorSymbol , defaultDeclaration , derivingClause + , do' , equalityConstraint , expression' , float diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 3ed02c2e2..4a628525f 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -534,3 +534,11 @@ instance Show1 BindPattern where liftShowsPrec = genericLiftShowsPrec instance Evaluatable BindPattern +newtype Do a = Do [a] + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Do where liftEq = genericLiftEq +instance Ord1 Do where liftCompare = genericLiftCompare +instance Show1 Do where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Do From 811a7335a08211f672daa21d1ce96a434802ef07 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:18:56 -0700 Subject: [PATCH 16/23] Assign parenthesized patterns --- src/Language/Haskell/Assignment.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 8eaaa7e71..151319186 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -243,6 +243,7 @@ expressionChoices = [ , newType , operator , operatorSection + , parenthesizedPattern , parenthesizedTypePattern , pattern , pragma @@ -438,6 +439,9 @@ operatorSection = (makeTerm <$> symbol RightOperatorSection <*> children (Syntax packageQualifiedImport :: Assignment packageQualifiedImport = makeTerm <$> symbol PackageQualifiedImport <*> (Literal.TextElement <$> source) +parenthesizedPattern :: Assignment +parenthesizedPattern = symbol ParenthesizedPattern *> children expressions + parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children expressions From 00e299ad257c6597ce2225f8709f6bd860ccba52 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:19:18 -0700 Subject: [PATCH 17/23] Add more expression test fixtures --- ...lgebraic-datatype-declarations.diffA-B.txt | 20 +-- ...lgebraic-datatype-declarations.diffB-A.txt | 10 +- test/fixtures/haskell/corpus/expressions.A.hs | 14 ++ test/fixtures/haskell/corpus/expressions.B.hs | 14 ++ .../haskell/corpus/expressions.diffA-B.txt | 107 +++++++++++- .../haskell/corpus/expressions.diffB-A.txt | 160 ++++++++++++++++-- .../haskell/corpus/expressions.parseA.txt | 76 ++++++++- .../haskell/corpus/expressions.parseB.txt | 76 ++++++++- .../haskell/corpus/literals.diffA-B.txt | 19 +-- .../haskell/corpus/literals.diffB-A.txt | 13 +- .../haskell/corpus/type-synonyms.diffA-B.txt | 14 +- .../haskell/corpus/type-synonyms.diffB-A.txt | 34 ++-- 12 files changed, 482 insertions(+), 75 deletions(-) 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 957d9c670..a45e7f33c 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -62,6 +62,14 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -75,18 +83,6 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} 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 e64e25577..2a8638d41 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -62,9 +62,10 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) (Constructor { (ConstructorIdentifier) ->(ConstructorIdentifier) } @@ -90,9 +91,6 @@ {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs index d0af7c7a7..a65b4c81b 100644 --- a/test/fixtures/haskell/corpus/expressions.A.hs +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -26,3 +26,17 @@ a = (:< a) a = (a :) a = (a :|) + +g = h `i` j + +a = Data.Just + +parseJSON (JSON.Object r) = IncPK <$> + r .: "id" <*> + r .: "nullable_string" <*> + r .: "non_nullable_string" <*> + r .: "inserted_at" + +f = do + a <- b =<< c + b <- e >>= g diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs index 1a09f8f95..f0128abd0 100644 --- a/test/fixtures/haskell/corpus/expressions.B.hs +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -26,3 +26,17 @@ b = (:< a) b = (b :) b = (b :|) + +b = h `i` j + +b = Data.Just + +parseJSON (JSON.Object s) = IncPK <$> + s .: "id" <*> + s .: "nullable_string" <*> + s .: "non_nullable_string" <*> + s .: "inserted_at" + +g = do + b <- d =<< e + c <- f >>= h diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt index f86c70398..802be0ecf 100644 --- a/test/fixtures/haskell/corpus/expressions.diffA-B.txt +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -230,6 +230,15 @@ (ConstructorOperator (ConstructorSymbol)) (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (LeftOperatorSection + { (VariableIdentifier) + ->(VariableIdentifier) } + (ConstructorOperator + (ConstructorSymbol))))) {+(Function {+(VariableIdentifier)+} {+(Statements @@ -240,10 +249,17 @@ {+(Function {+(VariableIdentifier)+} {+(Statements - {+(LeftOperatorSection + {+(InfixOperatorApp {+(VariableIdentifier)+} - {+(ConstructorOperator - {+(ConstructorSymbol)+})+})+})+})+} + {+(VariableOperator + {+(InfixVariableIdentifier)+})+} + {+(VariableIdentifier)+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(QualifiedConstructorIdentifier + {+(ModuleIdentifier)+} + {+(ConstructorIdentifier)+})+})+})+} {-(Function {-(VariableIdentifier)-} {-(Statements @@ -254,7 +270,86 @@ {-(Function {-(VariableIdentifier)-} {-(Statements - {-(LeftOperatorSection + {-(InfixOperatorApp {-(VariableIdentifier)-} - {-(ConstructorOperator - {-(ConstructorSymbol)-})-})-})-})-})) + {-(VariableOperator + {-(InfixVariableIdentifier)-})-} + {-(VariableIdentifier)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(QualifiedConstructorIdentifier + {-(ModuleIdentifier)-} + {-(ConstructorIdentifier)-})-})-})-} + (Function + (VariableIdentifier) + (ConstructorPattern + (Statements + (QualifiedConstructorIdentifier + (ModuleIdentifier) + (ConstructorIdentifier)) + { (VariableIdentifier) + ->(VariableIdentifier) })) + (Statements + (InfixOperatorApp + (ConstructorIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + { (VariableIdentifier) + ->(VariableIdentifier) } + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + { (VariableIdentifier) + ->(VariableIdentifier) } + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + { (VariableIdentifier) + ->(VariableIdentifier) } + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + { (VariableIdentifier) + ->(VariableIdentifier) } + (VariableOperator + (VariableSymbol)) + (TextElement))))))))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Do + (BindPattern + { (VariableIdentifier) + ->(VariableIdentifier) } + (InfixOperatorApp + { (VariableIdentifier) + ->(VariableIdentifier) } + (VariableOperator + (VariableSymbol)) + { (VariableIdentifier) + ->(VariableIdentifier) })) + (BindPattern + { (VariableIdentifier) + ->(VariableIdentifier) } + (InfixOperatorApp + { (VariableIdentifier) + ->(VariableIdentifier) } + (VariableOperator + (VariableSymbol)) + { (VariableIdentifier) + ->(VariableIdentifier) }))))))) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt index 03a9263c4..7a3d7fcb3 100644 --- a/test/fixtures/haskell/corpus/expressions.diffB-A.txt +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -230,13 +230,15 @@ (ConstructorOperator (ConstructorSymbol)) (VariableIdentifier)))) - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(LeftOperatorSection - {+(VariableIdentifier)+} - {+(ConstructorOperator - {+(ConstructorSymbol)+})+})+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (LeftOperatorSection + { (VariableIdentifier) + ->(VariableIdentifier) } + (ConstructorOperator + (ConstructorSymbol))))) {+(Function {+(VariableIdentifier)+} {+(Statements @@ -254,7 +256,145 @@ {-(Function {-(VariableIdentifier)-} {-(Statements - {-(LeftOperatorSection + {-(InfixOperatorApp {-(VariableIdentifier)-} - {-(ConstructorOperator - {-(ConstructorSymbol)-})-})-})-})-})) + {-(VariableOperator + {-(InfixVariableIdentifier)-})-} + {-(VariableIdentifier)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(QualifiedConstructorIdentifier + {-(ModuleIdentifier)-} + {-(ConstructorIdentifier)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(ConstructorPattern + {-(Statements + {-(QualifiedConstructorIdentifier + {-(ModuleIdentifier)-} + {-(ConstructorIdentifier)-})-} + {-(VariableIdentifier)-})-})-} + {-(Statements + {-(InfixOperatorApp + {-(ConstructorIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(TextElement)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(TextElement)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(TextElement)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(TextElement)-})-})-})-})-})-})-})-})-})-})-} + (Function + (VariableIdentifier) + (Statements + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(InfixVariableIdentifier)+})+} + {+(VariableIdentifier)+})+} + {-(Do + {-(BindPattern + {-(VariableIdentifier)-} + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(VariableIdentifier)-})-})-} + {-(BindPattern + {-(VariableIdentifier)-} + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(VariableIdentifier)-})-})-})-})) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(QualifiedConstructorIdentifier + {+(ModuleIdentifier)+} + {+(ConstructorIdentifier)+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(ConstructorPattern + {+(Statements + {+(QualifiedConstructorIdentifier + {+(ModuleIdentifier)+} + {+(ConstructorIdentifier)+})+} + {+(VariableIdentifier)+})+})+} + {+(Statements + {+(InfixOperatorApp + {+(ConstructorIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(TextElement)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(TextElement)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(TextElement)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(TextElement)+})+})+})+})+})+})+})+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Do + {+(BindPattern + {+(VariableIdentifier)+} + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(VariableIdentifier)+})+})+} + {+(BindPattern + {+(VariableIdentifier)+} + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(VariableIdentifier)+})+})+})+})+})+})) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt index 633638d23..190d3f150 100644 --- a/test/fixtures/haskell/corpus/expressions.parseA.txt +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -205,4 +205,78 @@ (LeftOperatorSection (VariableIdentifier) (ConstructorOperator - (ConstructorSymbol))))))) + (ConstructorSymbol))))) + (Function + (VariableIdentifier) + (Statements + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (InfixVariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (QualifiedConstructorIdentifier + (ModuleIdentifier) + (ConstructorIdentifier)))) + (Function + (VariableIdentifier) + (ConstructorPattern + (Statements + (QualifiedConstructorIdentifier + (ModuleIdentifier) + (ConstructorIdentifier)) + (VariableIdentifier))) + (Statements + (InfixOperatorApp + (ConstructorIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (TextElement))))))))))) + (Function + (VariableIdentifier) + (Statements + (Do + (BindPattern + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier))) + (BindPattern + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier)))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt index 3f55f42da..bd0f68d19 100644 --- a/test/fixtures/haskell/corpus/expressions.parseB.txt +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -207,4 +207,78 @@ (LeftOperatorSection (VariableIdentifier) (ConstructorOperator - (ConstructorSymbol))))))) + (ConstructorSymbol))))) + (Function + (VariableIdentifier) + (Statements + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (InfixVariableIdentifier)) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (QualifiedConstructorIdentifier + (ModuleIdentifier) + (ConstructorIdentifier)))) + (Function + (VariableIdentifier) + (ConstructorPattern + (Statements + (QualifiedConstructorIdentifier + (ModuleIdentifier) + (ConstructorIdentifier)) + (VariableIdentifier))) + (Statements + (InfixOperatorApp + (ConstructorIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (TextElement) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (TextElement))))))))))) + (Function + (VariableIdentifier) + (Statements + (Do + (BindPattern + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier))) + (BindPattern + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier)))))))) diff --git a/test/fixtures/haskell/corpus/literals.diffA-B.txt b/test/fixtures/haskell/corpus/literals.diffA-B.txt index aec6b2b9f..316dd79d5 100644 --- a/test/fixtures/haskell/corpus/literals.diffA-B.txt +++ b/test/fixtures/haskell/corpus/literals.diffA-B.txt @@ -1,10 +1,11 @@ (Module (ModuleIdentifier) (Statements - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(Integer)+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Integer))) {+(Function {+(VariableIdentifier)+} {+(Statements @@ -121,12 +122,10 @@ {+(VariableIdentifier)+} {+(Statements {+(Character)+})+})+} - (Function - { (VariableIdentifier) - ->(VariableIdentifier) } - (Statements - {+(Character)+} - {-(Integer)-})) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Character)+})+})+} {+(Function {+(VariableIdentifier)+} {+(Statements diff --git a/test/fixtures/haskell/corpus/literals.diffB-A.txt b/test/fixtures/haskell/corpus/literals.diffB-A.txt index 4f0defa69..316dd79d5 100644 --- a/test/fixtures/haskell/corpus/literals.diffB-A.txt +++ b/test/fixtures/haskell/corpus/literals.diffB-A.txt @@ -1,10 +1,11 @@ (Module (ModuleIdentifier) (Statements - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(Integer)+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Integer))) {+(Function {+(VariableIdentifier)+} {+(Statements @@ -283,10 +284,6 @@ {-(VariableIdentifier)-} {-(Statements {-(Integer)-})-})-} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(Integer)-})-})-} {-(Function {-(VariableIdentifier)-} {-(Statements diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt index 4fff50387..bcfd0ab5f 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt @@ -52,17 +52,17 @@ (TypeConstructorIdentifier)) (TypePattern (TupleConstructor))) - (TypeSynonym - (Statements - (TypeConstructorIdentifier)) - (TypePattern - { (FunctionConstructor) - ->(TupleConstructor) })) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+})+} {+(TypePattern - {+(FunctionConstructor)+})+})+} + {+(TupleConstructor)+})+})+} + (TypeSynonym + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) }) + (TypePattern + (FunctionConstructor))) (TypeSynonym (Statements (TypeConstructorIdentifier)) diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt index d03474db8..e098b46e7 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt @@ -52,12 +52,11 @@ (TypeConstructorIdentifier)) (TypePattern (TupleConstructor))) - (TypeSynonym - (Statements - (TypeConstructorIdentifier)) - (TypePattern - { (TupleConstructor) - ->(FunctionConstructor) })) + {+(TypeSynonym + {+(Statements + {+(TypeConstructorIdentifier)+})+} + {+(TypePattern + {+(FunctionConstructor)+})+})+} {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+})+} @@ -115,14 +114,11 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+})+})+} {+(Empty)+})+})+})+})+})+} - (TypeSynonym - (Statements - { (TypeConstructorIdentifier) - ->(TypeConstructorIdentifier) } - {+(TypeConstructorIdentifier)+}) - { (TypePattern - {-(FunctionConstructor)-}) - ->(TextElement) }) + {+(TypeSynonym + {+(Statements + {+(TypeConstructorIdentifier)+} + {+(TypeConstructorIdentifier)+})+} + {+(TextElement)+})+} {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+} @@ -171,6 +167,16 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+} {+(TypeVariableIdentifier)+})+})+})+})+} + {-(TypeSynonym + {-(Statements + {-(TypeConstructorIdentifier)-})-} + {-(TypePattern + {-(TupleConstructor)-})-})-} + {-(TypeSynonym + {-(Statements + {-(TypeConstructorIdentifier)-})-} + {-(TypePattern + {-(FunctionConstructor)-})-})-} {-(TypeSynonym {-(Statements {-(TypeConstructorIdentifier)-})-} From c53dab76cf189aef10744d7cb61c34fc8e4427ed Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 14:50:38 -0700 Subject: [PATCH 18/23] Assign lambdas --- src/Language/Haskell/Assignment.hs | 8 ++ src/Language/Haskell/Syntax.hs | 9 ++ ...lgebraic-datatype-declarations.diffA-B.txt | 6 +- ...lgebraic-datatype-declarations.diffB-A.txt | 10 +- test/fixtures/haskell/corpus/expressions.A.hs | 8 ++ test/fixtures/haskell/corpus/expressions.B.hs | 8 ++ .../haskell/corpus/expressions.diffA-B.txt | 119 +++++++++++------- .../haskell/corpus/expressions.diffB-A.txt | 86 ++++++++++--- .../haskell/corpus/expressions.parseA.txt | 46 +++++++ .../haskell/corpus/expressions.parseB.txt | 46 +++++++ .../haskell/corpus/type-synonyms.diffA-B.txt | 14 +-- .../haskell/corpus/type-synonyms.diffB-A.txt | 34 +++-- 12 files changed, 296 insertions(+), 98 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 151319186..af81a1cd9 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -69,6 +69,7 @@ type Syntax = '[ , Syntax.KindFunctionType , Syntax.KindListType , Syntax.KindSignature + , Syntax.Lambda , Syntax.ListComprehension , Syntax.ListConstructor , Syntax.Module @@ -234,6 +235,7 @@ expressionChoices = [ , integer , kind , kindSignature + , lambda , listConstructor , listComprehension , listExpression @@ -391,6 +393,12 @@ kindListType = makeTerm <$> symbol KindListType <*> children (Syntax.KindListTyp kindSignature :: Assignment kindSignature = makeTerm <$> symbol KindSignature <*> children (Syntax.KindSignature <$ token Annotation <*> kind) +lambda :: Assignment +lambda = makeTerm <$> symbol Lambda <*> children (Syntax.Lambda <$> lambdaHead <*> lambdaBody) + where + lambdaHead = symbol LambdaHead *> children (expressions) + lambdaBody = symbol LambdaBody *> children (expressions) + listComprehension :: Assignment listComprehension = makeTerm <$> symbol ListComprehension <*> children (Syntax.ListComprehension <$> expression <*> manyTerm expression) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 4a628525f..c4b3212c3 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -542,3 +542,12 @@ instance Ord1 Do where liftCompare = genericLiftCompare instance Show1 Do where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Do + +data Lambda a = Lambda { lambdaHead :: a, lambdaBody :: a } + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 Lambda where liftEq = genericLiftEq +instance Ord1 Lambda where liftCompare = genericLiftCompare +instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable Lambda 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 a45e7f33c..576c51f44 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -70,9 +70,6 @@ { (ConstructorIdentifier) ->(ConstructorIdentifier) } (TypeParameters)) - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} (Constructor { (ConstructorIdentifier) ->(ConstructorIdentifier) } @@ -83,6 +80,9 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} 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 2a8638d41..65afcabce 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -70,6 +70,10 @@ { (ConstructorIdentifier) ->(ConstructorIdentifier) } (TypeParameters)) + (Constructor + { (ConstructorIdentifier) + ->(ConstructorIdentifier) } + (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -79,12 +83,6 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} - {-(Constructor - {-(ConstructorIdentifier)-} - {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs index a65b4c81b..c27f67cf8 100644 --- a/test/fixtures/haskell/corpus/expressions.A.hs +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -40,3 +40,11 @@ parseJSON (JSON.Object r) = IncPK <$> f = do a <- b =<< c b <- e >>= g + +f = \ x -> x + +f = \ (Just a) -> a + +f = \ x -> x : a : xs + +f = \ g a b -> g <$> a <*> b diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs index f0128abd0..fd2bff77e 100644 --- a/test/fixtures/haskell/corpus/expressions.B.hs +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -40,3 +40,11 @@ parseJSON (JSON.Object s) = IncPK <$> g = do b <- d =<< e c <- f >>= h + +g = \ x -> x + +g = \ (Just a) -> a + +g = \ x -> x : a : xs + +g = \ g a b -> g <$> a <*> b diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt index 802be0ecf..d41e90860 100644 --- a/test/fixtures/haskell/corpus/expressions.diffA-B.txt +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -239,48 +239,31 @@ ->(VariableIdentifier) } (ConstructorOperator (ConstructorSymbol))))) - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(LeftOperatorSection - {+(VariableIdentifier)+} - {+(ConstructorOperator - {+(ConstructorSymbol)+})+})+})+})+} - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(InfixOperatorApp - {+(VariableIdentifier)+} - {+(VariableOperator - {+(InfixVariableIdentifier)+})+} - {+(VariableIdentifier)+})+})+})+} - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(QualifiedConstructorIdentifier - {+(ModuleIdentifier)+} - {+(ConstructorIdentifier)+})+})+})+} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(LeftOperatorSection - {-(VariableIdentifier)-} - {-(ConstructorOperator - {-(ConstructorSymbol)-})-})-})-})-} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(InfixOperatorApp - {-(VariableIdentifier)-} - {-(VariableOperator - {-(InfixVariableIdentifier)-})-} - {-(VariableIdentifier)-})-})-})-} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(QualifiedConstructorIdentifier - {-(ModuleIdentifier)-} - {-(ConstructorIdentifier)-})-})-})-} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (LeftOperatorSection + { (VariableIdentifier) + ->(VariableIdentifier) } + (ConstructorOperator + (ConstructorSymbol))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (InfixVariableIdentifier)) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (QualifiedConstructorIdentifier + (ModuleIdentifier) + (ConstructorIdentifier)))) (Function (VariableIdentifier) (ConstructorPattern @@ -352,4 +335,54 @@ (VariableOperator (VariableSymbol)) { (VariableIdentifier) - ->(VariableIdentifier) }))))))) + ->(VariableIdentifier) }))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (VariableIdentifier) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (ConstructorPattern + (Statements + (ConstructorIdentifier) + (VariableIdentifier))) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (Statements + (VariableIdentifier) + (VariableIdentifier) + (VariableIdentifier)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier)))))))) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt index 7a3d7fcb3..03eb66329 100644 --- a/test/fixtures/haskell/corpus/expressions.diffB-A.txt +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -239,20 +239,15 @@ ->(VariableIdentifier) } (ConstructorOperator (ConstructorSymbol))))) - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(LeftOperatorSection - {+(VariableIdentifier)+} - {+(ConstructorOperator - {+(ConstructorSymbol)+})+})+})+})+} - {-(Function - {-(VariableIdentifier)-} - {-(Statements - {-(LeftOperatorSection - {-(VariableIdentifier)-} - {-(ConstructorOperator - {-(ConstructorSymbol)-})-})-})-})-} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (LeftOperatorSection + { (VariableIdentifier) + ->(VariableIdentifier) } + (ConstructorOperator + (ConstructorSymbol))))) {-(Function {-(VariableIdentifier)-} {-(Statements @@ -332,12 +327,16 @@ {-(VariableOperator {-(VariableSymbol)-})-} {-(VariableIdentifier)-})-})-})-})) - {+(Function - {+(VariableIdentifier)+} - {+(Statements + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements {+(QualifiedConstructorIdentifier {+(ModuleIdentifier)+} - {+(ConstructorIdentifier)+})+})+})+} + {+(ConstructorIdentifier)+})+} + {-(Lambda + {-(VariableIdentifier)-} + {-(VariableIdentifier)-})-})) {+(Function {+(VariableIdentifier)+} {+(ConstructorPattern @@ -397,4 +396,53 @@ {+(VariableIdentifier)+} {+(VariableOperator {+(VariableSymbol)+})+} - {+(VariableIdentifier)+})+})+})+})+})+})) + {+(VariableIdentifier)+})+})+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(Lambda + {+(VariableIdentifier)+} + {+(VariableIdentifier)+})+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (ConstructorPattern + (Statements + (ConstructorIdentifier) + (VariableIdentifier))) + (VariableIdentifier)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (Statements + (VariableIdentifier) + (VariableIdentifier) + (VariableIdentifier)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier)))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt index 190d3f150..ddcc36a9c 100644 --- a/test/fixtures/haskell/corpus/expressions.parseA.txt +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -275,6 +275,52 @@ (VariableIdentifier))) (BindPattern (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier)))))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (VariableIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (ConstructorPattern + (Statements + (ConstructorIdentifier) + (VariableIdentifier))) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (Statements + (VariableIdentifier) + (VariableIdentifier) + (VariableIdentifier)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) (InfixOperatorApp (VariableIdentifier) (VariableOperator diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt index bd0f68d19..856ec556b 100644 --- a/test/fixtures/haskell/corpus/expressions.parseB.txt +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -277,6 +277,52 @@ (VariableIdentifier))) (BindPattern (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (VariableIdentifier)))))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (VariableIdentifier) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (ConstructorPattern + (Statements + (ConstructorIdentifier) + (VariableIdentifier))) + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (VariableIdentifier) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (InfixOperatorApp + (VariableIdentifier) + (ConstructorOperator + (ConstructorSymbol)) + (VariableIdentifier)))))) + (Function + (VariableIdentifier) + (Statements + (Lambda + (Statements + (VariableIdentifier) + (VariableIdentifier) + (VariableIdentifier)) + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) (InfixOperatorApp (VariableIdentifier) (VariableOperator diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt index bcfd0ab5f..4fff50387 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffA-B.txt @@ -52,17 +52,17 @@ (TypeConstructorIdentifier)) (TypePattern (TupleConstructor))) + (TypeSynonym + (Statements + (TypeConstructorIdentifier)) + (TypePattern + { (FunctionConstructor) + ->(TupleConstructor) })) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+})+} {+(TypePattern - {+(TupleConstructor)+})+})+} - (TypeSynonym - (Statements - { (TypeConstructorIdentifier) - ->(TypeConstructorIdentifier) }) - (TypePattern - (FunctionConstructor))) + {+(FunctionConstructor)+})+})+} (TypeSynonym (Statements (TypeConstructorIdentifier)) diff --git a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt index e098b46e7..d03474db8 100644 --- a/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt +++ b/test/fixtures/haskell/corpus/type-synonyms.diffB-A.txt @@ -52,11 +52,12 @@ (TypeConstructorIdentifier)) (TypePattern (TupleConstructor))) - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+})+} - {+(TypePattern - {+(FunctionConstructor)+})+})+} + (TypeSynonym + (Statements + (TypeConstructorIdentifier)) + (TypePattern + { (TupleConstructor) + ->(FunctionConstructor) })) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+})+} @@ -114,11 +115,14 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+})+})+} {+(Empty)+})+})+})+})+})+} - {+(TypeSynonym - {+(Statements - {+(TypeConstructorIdentifier)+} - {+(TypeConstructorIdentifier)+})+} - {+(TextElement)+})+} + (TypeSynonym + (Statements + { (TypeConstructorIdentifier) + ->(TypeConstructorIdentifier) } + {+(TypeConstructorIdentifier)+}) + { (TypePattern + {-(FunctionConstructor)-}) + ->(TextElement) }) {+(TypeSynonym {+(Statements {+(TypeConstructorIdentifier)+} @@ -167,16 +171,6 @@ {+(TypeConstructorIdentifier)+} {+(TypeVariableIdentifier)+} {+(TypeVariableIdentifier)+})+})+})+})+} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-})-} - {-(TypePattern - {-(TupleConstructor)-})-})-} - {-(TypeSynonym - {-(Statements - {-(TypeConstructorIdentifier)-})-} - {-(TypePattern - {-(FunctionConstructor)-})-})-} {-(TypeSynonym {-(Statements {-(TypeConstructorIdentifier)-})-} From 148ee52a5ff6f9274e1ff8247c55cb92f4f770b4 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 15:01:46 -0700 Subject: [PATCH 19/23] Assign prefix negation and parenthesized expressions --- src/Language/Haskell/Assignment.hs | 9 +++ src/Language/Haskell/Syntax.hs | 12 +++- ...lgebraic-datatype-declarations.diffA-B.txt | 30 ++++---- ...lgebraic-datatype-declarations.diffB-A.txt | 26 ++++--- test/fixtures/haskell/corpus/expressions.A.hs | 6 ++ test/fixtures/haskell/corpus/expressions.B.hs | 6 ++ .../haskell/corpus/expressions.diffA-B.txt | 43 ++++++++++- .../haskell/corpus/expressions.diffB-A.txt | 72 +++++++++++++++---- .../haskell/corpus/expressions.parseA.txt | 30 +++++++- .../haskell/corpus/expressions.parseB.txt | 30 +++++++- 10 files changed, 222 insertions(+), 42 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index af81a1cd9..85d58b346 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -78,6 +78,7 @@ type Syntax = '[ , Syntax.Operator , Syntax.OperatorSection , Syntax.Pragma + , Syntax.PrefixNegation , Syntax.QualifiedEntityIdentifier , Syntax.QualifiedImportDeclaration , Syntax.QuotedName @@ -245,10 +246,12 @@ expressionChoices = [ , newType , operator , operatorSection + , parenthesizedExpression , parenthesizedPattern , parenthesizedTypePattern , pattern , pragma + , prefixNegation , primitiveConstructorIdentifier , primitiveVariableIdentifier , qualifiedConstructorIdentifier @@ -447,6 +450,9 @@ operatorSection = (makeTerm <$> symbol RightOperatorSection <*> children (Syntax packageQualifiedImport :: Assignment packageQualifiedImport = makeTerm <$> symbol PackageQualifiedImport <*> (Literal.TextElement <$> source) +parenthesizedExpression :: Assignment +parenthesizedExpression = symbol ParenthesizedExpression *> children expression + parenthesizedPattern :: Assignment parenthesizedPattern = symbol ParenthesizedPattern *> children expressions @@ -459,6 +465,9 @@ pattern = symbol Pattern *> children (expression) pragma :: Assignment pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) +prefixNegation :: Assignment +prefixNegation = makeTerm <$> symbol PrefixNegation <*> children (Syntax.PrefixNegation <$> expression) + primitiveConstructorIdentifier :: Assignment primitiveConstructorIdentifier = makeTerm <$> symbol PrimitiveConstructorIdentifier <*> (Syntax.PrimitiveConstructorIdentifier . Name.name <$> source) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index c4b3212c3..6c7cdf661 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -524,7 +524,7 @@ instance Show1 ConstructorPattern where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ConstructorPattern --- e.g. `a <- b` in a Haskell do block +-- e.g. `a <- b` in a Haskell do block. data BindPattern a = BindPattern { bindPatternLeft :: a, bindPatternRight :: a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) @@ -551,3 +551,13 @@ instance Ord1 Lambda where liftCompare = genericLiftCompare instance Show1 Lambda where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Lambda + +-- e.g. -1 or (-a) as an expression and not `-` as a variable operator. +newtype PrefixNegation a = PrefixNegation a + deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) + +instance Eq1 PrefixNegation where liftEq = genericLiftEq +instance Ord1 PrefixNegation where liftCompare = genericLiftCompare +instance Show1 PrefixNegation where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable PrefixNegation 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 576c51f44..2eff06678 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffA-B.txt @@ -62,18 +62,6 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} @@ -83,6 +71,24 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} 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 65afcabce..4c7b58dc6 100644 --- a/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt +++ b/test/fixtures/haskell/corpus/algebraic-datatype-declarations.diffB-A.txt @@ -62,14 +62,15 @@ ->(TypeConstructorIdentifier) } (TypeParameters) (Empty)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) - (Constructor - { (ConstructorIdentifier) - ->(ConstructorIdentifier) } - (TypeParameters)) + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} + {+(Constructor + {+(ConstructorIdentifier)+} + {+(TypeParameters)+})+} (Constructor { (ConstructorIdentifier) ->(ConstructorIdentifier) } @@ -80,9 +81,12 @@ {+(Constructor {+(ConstructorIdentifier)+} {+(TypeParameters)+})+} - {+(Constructor - {+(ConstructorIdentifier)+} - {+(TypeParameters)+})+} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} + {-(Constructor + {-(ConstructorIdentifier)-} + {-(TypeParameters)-})-} {-(Constructor {-(ConstructorIdentifier)-} {-(TypeParameters)-})-} diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs index c27f67cf8..ea9013268 100644 --- a/test/fixtures/haskell/corpus/expressions.A.hs +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -48,3 +48,9 @@ f = \ (Just a) -> a f = \ x -> x : a : xs f = \ g a b -> g <$> a <*> b + +f = (-) +f = 1 - 1 +f = (-1) +f = (-a) +f = -(1) diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs index fd2bff77e..e669468d3 100644 --- a/test/fixtures/haskell/corpus/expressions.B.hs +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -48,3 +48,9 @@ g = \ (Just a) -> a g = \ x -> x : a : xs g = \ g a b -> g <$> a <*> b + +g = (-) +g = 1 - 1 +g = (-1) +g = (-a) +g = -(1) diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt index d41e90860..165e5633c 100644 --- a/test/fixtures/haskell/corpus/expressions.diffA-B.txt +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -385,4 +385,45 @@ (VariableIdentifier) (VariableOperator (VariableSymbol)) - (VariableIdentifier)))))))) + (VariableIdentifier)))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (VariableOperator + (VariableSymbol)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (InfixOperatorApp + (Integer) + (VariableOperator + (VariableSymbol)) + (Integer)))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(PrefixNegation + {+(Integer)+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(PrefixNegation + {+(VariableIdentifier)+})+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (PrefixNegation + (Integer)))) + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(PrefixNegation + {-(VariableIdentifier)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(PrefixNegation + {-(Integer)-})-})-})-})) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt index 03eb66329..591ad7c81 100644 --- a/test/fixtures/haskell/corpus/expressions.diffB-A.txt +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -327,16 +327,12 @@ {-(VariableOperator {-(VariableSymbol)-})-} {-(VariableIdentifier)-})-})-})-})) - (Function - { (VariableIdentifier) - ->(VariableIdentifier) } - (Statements + {+(Function + {+(VariableIdentifier)+} + {+(Statements {+(QualifiedConstructorIdentifier {+(ModuleIdentifier)+} - {+(ConstructorIdentifier)+})+} - {-(Lambda - {-(VariableIdentifier)-} - {-(VariableIdentifier)-})-})) + {+(ConstructorIdentifier)+})+})+})+} {+(Function {+(VariableIdentifier)+} {+(ConstructorPattern @@ -397,12 +393,13 @@ {+(VariableOperator {+(VariableSymbol)+})+} {+(VariableIdentifier)+})+})+})+})+})+} - {+(Function - {+(VariableIdentifier)+} - {+(Statements - {+(Lambda - {+(VariableIdentifier)+} - {+(VariableIdentifier)+})+})+})+} + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (Lambda + (VariableIdentifier) + (VariableIdentifier)))) (Function { (VariableIdentifier) ->(VariableIdentifier) } @@ -445,4 +442,49 @@ (VariableIdentifier) (VariableOperator (VariableSymbol)) - (VariableIdentifier)))))))) + (VariableIdentifier)))))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (VariableOperator + (VariableSymbol)))) + (Function + { (VariableIdentifier) + ->(VariableIdentifier) } + (Statements + (InfixOperatorApp + (Integer) + (VariableOperator + (VariableSymbol)) + (Integer)))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(PrefixNegation + {+(Integer)+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(PrefixNegation + {+(VariableIdentifier)+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(PrefixNegation + {+(Integer)+})+})+})+} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(PrefixNegation + {-(Integer)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(PrefixNegation + {-(VariableIdentifier)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(PrefixNegation + {-(Integer)-})-})-})-})) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt index ddcc36a9c..d3b8a8dba 100644 --- a/test/fixtures/haskell/corpus/expressions.parseA.txt +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -325,4 +325,32 @@ (VariableIdentifier) (VariableOperator (VariableSymbol)) - (VariableIdentifier)))))))) + (VariableIdentifier)))))) + (Function + (VariableIdentifier) + (Statements + (VariableOperator + (VariableSymbol)))) + (Function + (VariableIdentifier) + (Statements + (InfixOperatorApp + (Integer) + (VariableOperator + (VariableSymbol)) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (PrefixNegation + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (PrefixNegation + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (PrefixNegation + (Integer)))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt index 856ec556b..5f782308f 100644 --- a/test/fixtures/haskell/corpus/expressions.parseB.txt +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -327,4 +327,32 @@ (VariableIdentifier) (VariableOperator (VariableSymbol)) - (VariableIdentifier)))))))) + (VariableIdentifier)))))) + (Function + (VariableIdentifier) + (Statements + (VariableOperator + (VariableSymbol)))) + (Function + (VariableIdentifier) + (Statements + (InfixOperatorApp + (Integer) + (VariableOperator + (VariableSymbol)) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (PrefixNegation + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (PrefixNegation + (VariableIdentifier)))) + (Function + (VariableIdentifier) + (Statements + (PrefixNegation + (Integer)))))) From 59cd3b55dbc186628d7bdee4f289b56f295a3f03 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 15:07:58 -0700 Subject: [PATCH 20/23] Add additional test cases --- test/fixtures/haskell/corpus/expressions.A.hs | 2 + test/fixtures/haskell/corpus/expressions.B.hs | 2 + .../haskell/corpus/expressions.diffA-B.txt | 52 ++++++++++++++++++- .../haskell/corpus/expressions.diffB-A.txt | 52 ++++++++++++++++++- .../haskell/corpus/expressions.parseA.txt | 27 +++++++++- .../haskell/corpus/expressions.parseB.txt | 27 +++++++++- 6 files changed, 158 insertions(+), 4 deletions(-) diff --git a/test/fixtures/haskell/corpus/expressions.A.hs b/test/fixtures/haskell/corpus/expressions.A.hs index ea9013268..f80538083 100644 --- a/test/fixtures/haskell/corpus/expressions.A.hs +++ b/test/fixtures/haskell/corpus/expressions.A.hs @@ -54,3 +54,5 @@ f = 1 - 1 f = (-1) f = (-a) f = -(1) + +foo = catMaybes $ fmap (\p -> (p,) . Just <$> bar p) waz diff --git a/test/fixtures/haskell/corpus/expressions.B.hs b/test/fixtures/haskell/corpus/expressions.B.hs index e669468d3..8be8ad7f2 100644 --- a/test/fixtures/haskell/corpus/expressions.B.hs +++ b/test/fixtures/haskell/corpus/expressions.B.hs @@ -54,3 +54,5 @@ g = 1 - 1 g = (-1) g = (-a) g = -(1) + +bar = catMaybes $ fmap (\q -> (q,) . Just <$> baz q) waz diff --git a/test/fixtures/haskell/corpus/expressions.diffA-B.txt b/test/fixtures/haskell/corpus/expressions.diffA-B.txt index 165e5633c..8cdc708f5 100644 --- a/test/fixtures/haskell/corpus/expressions.diffA-B.txt +++ b/test/fixtures/haskell/corpus/expressions.diffA-B.txt @@ -417,6 +417,31 @@ (Statements (PrefixNegation (Integer)))) + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(App + {+(App + {+(VariableIdentifier)+} + {+(Lambda + {+(VariableIdentifier)+} + {+(InfixOperatorApp + {+(Tuple + {+(VariableIdentifier)+})+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(ConstructorIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(App + {+(VariableIdentifier)+} + {+(VariableIdentifier)+})+})+})+})+})+} + {+(VariableIdentifier)+})+})+})+})+} {-(Function {-(VariableIdentifier)-} {-(Statements @@ -426,4 +451,29 @@ {-(VariableIdentifier)-} {-(Statements {-(PrefixNegation - {-(Integer)-})-})-})-})) + {-(Integer)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(App + {-(App + {-(VariableIdentifier)-} + {-(Lambda + {-(VariableIdentifier)-} + {-(InfixOperatorApp + {-(Tuple + {-(VariableIdentifier)-})-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(ConstructorIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(App + {-(VariableIdentifier)-} + {-(VariableIdentifier)-})-})-})-})-})-} + {-(VariableIdentifier)-})-})-})-})-})) diff --git a/test/fixtures/haskell/corpus/expressions.diffB-A.txt b/test/fixtures/haskell/corpus/expressions.diffB-A.txt index 591ad7c81..6ba694ba3 100644 --- a/test/fixtures/haskell/corpus/expressions.diffB-A.txt +++ b/test/fixtures/haskell/corpus/expressions.diffB-A.txt @@ -473,6 +473,31 @@ {+(Statements {+(PrefixNegation {+(Integer)+})+})+})+} + {+(Function + {+(VariableIdentifier)+} + {+(Statements + {+(InfixOperatorApp + {+(VariableIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(App + {+(App + {+(VariableIdentifier)+} + {+(Lambda + {+(VariableIdentifier)+} + {+(InfixOperatorApp + {+(Tuple + {+(VariableIdentifier)+})+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(InfixOperatorApp + {+(ConstructorIdentifier)+} + {+(VariableOperator + {+(VariableSymbol)+})+} + {+(App + {+(VariableIdentifier)+} + {+(VariableIdentifier)+})+})+})+})+})+} + {+(VariableIdentifier)+})+})+})+})+} {-(Function {-(VariableIdentifier)-} {-(Statements @@ -487,4 +512,29 @@ {-(VariableIdentifier)-} {-(Statements {-(PrefixNegation - {-(Integer)-})-})-})-})) + {-(Integer)-})-})-})-} + {-(Function + {-(VariableIdentifier)-} + {-(Statements + {-(InfixOperatorApp + {-(VariableIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(App + {-(App + {-(VariableIdentifier)-} + {-(Lambda + {-(VariableIdentifier)-} + {-(InfixOperatorApp + {-(Tuple + {-(VariableIdentifier)-})-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(InfixOperatorApp + {-(ConstructorIdentifier)-} + {-(VariableOperator + {-(VariableSymbol)-})-} + {-(App + {-(VariableIdentifier)-} + {-(VariableIdentifier)-})-})-})-})-})-} + {-(VariableIdentifier)-})-})-})-})-})) diff --git a/test/fixtures/haskell/corpus/expressions.parseA.txt b/test/fixtures/haskell/corpus/expressions.parseA.txt index d3b8a8dba..1cea51c29 100644 --- a/test/fixtures/haskell/corpus/expressions.parseA.txt +++ b/test/fixtures/haskell/corpus/expressions.parseA.txt @@ -353,4 +353,29 @@ (VariableIdentifier) (Statements (PrefixNegation - (Integer)))))) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (App + (App + (VariableIdentifier) + (Lambda + (VariableIdentifier) + (InfixOperatorApp + (Tuple + (VariableIdentifier)) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (ConstructorIdentifier) + (VariableOperator + (VariableSymbol)) + (App + (VariableIdentifier) + (VariableIdentifier)))))) + (VariableIdentifier))))))) diff --git a/test/fixtures/haskell/corpus/expressions.parseB.txt b/test/fixtures/haskell/corpus/expressions.parseB.txt index 5f782308f..fd949667e 100644 --- a/test/fixtures/haskell/corpus/expressions.parseB.txt +++ b/test/fixtures/haskell/corpus/expressions.parseB.txt @@ -355,4 +355,29 @@ (VariableIdentifier) (Statements (PrefixNegation - (Integer)))))) + (Integer)))) + (Function + (VariableIdentifier) + (Statements + (InfixOperatorApp + (VariableIdentifier) + (VariableOperator + (VariableSymbol)) + (App + (App + (VariableIdentifier) + (Lambda + (VariableIdentifier) + (InfixOperatorApp + (Tuple + (VariableIdentifier)) + (VariableOperator + (VariableSymbol)) + (InfixOperatorApp + (ConstructorIdentifier) + (VariableOperator + (VariableSymbol)) + (App + (VariableIdentifier) + (VariableIdentifier)))))) + (VariableIdentifier))))))) From a2f6f7089dcd99eb01c443989edae742d3d0e4b0 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 15:17:54 -0700 Subject: [PATCH 21/23] Use newtype instead of data --- src/Language/Haskell/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 6c7cdf661..af81a458f 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -135,7 +135,7 @@ instance Show1 Context' where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Context' -data Class a = Class { classContent :: [a] } +newtype Class a = Class { classContent :: [a] } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Mergeable, Ord, Show, ToJSONFields1, Traversable) instance Eq1 Class where liftEq = genericLiftEq From f009658ddc94584b99d3adf26ca74a5f4a44801b Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 15:43:28 -0700 Subject: [PATCH 22/23] Rename to avoid confusion with pattern synonyms --- src/Language/Haskell/Assignment.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index 85d58b346..b3b6dfb9c 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -249,7 +249,7 @@ expressionChoices = [ , parenthesizedExpression , parenthesizedPattern , parenthesizedTypePattern - , pattern + , pattern' , pragma , prefixNegation , primitiveConstructorIdentifier @@ -459,8 +459,8 @@ parenthesizedPattern = symbol ParenthesizedPattern *> children expressions parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children expressions -pattern :: Assignment -pattern = symbol Pattern *> children (expression) +pattern' :: Assignment +pattern' = symbol Pattern *> children (expression) pragma :: Assignment pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) From 266d3500cc3b2fd01286ce39068859d617a5617f Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 12 Jun 2018 15:55:53 -0700 Subject: [PATCH 23/23] .khanify hlint --- src/Language/Haskell/Assignment.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Language/Haskell/Assignment.hs b/src/Language/Haskell/Assignment.hs index b3b6dfb9c..4cb861e69 100644 --- a/src/Language/Haskell/Assignment.hs +++ b/src/Language/Haskell/Assignment.hs @@ -171,7 +171,7 @@ context' :: Assignment context' = makeTerm <$> symbol Context <*> children (Syntax.Context' <$> expressions) contextPattern :: Assignment -contextPattern = symbol ContextPattern *> children (expressions) +contextPattern = symbol ContextPattern *> children expressions defaultDeclaration :: Assignment defaultDeclaration = makeTerm <$> symbol DefaultDeclaration <*> children (Syntax.DefaultDeclaration <$> manyTerm expression) @@ -192,7 +192,7 @@ export :: Assignment export = makeTerm <$> symbol Export <*> children (Syntax.Export <$> expressions) expression' :: Assignment -expression' = symbol Expression *> children (expression) +expression' = symbol Expression *> children expression expressions :: Assignment expressions = makeTerm'' <$> location <*> manyTerm expression @@ -399,8 +399,8 @@ kindSignature = makeTerm <$> symbol KindSignature <*> children (Syntax.KindSigna lambda :: Assignment lambda = makeTerm <$> symbol Lambda <*> children (Syntax.Lambda <$> lambdaHead <*> lambdaBody) where - lambdaHead = symbol LambdaHead *> children (expressions) - lambdaBody = symbol LambdaBody *> children (expressions) + lambdaHead = symbol LambdaHead *> children expressions + lambdaBody = symbol LambdaBody *> children expressions listComprehension :: Assignment listComprehension = makeTerm <$> symbol ListComprehension <*> children (Syntax.ListComprehension <$> expression <*> manyTerm expression) @@ -460,7 +460,7 @@ parenthesizedTypePattern :: Assignment parenthesizedTypePattern = symbol ParenthesizedTypePattern *> children expressions pattern' :: Assignment -pattern' = symbol Pattern *> children (expression) +pattern' = symbol Pattern *> children expression pragma :: Assignment pragma = makeTerm <$> symbol Pragma <*> (Syntax.Pragma <$> source) @@ -506,7 +506,7 @@ scopedTypeVariables = makeTerm <$> symbol ScopedTypeVariables <*> children (Synt standaloneDerivingInstance :: Assignment standaloneDerivingInstance = makeTerm <$> symbol StandaloneDerivingDeclaration <*> children (Syntax.StandaloneDerivingInstance <$> manyTerm (context' <|> scopedTypeVariables) <*> expression <*> instance') where - instance' = symbol Instance *> children (expressions) + instance' = symbol Instance *> children expressions star :: Assignment star = makeTerm <$> token Star <*> pure Syntax.Star