diff options
author | Richard Eisenberg <eir@cis.upenn.edu> | 2013-06-21 13:58:24 +0100 |
---|---|---|
committer | Richard Eisenberg <eir@cis.upenn.edu> | 2013-06-21 13:58:24 +0100 |
commit | c30744cc4fcd3a048dab246058f4f6831f38d798 (patch) | |
tree | 6d4d0b1f5134e1a8a23af75c0bbc2d6fa90427f2 | |
parent | a26bf928d274f57c7c0c95df23c769244e90633e (diff) | |
download | haskell-c30744cc4fcd3a048dab246058f4f6831f38d798.tar.gz |
Updates to support closed type families.
54 files changed, 240 insertions, 319 deletions
diff --git a/testsuite/tests/ghci/scripts/T4175.hs b/testsuite/tests/ghci/scripts/T4175.hs index 69ff79fd94..a3b1d273f5 100644 --- a/testsuite/tests/ghci/scripts/T4175.hs +++ b/testsuite/tests/ghci/scripts/T4175.hs @@ -17,8 +17,6 @@ instance C Int where instance C () where type D () () = Bool -type family E a - -type instance where +type family E a where E () = Bool E Int = String
\ No newline at end of file diff --git a/testsuite/tests/ghci/scripts/T4175.stdout b/testsuite/tests/ghci/scripts/T4175.stdout index bfbfc87765..553d92a0ab 100644 --- a/testsuite/tests/ghci/scripts/T4175.stdout +++ b/testsuite/tests/ghci/scripts/T4175.stdout @@ -1,52 +1,46 @@ -type family A a b :: * -- Defined at T4175.hs:4:13
-type instance A (Maybe a) a -- Defined at T4175.hs:6:15
-type instance A Int Int -- Defined at T4175.hs:5:15
-data family B a -- Defined at T4175.hs:8:13
-data instance B () -- Defined at T4175.hs:9:15
-class C a where
- type family D a b :: *
- -- Defined at T4175.hs:12:10
-type D () () -- Defined at T4175.hs:18:10
-type D Int () -- Defined at T4175.hs:15:10
-type family E a :: * -- Defined at T4175.hs:20:13
-type instance where
- E () -- Defined at T4175.hs:23:5
- E Int -- Defined at T4175.hs:24:5
-data () = () -- Defined in ‛GHC.Tuple’
-instance C () -- Defined at T4175.hs:17:10
-instance Bounded () -- Defined in ‛GHC.Enum’
-instance Enum () -- Defined in ‛GHC.Enum’
-instance Eq () -- Defined in ‛GHC.Classes’
-instance Ord () -- Defined in ‛GHC.Classes’
-instance Read () -- Defined in ‛GHC.Read’
-instance Show () -- Defined in ‛GHC.Show’
-type instance where
- E () -- Defined at T4175.hs:23:5
- E Int -- Defined at T4175.hs:24:5
-type D () () -- Defined at T4175.hs:18:10
-type D Int () -- Defined at T4175.hs:15:10
-data instance B () -- Defined at T4175.hs:9:15
-data Maybe a = Nothing | Just a -- Defined in ‛Data.Maybe’
-instance Eq a => Eq (Maybe a) -- Defined in ‛Data.Maybe’
-instance Monad Maybe -- Defined in ‛Data.Maybe’
-instance Functor Maybe -- Defined in ‛Data.Maybe’
-instance Ord a => Ord (Maybe a) -- Defined in ‛Data.Maybe’
-instance Read a => Read (Maybe a) -- Defined in ‛GHC.Read’
-instance Show a => Show (Maybe a) -- Defined in ‛GHC.Show’
-type instance A (Maybe a) a -- Defined at T4175.hs:6:15
-data Int = GHC.Types.I# GHC.Prim.Int# -- Defined in ‛GHC.Types’
-instance C Int -- Defined at T4175.hs:14:10
-instance Bounded Int -- Defined in ‛GHC.Enum’
-instance Enum Int -- Defined in ‛GHC.Enum’
-instance Eq Int -- Defined in ‛GHC.Classes’
-instance Integral Int -- Defined in ‛GHC.Real’
-instance Num Int -- Defined in ‛GHC.Num’
-instance Ord Int -- Defined in ‛GHC.Classes’
-instance Read Int -- Defined in ‛GHC.Read’
-instance Real Int -- Defined in ‛GHC.Real’
-instance Show Int -- Defined in ‛GHC.Show’
-type instance where
- E () -- Defined at T4175.hs:23:5
- E Int -- Defined at T4175.hs:24:5
-type D Int () -- Defined at T4175.hs:15:10
-type instance A Int Int -- Defined at T4175.hs:5:15
+type family A a b :: * -- Defined at T4175.hs:4:13 +type instance A (Maybe a) a -- Defined at T4175.hs:6:1 +type instance A Int Int -- Defined at T4175.hs:5:1 +data family B a -- Defined at T4175.hs:8:13 +data instance B () -- Defined at T4175.hs:9:15 +class C a where + type family D a b :: * + -- Defined at T4175.hs:12:10 +type D () () -- Defined at T4175.hs:18:5 +type D Int () -- Defined at T4175.hs:15:5 +type family E a :: * where + E () = Bool + E Int = String + -- Defined at T4175.hs:20:13 +data () = () -- Defined in ‛GHC.Tuple’ +instance C () -- Defined at T4175.hs:17:10 +instance Bounded () -- Defined in ‛GHC.Enum’ +instance Enum () -- Defined in ‛GHC.Enum’ +instance Eq () -- Defined in ‛GHC.Classes’ +instance Ord () -- Defined in ‛GHC.Classes’ +instance Read () -- Defined in ‛GHC.Read’ +instance Show () -- Defined in ‛GHC.Show’ +type D () () -- Defined at T4175.hs:18:5 +type D Int () -- Defined at T4175.hs:15:5 +data instance B () -- Defined at T4175.hs:9:15 +data Maybe a = Nothing | Just a -- Defined in ‛Data.Maybe’ +instance Eq a => Eq (Maybe a) -- Defined in ‛Data.Maybe’ +instance Monad Maybe -- Defined in ‛Data.Maybe’ +instance Functor Maybe -- Defined in ‛Data.Maybe’ +instance Ord a => Ord (Maybe a) -- Defined in ‛Data.Maybe’ +instance Read a => Read (Maybe a) -- Defined in ‛GHC.Read’ +instance Show a => Show (Maybe a) -- Defined in ‛GHC.Show’ +type instance A (Maybe a) a -- Defined at T4175.hs:6:1 +data Int = GHC.Types.I# GHC.Prim.Int# -- Defined in ‛GHC.Types’ +instance C Int -- Defined at T4175.hs:14:10 +instance Bounded Int -- Defined in ‛GHC.Enum’ +instance Enum Int -- Defined in ‛GHC.Enum’ +instance Eq Int -- Defined in ‛GHC.Classes’ +instance Integral Int -- Defined in ‛GHC.Real’ +instance Num Int -- Defined in ‛GHC.Num’ +instance Ord Int -- Defined in ‛GHC.Classes’ +instance Read Int -- Defined in ‛GHC.Read’ +instance Real Int -- Defined in ‛GHC.Real’ +instance Show Int -- Defined in ‛GHC.Show’ +type D Int () -- Defined at T4175.hs:15:5 +type instance A Int Int -- Defined at T4175.hs:5:1 diff --git a/testsuite/tests/indexed-types/should_compile/Overlap1.hs b/testsuite/tests/indexed-types/should_compile/Overlap1.hs index b285deece1..4ee3776f59 100644 --- a/testsuite/tests/indexed-types/should_compile/Overlap1.hs +++ b/testsuite/tests/indexed-types/should_compile/Overlap1.hs @@ -2,8 +2,7 @@ module Overlap1 where -type family F a -type instance where +type family F a where F Int = Int F a = Bool diff --git a/testsuite/tests/indexed-types/should_compile/Overlap12.hs b/testsuite/tests/indexed-types/should_compile/Overlap12.hs index 414c9d9f03..6fe1bd981c 100644 --- a/testsuite/tests/indexed-types/should_compile/Overlap12.hs +++ b/testsuite/tests/indexed-types/should_compile/Overlap12.hs @@ -2,8 +2,7 @@ module Overlap12 where -type family And (a :: Bool) (b :: Bool) :: Bool -type instance where +type family And (a :: Bool) (b :: Bool) :: Bool where And False x = False And True x = x And x False = False @@ -12,5 +11,17 @@ type instance where data Proxy p = P -i :: Proxy (And False x) -i = (P :: Proxy False)
\ No newline at end of file +a :: Proxy (And False x) +a = (P :: Proxy False) + +b :: Proxy x -> Proxy (And True x) +b x = x + +c :: Proxy (And x False) +c = (P :: Proxy False) + +d :: Proxy x -> Proxy (And x True) +d x = x + +e :: Proxy x -> Proxy (And x x) +e x = x diff --git a/testsuite/tests/indexed-types/should_compile/Overlap13.hs b/testsuite/tests/indexed-types/should_compile/Overlap13.hs new file mode 100644 index 0000000000..56fc78e3a1 --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/Overlap13.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TypeFamilies #-} + +module Overlap13 where + +type family F a b where + F a a = Int + F a Int = Int + F a b = b + +g :: a -> F a Int +g x = (5 :: Int) + + + + diff --git a/testsuite/tests/indexed-types/should_compile/Overlap14.hs b/testsuite/tests/indexed-types/should_compile/Overlap14.hs new file mode 100644 index 0000000000..49af37c8bd --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/Overlap14.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TypeFamilies #-} + +module Overlap14 where + +type family F a b c where + F a a a = Int + F Int b c = Bool + +type family G x + +foo :: F Int (G Bool) Bool +foo = False diff --git a/testsuite/tests/indexed-types/should_compile/Overlap2.hs b/testsuite/tests/indexed-types/should_compile/Overlap2.hs index ced2dd4292..3a4da42c00 100644 --- a/testsuite/tests/indexed-types/should_compile/Overlap2.hs +++ b/testsuite/tests/indexed-types/should_compile/Overlap2.hs @@ -2,8 +2,7 @@ module Overlap2 where -type family F a b -type instance where +type family F a b where F a a = Int F a b = Bool diff --git a/testsuite/tests/indexed-types/should_compile/T3017.stderr b/testsuite/tests/indexed-types/should_compile/T3017.stderr index a6b44e3ad5..5c6a2641c7 100644 --- a/testsuite/tests/indexed-types/should_compile/T3017.stderr +++ b/testsuite/tests/indexed-types/should_compile/T3017.stderr @@ -1,24 +1,24 @@ -TYPE SIGNATURES
- emptyL :: forall a. ListColl a
- test2 ::
- forall c t t1. (Num t, Num t1, Coll c, Elem c ~ (t, t1)) => c -> c
-TYPE CONSTRUCTORS
- Coll :: * -> Constraint
- class Coll c
- RecFlag NonRecursive
- type family Elem c :: *
- empty :: c insert :: Elem c -> c -> c
- ListColl :: * -> *
- data ListColl a
- No C type associated
- RecFlag NonRecursive, Promotable
- = L :: forall a. [a] -> ListColl a Stricts: _
- FamilyInstance: none
-COERCION AXIOMS
- axiom Foo.TFCo:R:ElemListColl :: Elem (ListColl a) = a
-INSTANCES
- instance Coll (ListColl a) -- Defined at T3017.hs:12:11
-FAMILY INSTANCES
- type Elem (ListColl a) -- Defined at T3017.hs:13:9
-Dependent modules: []
-Dependent packages: [base, ghc-prim, integer-gmp]
+TYPE SIGNATURES + emptyL :: forall a. ListColl a + test2 :: + forall c t t1. (Num t, Num t1, Coll c, Elem c ~ (t, t1)) => c -> c +TYPE CONSTRUCTORS + Coll :: * -> Constraint + class Coll c + RecFlag NonRecursive + type family Elem c :: * + empty :: c insert :: Elem c -> c -> c + ListColl :: * -> * + data ListColl a + No C type associated + RecFlag NonRecursive, Promotable + = L :: forall a. [a] -> ListColl a Stricts: _ + FamilyInstance: none +COERCION AXIOMS + axiom Foo.TFCo:R:ElemListColl :: Elem (ListColl a) = a +INSTANCES + instance Coll (ListColl a) -- Defined at T3017.hs:12:11 +FAMILY INSTANCES + type Elem (ListColl a) -- Defined at T3017.hs:13:4 +Dependent modules: [] +Dependent packages: [base, ghc-prim, integer-gmp] diff --git a/testsuite/tests/indexed-types/should_compile/T7585.hs b/testsuite/tests/indexed-types/should_compile/T7585.hs index 475269c851..93a85b6b6f 100644 --- a/testsuite/tests/indexed-types/should_compile/T7585.hs +++ b/testsuite/tests/indexed-types/should_compile/T7585.hs @@ -11,8 +11,7 @@ data SList :: [Bool] -> * where SNil :: SList '[] SCons :: SBool h -> SList t -> SList (h ': t) -type family (a :: k) :==: (b :: k) :: Bool -type instance where +type family (a :: k) :==: (b :: k) :: Bool where '[] :==: '[] = True (h1 ': t1) :==: (h2 ': t2) = True a :==: b = False diff --git a/testsuite/tests/indexed-types/should_compile/all.T b/testsuite/tests/indexed-types/should_compile/all.T index ac3a5f866d..419008cc88 100644 --- a/testsuite/tests/indexed-types/should_compile/all.T +++ b/testsuite/tests/indexed-types/should_compile/all.T @@ -200,6 +200,8 @@ test('T7082', normal, compile, ['']) test('Overlap1', normal, compile, ['']) test('Overlap2', normal, compile, ['']) test('Overlap12', normal, compile, ['']) +test('Overlap13', normal, compile, ['']) +test('Overlap14', normal, compile, ['']) test('T7156', normal, compile, ['']) test('T5591a', normal, compile, ['']) test('T5591b', normal, compile, ['']) diff --git a/testsuite/tests/indexed-types/should_fail/NoGood.hs b/testsuite/tests/indexed-types/should_fail/NoGood.hs new file mode 100644 index 0000000000..43a237b0ff --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/NoGood.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeFamilies #-} + +type family F a b +type instance F a a = Int +type instance F [a] a = Bool diff --git a/testsuite/tests/indexed-types/should_fail/NoGood.stderr b/testsuite/tests/indexed-types/should_fail/NoGood.stderr new file mode 100644 index 0000000000..bfb5814f8d --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/NoGood.stderr @@ -0,0 +1,5 @@ + +NoGood.hs:4:15: + Conflicting family instance declarations: + F a a -- Defined at NoGood.hs:4:15 + F [a] a -- Defined at NoGood.hs:5:15 diff --git a/testsuite/tests/indexed-types/should_fail/Overlap10.hs b/testsuite/tests/indexed-types/should_fail/Overlap10.hs index 07a13e0219..c99839bc93 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap10.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap10.hs @@ -2,8 +2,7 @@ module Overlap10 where -type family F a b -type instance where +type family F a b where F a a = Int F a b = b diff --git a/testsuite/tests/indexed-types/should_fail/Overlap10.stderr b/testsuite/tests/indexed-types/should_fail/Overlap10.stderr index 342cbe4bca..b31de8d757 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap10.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap10.stderr @@ -1,8 +1,8 @@ -Overlap10.hs:11:7: +Overlap10.hs:10:7: Couldn't match expected type ‛F a Bool’ with actual type ‛Bool’ Relevant bindings include - g :: a -> F a Bool (bound at Overlap10.hs:11:1) - x :: a (bound at Overlap10.hs:11:3) + g :: a -> F a Bool (bound at Overlap10.hs:10:1) + x :: a (bound at Overlap10.hs:10:3) In the expression: False In an equation for ‛g’: g x = False diff --git a/testsuite/tests/indexed-types/should_fail/Overlap11.hs b/testsuite/tests/indexed-types/should_fail/Overlap11.hs index 1498d5946a..79b0ecba60 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap11.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap11.hs @@ -2,8 +2,7 @@ module Overlap11 where -type family F a b -type instance where +type family F a b where F a a = Int F a b = b diff --git a/testsuite/tests/indexed-types/should_fail/Overlap11.stderr b/testsuite/tests/indexed-types/should_fail/Overlap11.stderr index 476ae6c2fb..97627e7939 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap11.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap11.stderr @@ -1,8 +1,8 @@ -Overlap11.hs:11:8: +Overlap11.hs:10:8: Couldn't match expected type ‛F a Int’ with actual type ‛Int’ Relevant bindings include - g :: a -> F a Int (bound at Overlap11.hs:11:1) - x :: a (bound at Overlap11.hs:11:3) + g :: a -> F a Int (bound at Overlap11.hs:10:1) + x :: a (bound at Overlap11.hs:10:3) In the expression: (5 :: Int) In an equation for ‛g’: g x = (5 :: Int) diff --git a/testsuite/tests/indexed-types/should_fail/Overlap3.hs b/testsuite/tests/indexed-types/should_fail/Overlap3.hs index 654d626904..82837d9193 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap3.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap3.hs @@ -2,8 +2,7 @@ module Overlap3 where -type family F a b -type instance where +type family F a b where F a a = Int F a b = Bool type instance F Char Char = Int diff --git a/testsuite/tests/indexed-types/should_fail/Overlap3.stderr b/testsuite/tests/indexed-types/should_fail/Overlap3.stderr index 7226058e12..c8d1b5ef80 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap3.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap3.stderr @@ -1,10 +1,4 @@ -Overlap3.hs:7:3: - Conflicting family instance declarations: - F a a -- Defined at Overlap3.hs:7:3 - F Char Char -- Defined at Overlap3.hs:9:15 - -Overlap3.hs:8:3: - Conflicting family instance declarations: - F a b -- Defined at Overlap3.hs:8:3 - F Char Char -- Defined at Overlap3.hs:9:15 +Overlap3.hs:8:1: + Illegal instance for closed family ‛F’ + In the type instance declaration for ‛F’ diff --git a/testsuite/tests/indexed-types/should_fail/Overlap4.hs b/testsuite/tests/indexed-types/should_fail/Overlap4.hs index 4f1b872b9e..3399c614b8 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap4.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap4.hs @@ -2,15 +2,7 @@ module Overlap4 where -type family F a b -type instance F Char Char = Int -type instance where - F a a = Int - F a b = Bool +type family F a b where + F Int Int = Bool + F Bool = Maybe - -g :: F Char Double -g = False - -h :: F Double Double -h = -2 diff --git a/testsuite/tests/indexed-types/should_fail/Overlap4.stderr b/testsuite/tests/indexed-types/should_fail/Overlap4.stderr index fd97e97481..fd545b6334 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap4.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap4.stderr @@ -1,5 +1,5 @@ -Overlap4.hs:6:15: - Conflicting family instance declarations: - F Char Char -- Defined at Overlap4.hs:6:15 - F a a -- Defined at Overlap4.hs:8:3 +Overlap4.hs:7:3: + Number of parameters must match family declaration; expected 2 + In the equations for closed type family ‛F’ + In the family declaration for ‛F’ diff --git a/testsuite/tests/indexed-types/should_fail/Overlap5.hs b/testsuite/tests/indexed-types/should_fail/Overlap5.hs index fbf05d4f4e..6338de1844 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap5.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap5.hs @@ -1,22 +1,9 @@ -{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} module Overlap5 where -type family And (a :: Bool) (b :: Bool) :: Bool -type instance where - And False x = False - And True x = x - And x False = False - And x True = x - And x x = x - -data Proxy p = P - -g :: Proxy x -> Proxy (And x True) -g x = x - -h :: Proxy x -> Proxy (And x x) -h x = x - -i :: Proxy x -> Proxy (And False x) -i x = (P :: Proxy False)
\ No newline at end of file +type family G a +type family F a where + F Int = Bool + G Int = Char + F a = Int
\ No newline at end of file diff --git a/testsuite/tests/indexed-types/should_fail/Overlap5.stderr b/testsuite/tests/indexed-types/should_fail/Overlap5.stderr index 0413002ab5..201dc416c1 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap5.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap5.stderr @@ -1,29 +1,5 @@ -Overlap5.hs:16:7: - Couldn't match type ‛x’ with ‛And x 'True’ - ‛x’ is a rigid type variable bound by - the type signature for - g :: Proxy Bool x -> Proxy Bool (And x 'True) - at Overlap5.hs:15:6 - Expected type: Proxy Bool (And x 'True) - Actual type: Proxy Bool x - Relevant bindings include - g :: Proxy Bool x -> Proxy Bool (And x 'True) - (bound at Overlap5.hs:16:1) - x :: Proxy Bool x (bound at Overlap5.hs:16:3) - In the expression: x - In an equation for ‛g’: g x = x - -Overlap5.hs:19:7: - Couldn't match type ‛x’ with ‛And x x’ - ‛x’ is a rigid type variable bound by - the type signature for h :: Proxy Bool x -> Proxy Bool (And x x) - at Overlap5.hs:18:6 - Expected type: Proxy Bool (And x x) - Actual type: Proxy Bool x - Relevant bindings include - h :: Proxy Bool x -> Proxy Bool (And x x) - (bound at Overlap5.hs:19:1) - x :: Proxy Bool x (bound at Overlap5.hs:19:3) - In the expression: x - In an equation for ‛h’: h x = x +Overlap5.hs:8:3: + Mismatched type names in closed type family declaration. + First name was F; this one is G + In the family declaration for ‛F’ diff --git a/testsuite/tests/indexed-types/should_fail/Overlap6.hs b/testsuite/tests/indexed-types/should_fail/Overlap6.hs index c97992e65f..a6fc9e7836 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap6.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap6.hs @@ -2,8 +2,7 @@ module Overlap6 where -type family And (a :: Bool) (b :: Bool) :: Bool -type instance where +type family And (a :: Bool) (b :: Bool) :: Bool where And False x = False And True x = False -- this is wrong! And x False = False diff --git a/testsuite/tests/indexed-types/should_fail/Overlap6.stderr b/testsuite/tests/indexed-types/should_fail/Overlap6.stderr index c59a1ab72d..ce0a64f8b2 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap6.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap6.stderr @@ -1,15 +1,15 @@ -Overlap6.hs:16:7: +Overlap6.hs:15:7: Couldn't match type ‛x’ with ‛And x 'True’ ‛x’ is a rigid type variable bound by the type signature for g :: Proxy Bool x -> Proxy Bool (And x 'True) - at Overlap6.hs:15:6 + at Overlap6.hs:14:6 Expected type: Proxy Bool (And x 'True) Actual type: Proxy Bool x Relevant bindings include g :: Proxy Bool x -> Proxy Bool (And x 'True) - (bound at Overlap6.hs:16:1) - x :: Proxy Bool x (bound at Overlap6.hs:16:3) + (bound at Overlap6.hs:15:1) + x :: Proxy Bool x (bound at Overlap6.hs:15:3) In the expression: x In an equation for ‛g’: g x = x diff --git a/testsuite/tests/indexed-types/should_fail/Overlap7.hs b/testsuite/tests/indexed-types/should_fail/Overlap7.hs index 352103c4c0..a6988f4e34 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap7.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap7.hs @@ -2,8 +2,7 @@ module Overlap7 where -type family F a b -type instance where +type family F a b where F Int a = Int F a b = Bool type instance F a Int = Int diff --git a/testsuite/tests/indexed-types/should_fail/Overlap7.stderr b/testsuite/tests/indexed-types/should_fail/Overlap7.stderr index a87186eec9..2858f792b2 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap7.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap7.stderr @@ -1,10 +1,4 @@ -Overlap7.hs:7:3: - Conflicting family instance declarations: - F Int a -- Defined at Overlap7.hs:7:3 - F a Int -- Defined at Overlap7.hs:9:15 - -Overlap7.hs:8:3: - Conflicting family instance declarations: - F a b -- Defined at Overlap7.hs:8:3 - F a Int -- Defined at Overlap7.hs:9:15 +Overlap7.hs:8:1: + Illegal instance for closed family ‛F’ + In the type instance declaration for ‛F’ diff --git a/testsuite/tests/indexed-types/should_fail/Overlap8.hs b/testsuite/tests/indexed-types/should_fail/Overlap8.hs deleted file mode 100644 index b998d26614..0000000000 --- a/testsuite/tests/indexed-types/should_fail/Overlap8.hs +++ /dev/null @@ -1,11 +0,0 @@ -{-# LANGUAGE TypeFamilies #-} - -module Overlap8 where - -type family F a b -type instance F a Int = Int -type instance where - F Int a = Int - F a b = Bool - - diff --git a/testsuite/tests/indexed-types/should_fail/Overlap8.stderr b/testsuite/tests/indexed-types/should_fail/Overlap8.stderr deleted file mode 100644 index 9443a4636f..0000000000 --- a/testsuite/tests/indexed-types/should_fail/Overlap8.stderr +++ /dev/null @@ -1,5 +0,0 @@ - -Overlap8.hs:6:15: - Conflicting family instance declarations: - F a Int -- Defined at Overlap8.hs:6:15 - F Int a -- Defined at Overlap8.hs:8:3 diff --git a/testsuite/tests/indexed-types/should_fail/Overlap9.hs b/testsuite/tests/indexed-types/should_fail/Overlap9.hs index 61d1dff72f..19e1c989f1 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap9.hs +++ b/testsuite/tests/indexed-types/should_fail/Overlap9.hs @@ -2,8 +2,7 @@ module Overlap9 where -type family F a -type instance where +type family F a where F Int = Bool F a = Int diff --git a/testsuite/tests/indexed-types/should_fail/Overlap9.stderr b/testsuite/tests/indexed-types/should_fail/Overlap9.stderr index a0a6ea8ee6..9f9f102cc1 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap9.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap9.stderr @@ -1,11 +1,11 @@ -Overlap9.hs:11:7: +Overlap9.hs:10:7: Could not deduce (F a ~ Int) from the context (Show a) bound by the type signature for g :: Show a => a -> F a - at Overlap9.hs:10:6-23 + at Overlap9.hs:9:6-23 Relevant bindings include - g :: a -> F a (bound at Overlap9.hs:11:1) - x :: a (bound at Overlap9.hs:11:3) + g :: a -> F a (bound at Overlap9.hs:10:1) + x :: a (bound at Overlap9.hs:10:3) In the expression: length (show x) In an equation for ‛g’: g x = length (show x) diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail1a.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail1a.stderr index 7108a5ba73..2e7b982a6b 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail1a.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail1a.stderr @@ -1,4 +1,4 @@ SimpleFail1a.hs:4:1: - Number of parameters must match family declaration; expected 2 + Couldn't match kind ‛* -> *’ against ‛*’ In the data instance declaration for ‛T1’ diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail1b.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail1b.stderr index a65a50d2c2..8a3f5dfbcd 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail1b.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail1b.stderr @@ -1,4 +1,4 @@ SimpleFail1b.hs:4:1: - Number of parameters must match family declaration; expected 2 + Number of parameters must match family declaration; expected no more than 2 In the data instance declaration for ‛T1’ diff --git a/testsuite/tests/indexed-types/should_fail/T5515.stderr b/testsuite/tests/indexed-types/should_fail/T5515.stderr index c3d6b9f664..f8056f0dd9 100644 --- a/testsuite/tests/indexed-types/should_fail/T5515.stderr +++ b/testsuite/tests/indexed-types/should_fail/T5515.stderr @@ -1,8 +1,8 @@ -T5515.hs:9:8: +T5515.hs:9:3: The RHS of an associated type declaration mentions type variable ‛a’ All such variables must be bound on the LHS -T5515.hs:15:8: +T5515.hs:15:3: The RHS of an associated type declaration mentions type variable ‛a’ All such variables must be bound on the LHS diff --git a/testsuite/tests/indexed-types/should_fail/T7560.hs b/testsuite/tests/indexed-types/should_fail/T7560.hs deleted file mode 100644 index 0176c5a408..0000000000 --- a/testsuite/tests/indexed-types/should_fail/T7560.hs +++ /dev/null @@ -1,13 +0,0 @@ -{-# LANGUAGE TypeFamilies #-} - -module T7560 where - -type family F a - -type instance where - F Int = Int - F Bool = Bool - -type instance where - F Int = Char - F Double = Double
\ No newline at end of file diff --git a/testsuite/tests/indexed-types/should_fail/T7560.stderr b/testsuite/tests/indexed-types/should_fail/T7560.stderr deleted file mode 100644 index e382fb3d78..0000000000 --- a/testsuite/tests/indexed-types/should_fail/T7560.stderr +++ /dev/null @@ -1,5 +0,0 @@ - -T7560.hs:8:3: - Conflicting family instance declarations: - F Int -- Defined at T7560.hs:8:3 - F Int -- Defined at T7560.hs:12:3 diff --git a/testsuite/tests/indexed-types/should_fail/T7786.hs b/testsuite/tests/indexed-types/should_fail/T7786.hs index f2d119ba10..59c5fecab8 100644 --- a/testsuite/tests/indexed-types/should_fail/T7786.hs +++ b/testsuite/tests/indexed-types/should_fail/T7786.hs @@ -50,8 +50,7 @@ buryUnder (ps `Snoc` p) post acc = (ps `buryUnder` post) acc `Snoc` (p `under` p type key `KeyNotIn` inv = Intersect (More Empty key) inv ~ Empty type (lhs `UnderDisjoint` post) rhs = Intersect ((lhs `BuriedUnder` post) Empty) rhs ~ Empty -type family Intersect (l :: Inventory a) (r :: Inventory a) :: Inventory a -type instance where +type family Intersect (l :: Inventory a) (r :: Inventory a) :: Inventory a where Intersect Empty r = Empty Intersect l Empty = Empty Intersect (More ls l) r = InterAppend (Intersect ls r) r l @@ -59,8 +58,7 @@ type instance where type family InterAppend (l :: Inventory a) (r :: Inventory a) (one :: a) - :: Inventory a -type instance where + :: Inventory a where InterAppend acc Empty one = acc InterAppend acc (More rs one) one = More acc one InterAppend acc (More rs r) one = InterAppend acc rs one @@ -68,8 +66,7 @@ type instance where type family BuriedUnder (sub :: Inventory [KeySegment]) (post :: [KeySegment]) (inv :: Inventory [KeySegment]) - :: Inventory [KeySegment] -type instance where + :: Inventory [KeySegment] where BuriedUnder Empty post inv = inv BuriedUnder (More ps p) post inv = More ((ps `BuriedUnder` post) inv) (p `Under` post) diff --git a/testsuite/tests/indexed-types/should_fail/T7786.stderr b/testsuite/tests/indexed-types/should_fail/T7786.stderr index 359c84fe71..85a1be23d5 100644 --- a/testsuite/tests/indexed-types/should_fail/T7786.stderr +++ b/testsuite/tests/indexed-types/should_fail/T7786.stderr @@ -1,5 +1,5 @@ -T7786.hs:89:22: +T7786.hs:86:22: Couldn't match type ‛xxx’ with ‛'Empty [KeySegment]’ Inaccessible code in a pattern with constructor diff --git a/testsuite/tests/indexed-types/should_fail/all.T b/testsuite/tests/indexed-types/should_fail/all.T index da6d4a1950..ed0e070879 100644 --- a/testsuite/tests/indexed-types/should_fail/all.T +++ b/testsuite/tests/indexed-types/should_fail/all.T @@ -82,7 +82,6 @@ test('Overlap4', normal, compile_fail, ['']) test('Overlap5', normal, compile_fail, ['']) test('Overlap6', normal, compile_fail, ['']) test('Overlap7', normal, compile_fail, ['']) -test('Overlap8', normal, compile_fail, ['']) test('Overlap9', normal, compile_fail, ['']) test('Overlap10', normal, compile_fail, ['']) test('Overlap11', normal, compile_fail, ['']) @@ -94,8 +93,10 @@ test('T7354a', ['$MAKE -s --no-print-directory T7354a']) test('T7536', normal, compile_fail, ['']) -test('T7560', normal, compile_fail, ['']) test('T7729', normal, compile_fail, ['']) test('T7729a', normal, compile_fail, ['']) test('T7786', normal, compile_fail, ['']) + +test('NoGood', normal, compile_fail, ['']) test('T7967', normal, compile_fail, ['']) + diff --git a/testsuite/tests/th/ClosedFam1.hs b/testsuite/tests/th/ClosedFam1.hs new file mode 100644 index 0000000000..262e9a1e48 --- /dev/null +++ b/testsuite/tests/th/ClosedFam1.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE TemplateHaskell, TypeFamilies, PolyKinds, DataKinds #-} + +module ClosedFam1 where + +import Language.Haskell.TH + +$(do { decl <- [d| type family Foo a (b :: k) where + Foo Int Bool = Int + Foo a Maybe = Bool + Foo b (x :: Bool) = Char |] + ; reportWarning (pprint decl) + ; return [] }) + diff --git a/testsuite/tests/th/ClosedFam1.stderr b/testsuite/tests/th/ClosedFam1.stderr new file mode 100644 index 0000000000..d9827d8afb --- /dev/null +++ b/testsuite/tests/th/ClosedFam1.stderr @@ -0,0 +1,6 @@ + +ClosedFam1.hs:7:3: Warning: + type family Foo_0 a_1 (b_2 :: k_3) where + Foo_0 GHC.Types.Int GHC.Types.Bool = GHC.Types.Int + Foo_0 a_4 Data.Maybe.Maybe = GHC.Types.Bool + Foo_0 b_5 (x_6 :: GHC.Types.Bool) = GHC.Types.Char diff --git a/testsuite/tests/th/ClosedFam2.hs b/testsuite/tests/th/ClosedFam2.hs new file mode 100644 index 0000000000..cd2dc2de60 --- /dev/null +++ b/testsuite/tests/th/ClosedFam2.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE TemplateHaskell, TypeFamilies, PolyKinds #-} + +module ClosedFam2 where + +import Language.Haskell.TH + +$( return [ ClosedTypeFamilyD (mkName "Equals") + [ KindedTV (mkName "a") (VarT (mkName "k")) + , KindedTV (mkName "b") (VarT (mkName "k")) ] + Nothing + [ TySynEqn [ (VarT (mkName "a")) + , (VarT (mkName "a")) ] + (ConT (mkName "Int")) + , TySynEqn [ (VarT (mkName "a")) + , (VarT (mkName "b")) ] + (ConT (mkName "Bool")) ] ]) + +a :: Equals b b +a = (5 :: Int) + +b :: Equals Int Bool +b = False diff --git a/testsuite/tests/th/T5886a.hs b/testsuite/tests/th/T5886a.hs index 74db6fa192..4d2cec6207 100644 --- a/testsuite/tests/th/T5886a.hs +++ b/testsuite/tests/th/T5886a.hs @@ -11,4 +11,4 @@ class C α where bang ∷ DecsQ bang = return [InstanceD [] (AppT (ConT ''C) (ConT ''Int)) - [TySynInstD ''AT [TySynEqn [ConT ''Int] (ConT ''Int)]]] + [TySynInstD ''AT (TySynEqn [ConT ''Int] (ConT ''Int))]] diff --git a/testsuite/tests/th/TH_TyInstWhere1.hs b/testsuite/tests/th/TH_TyInstWhere1.hs index 8352d4bf01..d8c07d7642 100644 --- a/testsuite/tests/th/TH_TyInstWhere1.hs +++ b/testsuite/tests/th/TH_TyInstWhere1.hs @@ -2,9 +2,7 @@ module TH_TyInstWhere1 where -type family F (a :: k) (b :: k) :: Bool - -$([d| type instance where +$([d| type family F (a :: k) (b :: k) :: Bool where F a a = True F a b = False |]) diff --git a/testsuite/tests/th/TH_TyInstWhere1.stderr b/testsuite/tests/th/TH_TyInstWhere1.stderr index 480e5bf4f7..5a830aa792 100644 --- a/testsuite/tests/th/TH_TyInstWhere1.stderr +++ b/testsuite/tests/th/TH_TyInstWhere1.stderr @@ -1,9 +1,9 @@ TH_TyInstWhere1.hs:1:1: Splicing declarations - [d| type instance where + [d| type family F (a :: k) (b :: k) :: Bool where F a a = True F a b = False |] ======> - TH_TyInstWhere1.hs:(7,3)-(9,24) - type instance where + TH_TyInstWhere1.hs:(5,3)-(7,24) + type family F (a :: k) (b :: k) :: Bool where F a a = True F a b = False diff --git a/testsuite/tests/th/TH_TyInstWhere2.hs b/testsuite/tests/th/TH_TyInstWhere2.hs index ec27ced780..47fedad8da 100644 --- a/testsuite/tests/th/TH_TyInstWhere2.hs +++ b/testsuite/tests/th/TH_TyInstWhere2.hs @@ -4,9 +4,7 @@ module TH_TyInstWhere2 where import Language.Haskell.TH -type family F (a :: k) (b :: k) :: Bool - -$( do { decs <- [d| type instance where +$( do { decs <- [d| type family F (a :: k) (b :: k) :: Bool where F a a = True F a b = False |] ; reportWarning (pprint decs) diff --git a/testsuite/tests/th/TH_TyInstWhere2.stderr b/testsuite/tests/th/TH_TyInstWhere2.stderr index 4ed490e8ea..17caf61bad 100644 --- a/testsuite/tests/th/TH_TyInstWhere2.stderr +++ b/testsuite/tests/th/TH_TyInstWhere2.stderr @@ -1,5 +1,5 @@ -TH_TyInstWhere2.hs:9:4: Warning: - type instance where - TH_TyInstWhere2.F a_0 a_0 = 'GHC.Types.True - TH_TyInstWhere2.F a_1 b_2 = 'GHC.Types.False +TH_TyInstWhere2.hs:7:4: Warning: + type family F_0 (a_1 :: k_2) (b_3 :: k_2) :: GHC.Types.Bool where + F_0 a_4 a_4 = 'GHC.Types.True + F_0 a_5 b_6 = 'GHC.Types.False diff --git a/testsuite/tests/th/TH_TyInstWhere3.hs b/testsuite/tests/th/TH_TyInstWhere3.hs deleted file mode 100644 index 54d76f5226..0000000000 --- a/testsuite/tests/th/TH_TyInstWhere3.hs +++ /dev/null @@ -1,18 +0,0 @@ -{-# LANGUAGE PolyKinds, DataKinds, TemplateHaskell, TypeFamilies #-} - -module TH_TyInstWhere3 where - -import Language.Haskell.TH - -type family F a - -$( do { decs <- [d| type instance where - F Int = Int |] - ; reportWarning (pprint decs) - ; return decs }) - -type instance F a = a - --- When this test was written, TH considered all singleton type family instance --- as unbranched. Thus, even though the two instances above would not play nicely --- without TH, they should be fine with TH. diff --git a/testsuite/tests/th/TH_TyInstWhere3.stderr b/testsuite/tests/th/TH_TyInstWhere3.stderr deleted file mode 100644 index eaebfec89f..0000000000 --- a/testsuite/tests/th/TH_TyInstWhere3.stderr +++ /dev/null @@ -1,3 +0,0 @@ - -TH_TyInstWhere3.hs:9:4: Warning: - type instance TH_TyInstWhere3.F GHC.Types.Int = GHC.Types.Int diff --git a/testsuite/tests/th/TH_TyInstWhere4.hs b/testsuite/tests/th/TH_TyInstWhere4.hs deleted file mode 100644 index 86415ffd5d..0000000000 --- a/testsuite/tests/th/TH_TyInstWhere4.hs +++ /dev/null @@ -1,20 +0,0 @@ -{-# LANGUAGE PolyKinds, DataKinds, TemplateHaskell, TypeFamilies #-} - -module TH_TyInstWhere4 where - -import Language.Haskell.TH - -type family F a b :: Bool -type instance where - F a a = True - F a b = False - -$( do { info1 <- reify ''F - ; reportWarning (pprint info1) - ; info2 <- reifyInstances ''F [ConT ''Int, ConT ''Int] - ; reportWarning (pprint info2) - ; info3 <- reifyInstances ''F [ConT ''Int, ConT ''Bool] - ; reportWarning (pprint info3) - ; return [] }) - - diff --git a/testsuite/tests/th/TH_TyInstWhere4.stderr b/testsuite/tests/th/TH_TyInstWhere4.stderr deleted file mode 100644 index 70dfe85b7a..0000000000 --- a/testsuite/tests/th/TH_TyInstWhere4.stderr +++ /dev/null @@ -1,16 +0,0 @@ - -TH_TyInstWhere4.hs:12:4: Warning: - type family TH_TyInstWhere4.F a_0 b_1 :: * -> * -> GHC.Types.Bool -type instance where - TH_TyInstWhere4.F a_2 a_2 = GHC.Types.True - TH_TyInstWhere4.F a_3 b_4 = GHC.Types.False - -TH_TyInstWhere4.hs:12:4: Warning: - type instance where - TH_TyInstWhere4.F a_0 a_0 = GHC.Types.True - TH_TyInstWhere4.F a_1 b_2 = GHC.Types.False - -TH_TyInstWhere4.hs:12:4: Warning: - type instance where - TH_TyInstWhere4.F a_0 a_0 = GHC.Types.True - TH_TyInstWhere4.F a_1 b_2 = GHC.Types.False diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index ad1c4e9782..c6407c462e 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -261,8 +261,6 @@ test('T7276a', combined_output, ghci_script, ['T7276a.script']) test('TH_TyInstWhere1', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('TH_TyInstWhere2', normal, compile, ['-v0']) -test('TH_TyInstWhere3', normal, compile, ['-v0']) -test('TH_TyInstWhere4', normal, compile, ['-v0']) test('T7445', extra_clean(['T7445a.hi', 'T7445a.o']), run_command, @@ -275,3 +273,6 @@ test('T2222', normal, compile, ['-v0']) test('T1849', normal, ghci_script, ['T1849.script']) test('T7681', normal, compile, ['-v0']) test('T7910', normal, compile_and_run, ['-v0']) + +test('ClosedFam1', normal, compile, ['-dsuppress-uniques -v0']) +test('ClosedFam2', normal, compile, ['-v0'])
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_compile/T5481.stderr b/testsuite/tests/typecheck/should_compile/T5481.stderr index 931c3e0420..bf59427da6 100644 --- a/testsuite/tests/typecheck/should_compile/T5481.stderr +++ b/testsuite/tests/typecheck/should_compile/T5481.stderr @@ -1,8 +1,8 @@ -T5481.hs:6:10: +T5481.hs:6:5: The RHS of an associated type declaration mentions type variable ‛b’ All such variables must be bound on the LHS -T5481.hs:8:10: +T5481.hs:8:5: The RHS of an associated type declaration mentions type variable ‛a’ All such variables must be bound on the LHS diff --git a/testsuite/tests/typecheck/should_fail/AssocTyDef05.stderr b/testsuite/tests/typecheck/should_fail/AssocTyDef05.stderr index 401251e36a..5d003e9a42 100644 --- a/testsuite/tests/typecheck/should_fail/AssocTyDef05.stderr +++ b/testsuite/tests/typecheck/should_fail/AssocTyDef05.stderr @@ -1,5 +1,5 @@ AssocTyDef05.hs:6:10: Number of parameters must match family declaration; expected 1 - In the type instance declaration for ‛Typ’ + In the type synonym instance default declaration for ‛Typ’ In the class declaration for ‛Cls’ diff --git a/testsuite/tests/typecheck/should_fail/AssocTyDef06.stderr b/testsuite/tests/typecheck/should_fail/AssocTyDef06.stderr index 91e92bdcae..fb7f91033c 100644 --- a/testsuite/tests/typecheck/should_fail/AssocTyDef06.stderr +++ b/testsuite/tests/typecheck/should_fail/AssocTyDef06.stderr @@ -1,5 +1,5 @@ AssocTyDef06.hs:6:10: - Number of parameters must match family declaration; expected 1 + Number of parameters must match family declaration; expected no more than 1 In the type instance declaration for ‛Typ’ In the class declaration for ‛Cls’ |