diff options
Diffstat (limited to 'testsuite/tests/saks')
119 files changed, 1085 insertions, 0 deletions
diff --git a/testsuite/tests/saks/should_compile/T16721.script b/testsuite/tests/saks/should_compile/T16721.script new file mode 100644 index 0000000000..1e747be98e --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16721.script @@ -0,0 +1,4 @@ +:set -XStandaloneKindSignatures -XNoStarIsType +import Data.Kind (Type) +type T :: (Type -> Type) -> Type; data T a +:info T diff --git a/testsuite/tests/saks/should_compile/T16721.stdout b/testsuite/tests/saks/should_compile/T16721.stdout new file mode 100644 index 0000000000..8dce9caa1a --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16721.stdout @@ -0,0 +1,4 @@ +type role T phantom +type T :: (Type -> Type) -> Type +data T a + -- Defined at <interactive>:3:35 diff --git a/testsuite/tests/saks/should_compile/T16723.hs b/testsuite/tests/saks/should_compile/T16723.hs new file mode 100644 index 0000000000..2ba216a93d --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16723.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T16723 where + +import Data.Kind + +type D :: forall a. Type +data D diff --git a/testsuite/tests/saks/should_compile/T16724.hs b/testsuite/tests/saks/should_compile/T16724.hs new file mode 100644 index 0000000000..3ab5d0761a --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16724.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +module T16724 where + +import Data.Kind + +type T1 :: forall k (a :: k). Type +type family T1 + +-- type T2 :: forall {k} (a :: k). Type +type T2 :: forall a. Type +type family T2 diff --git a/testsuite/tests/saks/should_compile/T16724.script b/testsuite/tests/saks/should_compile/T16724.script new file mode 100644 index 0000000000..f5681b86ca --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16724.script @@ -0,0 +1,5 @@ +:set -fprint-explicit-kinds -fprint-explicit-foralls -XNoStarIsType +:load T16724.hs +:info T1 +:info T2 + -- must have the same arity! diff --git a/testsuite/tests/saks/should_compile/T16724.stdout b/testsuite/tests/saks/should_compile/T16724.stdout new file mode 100644 index 0000000000..099371c58d --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16724.stdout @@ -0,0 +1,6 @@ +type T1 :: forall k (a :: k). Type +type family T1 @k @a + -- Defined at T16724.hs:11:1 +type T2 :: forall {k} (a :: k). Type +type family T2 @{k} @a + -- Defined at T16724.hs:15:1 diff --git a/testsuite/tests/saks/should_compile/T16726.hs b/testsuite/tests/saks/should_compile/T16726.hs new file mode 100644 index 0000000000..e1a748d0a0 --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16726.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +module T16726 where + +import Data.Kind + +type D :: forall k. k -> Type +data D :: forall j. j -> Type + +type DF :: forall k. k -> Type +data family DF :: forall j. j -> Type + +type T :: forall k. k -> Type +type family T :: forall j. j -> Type diff --git a/testsuite/tests/saks/should_compile/T16731.hs b/testsuite/tests/saks/should_compile/T16731.hs new file mode 100644 index 0000000000..c2051f678d --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16731.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T16731 where + +import Data.Kind + +class C (a :: Type) (b :: Type) + +type T :: forall a. a -> Type +data T (x :: z) deriving (C z) diff --git a/testsuite/tests/saks/should_compile/T16756a.hs b/testsuite/tests/saks/should_compile/T16756a.hs new file mode 100644 index 0000000000..f85c2ecbc9 --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16756a.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} + +module T16756a where + +import Data.Kind (Type) + +type T :: Type -> Type +data family T + -- We do /not/ need to write: + -- data family T a + -- See https://gitlab.haskell.org/ghc/ghc/issues/16756#note_203567 diff --git a/testsuite/tests/saks/should_compile/T16758.hs b/testsuite/tests/saks/should_compile/T16758.hs new file mode 100644 index 0000000000..2798156f3c --- /dev/null +++ b/testsuite/tests/saks/should_compile/T16758.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ConstrainedClassMethods #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ExplicitForAll #-} + +module T16758 where + +import Data.Kind + +type C :: forall (a :: Type) -> a ~ Int => Constraint +class C a where + f :: C a => a -> Int diff --git a/testsuite/tests/saks/should_compile/T17164.hs b/testsuite/tests/saks/should_compile/T17164.hs new file mode 100644 index 0000000000..0f9d9e440f --- /dev/null +++ b/testsuite/tests/saks/should_compile/T17164.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -ddump-splices #-} + +module T17164 where + +import Data.Kind + +$([d| type T :: forall k -> k -> Type + type family T :: forall k -> k -> Type + |]) diff --git a/testsuite/tests/saks/should_compile/T17164.stderr b/testsuite/tests/saks/should_compile/T17164.stderr new file mode 100644 index 0000000000..5b1fdbf0fc --- /dev/null +++ b/testsuite/tests/saks/should_compile/T17164.stderr @@ -0,0 +1,7 @@ +T17164.hs:(12,3)-(14,6): Splicing declarations + [d| type T :: forall k -> k -> Type + + type family T :: forall k -> k -> Type |] + ======> + type T :: forall k -> k -> Type + type family T :: forall k -> k -> Type diff --git a/testsuite/tests/saks/should_compile/all.T b/testsuite/tests/saks/should_compile/all.T new file mode 100644 index 0000000000..73f608c6dd --- /dev/null +++ b/testsuite/tests/saks/should_compile/all.T @@ -0,0 +1,49 @@ +setTestOpts(normalise_version('base','ghc-prim')) + +test('saks001', normal, compile, ['']) +test('saks002', normal, compile, ['']) +test('saks003', normal, compile, ['']) +test('saks004', normal, compile, ['']) +test('saks005', normal, compile, ['']) +test('saks006', normal, compile, ['']) +test('saks007', normal, compile, ['']) +test('saks008', normal, compile, ['']) +test('saks009', normal, compile, ['']) +test('saks010', normal, compile, ['']) +test('saks014', normal, compile, ['']) +test('saks015', normal, compile, ['']) +test('saks016', normal, compile, ['']) +test('saks017', normal, compile, ['']) +test('saks018', normal, compile, ['']) +test('saks019', normal, compile, ['']) +test('saks020', normal, compile, ['']) +test('saks021', normal, compile, ['']) +test('saks023', normal, ghci_script, ['saks023.script']) +test('saks024', normal, compile, ['']) +test('saks025', extra_files(['saks025.hs']), ghci_script, ['saks025.script']) +test('saks026', normal, compile, ['']) +test('saks029', normal, compile, ['']) +test('saks030', normal, compile, ['']) +test('saks031', normal, compile, ['']) +test('saks032', normal, compile, ['']) +test('saks033', normal, compile, ['']) +test('saks034', extra_files(['saks034.hs']), ghci_script, ['saks034.script']) +test('saks035', extra_files(['saks035.hs']), ghci_script, ['saks035.script']) +test('saks036', normal, compile, ['']) +test('T16723', normal, compile, ['']) +test('T16724', extra_files(['T16724.hs']), ghci_script, ['T16724.script']) +test('T16726', normal, compile, ['']) +test('T16731', normal, compile, ['']) +test('T16758', expect_broken(16758), compile, ['']) +test('T16721', normal, ghci_script, ['T16721.script']) +test('T16756a', normal, compile, ['']) + +# We omit 'profasm' because it fails with: +# Cannot load -prof objects when GHC is built with -dynamic +# To fix this, either: +# (1) Use -fexternal-interpreter, or +# (2) Build the program twice: once with -dynamic, and then +# with -prof using -osuf to set a different object file suffix. +test('saks027', omit_ways(['profasm']), compile, ['-v0 -ddump-splices -dsuppress-uniques']) +test('saks028', omit_ways(['profasm']), compile, ['']) +test('T17164', omit_ways(['profasm']), compile, ['-v0 -ddump-splices -dsuppress-uniques']) diff --git a/testsuite/tests/saks/should_compile/saks001.hs b/testsuite/tests/saks/should_compile/saks001.hs new file mode 100644 index 0000000000..425a992adb --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks001.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_001 where + +import Data.Kind (Type) + +type MonoTagged :: Type -> Type -> Type +data MonoTagged t x = MonoTagged x diff --git a/testsuite/tests/saks/should_compile/saks002.hs b/testsuite/tests/saks/should_compile/saks002.hs new file mode 100644 index 0000000000..3dcf49deda --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks002.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, PolyKinds, ExplicitForAll #-} + +module SAKS_002 where + +type Id :: forall k. k -> k +type family Id x where + Id x = x diff --git a/testsuite/tests/saks/should_compile/saks003.hs b/testsuite/tests/saks/should_compile/saks003.hs new file mode 100644 index 0000000000..778862c918 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks003.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilyDependencies, PolyKinds, ExplicitForAll #-} + +module SAKS_003 where + +type InjectiveId :: forall k. k -> k +type family InjectiveId x = r | r -> x where + InjectiveId x = x diff --git a/testsuite/tests/saks/should_compile/saks004.hs b/testsuite/tests/saks/should_compile/saks004.hs new file mode 100644 index 0000000000..1a4cdbafd3 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks004.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE MultiParamTypeClasses, PolyKinds, ConstraintKinds #-} + +module SAKS_004 where + +import Data.Kind (Type, Constraint) + +type C :: (k -> Type) -> k -> Constraint +class C a b where + f :: a b diff --git a/testsuite/tests/saks/should_compile/saks005.hs b/testsuite/tests/saks/should_compile/saks005.hs new file mode 100644 index 0000000000..ed85eca41d --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks005.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE GADTs, PolyKinds, ExplicitForAll #-} + +module SAKS_005 where + +import Data.Kind (Type, Constraint) + +type TypeRep :: forall k. k -> Type +data TypeRep a where + TyInt :: TypeRep Int + TyMaybe :: TypeRep Maybe + TyApp :: TypeRep a -> TypeRep b -> TypeRep (a b) diff --git a/testsuite/tests/saks/should_compile/saks006.hs b/testsuite/tests/saks/should_compile/saks006.hs new file mode 100644 index 0000000000..99e6b3aa5c --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks006.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-} +{-# LANGUAGE TypeFamilies, PolyKinds, ConstraintKinds #-} + +module SAKS_006 where + +import Data.Kind (Type, Constraint) + +type C :: (k -> Type) -> k -> Constraint +type T :: k -> Type + +class C a b +data T a + +-- type D :: j -> Constraint -- #16571 +type D :: Type -> Constraint +type D = C T + +-- type DF :: j -> Constraint -- #16571 +type DF :: Type -> Constraint +type family DF where + DF = C T diff --git a/testsuite/tests/saks/should_compile/saks007.hs b/testsuite/tests/saks/should_compile/saks007.hs new file mode 100644 index 0000000000..7f6869576b --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks007.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, GADTs, PolyKinds, DataKinds, ExplicitForAll #-} + +-- See also: saks007_fail.hs +module SAKS_007 where + +import Data.Kind (Type, Constraint) + +type family F a where { F Type = True; F _ = False } +type family G a where { G Type = False; G _ = True } + +type X :: forall k1 k2. (F k1 ~ G k2) => k1 -> k2 -> Type +data X a b where + MkX :: X Integer Maybe -- OK: F Type ~ G (Type -> Type) + -- True ~ True diff --git a/testsuite/tests/saks/should_compile/saks008.hs b/testsuite/tests/saks/should_compile/saks008.hs new file mode 100644 index 0000000000..ce7a8646d0 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks008.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds #-} + +module SAKS_008 where + +import Data.Proxy (Proxy) +import Data.Kind (Type) + +-- Test inferred type variables. +-- T :: forall {k} (a :: k). Proxy a -> Type +type T :: Proxy a -> Type +data T x = MkT diff --git a/testsuite/tests/saks/should_compile/saks009.hs b/testsuite/tests/saks/should_compile/saks009.hs new file mode 100644 index 0000000000..f2cccdddfd --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks009.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ExplicitForAll, PolyKinds #-} + +module SAKS_009 where + +import Data.Kind (Type) + +type Q :: forall k -> k -> Type +data Q j (a :: j) diff --git a/testsuite/tests/saks/should_compile/saks010.hs b/testsuite/tests/saks/should_compile/saks010.hs new file mode 100644 index 0000000000..20dd2413b0 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks010.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE RankNTypes, PolyKinds, DataKinds #-} + +module SAKS_010 where + +import Data.Kind (Type) + +type W :: forall (a :: forall k. k -> Type) -> a Int -> a Maybe -> Type +data W x (y :: x Int) (z :: x Maybe) diff --git a/testsuite/tests/saks/should_compile/saks014.hs b/testsuite/tests/saks/should_compile/saks014.hs new file mode 100644 index 0000000000..6e0f4a56f6 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks014.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds #-} + +module SAKS_014 where + +import Data.Kind (Type) + +type T :: (k -> Type) -> (k -> Type) +data T m a = MkT (m a) (T Maybe (m a)) diff --git a/testsuite/tests/saks/should_compile/saks015.hs b/testsuite/tests/saks/should_compile/saks015.hs new file mode 100644 index 0000000000..a8cf7204f1 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks015.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} + +module SAKS_015 where + +import Data.Kind (Type) + +type T :: forall k -> k -> Type +data T (k :: Type) (a :: k) diff --git a/testsuite/tests/saks/should_compile/saks016.hs b/testsuite/tests/saks/should_compile/saks016.hs new file mode 100644 index 0000000000..dca8ce7700 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks016.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, RankNTypes #-} + +module SAKS_016 where + +import Data.Kind (Type) + +type T :: forall k. k -> forall j. j -> Type +data T (x :: hk) (y :: hj) diff --git a/testsuite/tests/saks/should_compile/saks017.hs b/testsuite/tests/saks/should_compile/saks017.hs new file mode 100644 index 0000000000..3b69b27d7f --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks017.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, ExplicitForAll #-} + +module SAKS_017 where + +import Data.Kind (Type) + +type family F a where + F Bool = Type + F (f a) = F a + +type family G a where + G Int = Type + +data family T :: F (Maybe Bool) -> t +data instance T (a :: G Int) = MkT a diff --git a/testsuite/tests/saks/should_compile/saks018.hs b/testsuite/tests/saks/should_compile/saks018.hs new file mode 100644 index 0000000000..a24a19e117 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks018.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} + +module SAKS_018 where + +import Data.Kind (Type) + +type T :: forall k -> k -> Type +data T k (x :: hk) diff --git a/testsuite/tests/saks/should_compile/saks019.hs b/testsuite/tests/saks/should_compile/saks019.hs new file mode 100644 index 0000000000..6e97db5c49 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks019.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE DataKinds, PolyKinds, ExplicitForAll #-} + +module SAKS_019 where + +import Data.Kind (Type) + +data P (a :: k) + +type T :: forall a. P a -> Type +data T (y :: P (b :: j)) diff --git a/testsuite/tests/saks/should_compile/saks020.hs b/testsuite/tests/saks/should_compile/saks020.hs new file mode 100644 index 0000000000..93cd4b734c --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks020.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, RankNTypes #-} + +module SAKS_020 where + +import Data.Kind (Type) + +type T :: forall k. k -> forall j. j -> Type +data T (x :: hk) :: hj -> Type diff --git a/testsuite/tests/saks/should_compile/saks021.hs b/testsuite/tests/saks/should_compile/saks021.hs new file mode 100644 index 0000000000..00bf9f8918 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks021.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} + +module SAKS_021 where + +import Data.Kind (Type) + +type T :: forall k -> forall (xx :: k) -> Type +data T k (x :: hk) diff --git a/testsuite/tests/saks/should_compile/saks023.script b/testsuite/tests/saks/should_compile/saks023.script new file mode 100644 index 0000000000..06d85eb38b --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks023.script @@ -0,0 +1,5 @@ +:set -XStandaloneKindSignatures -XExplicitForAll -XPolyKinds -XNoStarIsType +import Data.Kind (Type) +type T :: forall (x :: Type) -> Type; data T a +:kind T + -- must output forall x, not forall a! diff --git a/testsuite/tests/saks/should_compile/saks023.stdout b/testsuite/tests/saks/should_compile/saks023.stdout new file mode 100644 index 0000000000..051268aa78 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks023.stdout @@ -0,0 +1 @@ +T :: forall x -> Type diff --git a/testsuite/tests/saks/should_compile/saks024.hs b/testsuite/tests/saks/should_compile/saks024.hs new file mode 100644 index 0000000000..b58f49da5d --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks024.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, TypeFamilies #-} + +module SAKS_024 where + +import Data.Kind + +data P (a :: k) = MkP + +type C :: i -> Constraint +class C (p :: j) where + type F :: j + +f :: P k -> P (F :: k) +f _ = MkP diff --git a/testsuite/tests/saks/should_compile/saks025.hs b/testsuite/tests/saks/should_compile/saks025.hs new file mode 100644 index 0000000000..dc51abd3f1 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks025.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds #-} + +module SAKS_025 where + +import Data.Kind + +data P (a :: k) = MkP + +type C :: j -> Constraint +class C a where + type T a b (c :: P p) diff --git a/testsuite/tests/saks/should_compile/saks025.script b/testsuite/tests/saks/should_compile/saks025.script new file mode 100644 index 0000000000..e19353e46d --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks025.script @@ -0,0 +1,3 @@ +:set -XNoStarIsType +:load saks025.hs +:kind T diff --git a/testsuite/tests/saks/should_compile/saks025.stdout b/testsuite/tests/saks/should_compile/saks025.stdout new file mode 100644 index 0000000000..3eb0cd7c30 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks025.stdout @@ -0,0 +1 @@ +T :: forall k j (p :: k). j -> Type -> P p -> Type diff --git a/testsuite/tests/saks/should_compile/saks026.hs b/testsuite/tests/saks/should_compile/saks026.hs new file mode 100644 index 0000000000..a8a3967a0d --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks026.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE RankNTypes, DataKinds, PolyKinds, GADTs, TypeFamilies #-} + +module SAKS_026 where + +import Data.Kind + +data HigherRank (f :: forall x. x -> Type) + +data P :: forall k. k -> Type + +type PSyn :: forall k. k -> Type +type PSyn = (P :: forall k. k -> Type) + +type Test = HigherRank PSyn diff --git a/testsuite/tests/saks/should_compile/saks027.hs b/testsuite/tests/saks/should_compile/saks027.hs new file mode 100644 index 0000000000..736def1d68 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks027.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TemplateHaskell #-} + +module SAKS_027 where + +import Data.Kind + +$([d| type U :: Type + data U = MkU + |]) diff --git a/testsuite/tests/saks/should_compile/saks027.stderr b/testsuite/tests/saks/should_compile/saks027.stderr new file mode 100644 index 0000000000..730b1cfde6 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks027.stderr @@ -0,0 +1,7 @@ +saks027.hs:(8,3)-(10,6): Splicing declarations + [d| type U :: Type + + data U = MkU |] + ======> + type U :: Type + data U = MkU diff --git a/testsuite/tests/saks/should_compile/saks028.hs b/testsuite/tests/saks/should_compile/saks028.hs new file mode 100644 index 0000000000..9d15db593c --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks028.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TemplateHaskell #-} + +module SAKS_028 where + +import Data.Kind +import Language.Haskell.TH hiding (Type) + +type Functor' :: (Type -> Type) -> Constraint +class Functor' f + +do sig <- reifyType ('' Functor') + runIO $ putStrLn $ pprint sig + return [] diff --git a/testsuite/tests/saks/should_compile/saks028.stderr b/testsuite/tests/saks/should_compile/saks028.stderr new file mode 100644 index 0000000000..92ed23779c --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks028.stderr @@ -0,0 +1 @@ +(* -> *) -> Constraint diff --git a/testsuite/tests/saks/should_compile/saks029.hs b/testsuite/tests/saks/should_compile/saks029.hs new file mode 100644 index 0000000000..ca2f28bce9 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks029.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds, RankNTypes, TypeFamilies #-} + +module SAKS_029 where + +import Data.Kind +import Data.Proxy +import Data.Type.Bool + +type IfK :: forall j m n. forall (e :: Proxy (j :: Bool)) -> m -> n -> If j m n +type family IfK e f g where + IfK (_ :: Proxy True) f _ = f + IfK (_ :: Proxy False) _ g = g diff --git a/testsuite/tests/saks/should_compile/saks030.hs b/testsuite/tests/saks/should_compile/saks030.hs new file mode 100644 index 0000000000..93e414fbed --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks030.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds, RankNTypes, TypeFamilies, + TypeApplications, TypeOperators, GADTs #-} + +module SAKS_030 where + +import Data.Kind +import Data.Type.Equality + +type T1 :: forall k (a :: k). Bool +type T2 :: k -> Bool + +type family T1 where + T1 @Bool @True = False + T1 @Bool @False = True + +type family T2 a where + T2 True = False + T2 False = True + +type SBool :: Bool -> Type +data SBool b where + STrue :: SBool True + SFalse :: SBool False + +proof_t1_eq_t2 :: SBool b -> T1 @Bool @b :~: T2 b +proof_t1_eq_t2 STrue = Refl +proof_t1_eq_t2 SFalse = Refl diff --git a/testsuite/tests/saks/should_compile/saks031.hs b/testsuite/tests/saks/should_compile/saks031.hs new file mode 100644 index 0000000000..a737d6ddc7 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks031.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE UnliftedNewtypes #-} +{-# LANGUAGE PolyKinds, DataKinds, TypeFamilies, MagicHash #-} + +module SAKS_031 where + +import Data.Kind +import GHC.Exts + +type T1 :: Type -> TYPE 'IntRep +data family T1 + +newtype instance T1 a = MkT1 Int# + +type T2 :: TYPE IntRep +newtype T2 = MkT2 Int# diff --git a/testsuite/tests/saks/should_compile/saks032.hs b/testsuite/tests/saks/should_compile/saks032.hs new file mode 100644 index 0000000000..612c66d8fc --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks032.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds, TypeFamilies, RankNTypes #-} + +module SAKS_032 where + +import Data.Kind +import Data.Proxy + +type Const :: Type -> forall k. k -> Type +data Const a b = Const a + +type F :: Type -> Type -> forall k. k -> Type +type family F a b :: forall k. k -> Type where + F () () = Proxy + F a b = Const (a,b) + +type F1 :: Type -> forall j. j -> forall k1 k2. (k1, k2) -> Type +type family F1 a b + +type F2 :: Type -> forall j. j -> forall k1 k2. (k1, k2) -> Type +type family F2 a b :: forall r2. (r1, r2) -> Type diff --git a/testsuite/tests/saks/should_compile/saks033.hs b/testsuite/tests/saks/should_compile/saks033.hs new file mode 100644 index 0000000000..cd6451dff0 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks033.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds, MultiParamTypeClasses, TypeFamilies, TypeApplications #-} + +module SAKS_033 where + +import Data.Kind +import Data.Proxy + +type C :: i -> Constraint +class C (a :: zzz) where + type F (a :: zzz) :: Type + +type T = F @Bool True diff --git a/testsuite/tests/saks/should_compile/saks034.hs b/testsuite/tests/saks/should_compile/saks034.hs new file mode 100644 index 0000000000..1288b665fe --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks034.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-} + +module SAKS_034 where + +import Data.Kind + +type C :: j -> Constraint +class C (a :: k) where + -- T :: forall j -> j -> Type + type T k (b :: k) :: Type diff --git a/testsuite/tests/saks/should_compile/saks034.script b/testsuite/tests/saks/should_compile/saks034.script new file mode 100644 index 0000000000..23dc6dfae8 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks034.script @@ -0,0 +1,4 @@ +:set -XNoStarIsType +:load saks034.hs +:kind C +:kind T diff --git a/testsuite/tests/saks/should_compile/saks034.stdout b/testsuite/tests/saks/should_compile/saks034.stdout new file mode 100644 index 0000000000..9877dc5d39 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks034.stdout @@ -0,0 +1,2 @@ +C :: j -> Constraint +T :: forall j -> j -> Type diff --git a/testsuite/tests/saks/should_compile/saks035.hs b/testsuite/tests/saks/should_compile/saks035.hs new file mode 100644 index 0000000000..e4b5fe7d66 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks035.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-} + +module SAKS_035 where + +import Data.Proxy +import Data.Kind + +type C :: Proxy i -> Constraint +class C (a :: Proxy z) where + -- F :: k -> Type + type F z diff --git a/testsuite/tests/saks/should_compile/saks035.script b/testsuite/tests/saks/should_compile/saks035.script new file mode 100644 index 0000000000..c51128f0da --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks035.script @@ -0,0 +1,4 @@ +:set -XNoStarIsType +:load saks035.hs +:kind C +:kind F diff --git a/testsuite/tests/saks/should_compile/saks035.stdout b/testsuite/tests/saks/should_compile/saks035.stdout new file mode 100644 index 0000000000..52193a3ff4 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks035.stdout @@ -0,0 +1,2 @@ +C :: forall k (i :: k). Proxy i -> Constraint +F :: k -> Type diff --git a/testsuite/tests/saks/should_compile/saks036.hs b/testsuite/tests/saks/should_compile/saks036.hs new file mode 100644 index 0000000000..76d3acd340 --- /dev/null +++ b/testsuite/tests/saks/should_compile/saks036.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, PolyKinds, RankNTypes, DataKinds #-} + +module SAKS_036 where + +import Data.Kind + +type C :: forall (k :: Type). k -> Constraint +class C (a :: (j :: Star)) where + type F j + +type family Star where Star = Type diff --git a/testsuite/tests/saks/should_fail/T16722.hs b/testsuite/tests/saks/should_fail/T16722.hs new file mode 100644 index 0000000000..fdc8b8de21 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16722.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE NoPolyKinds #-} + +module T16722 where + +import Data.Kind + +type D :: k -> Type +data D a diff --git a/testsuite/tests/saks/should_fail/T16722.stderr b/testsuite/tests/saks/should_fail/T16722.stderr new file mode 100644 index 0000000000..0b50bb868d --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16722.stderr @@ -0,0 +1,5 @@ + +T16722.hs:8:11: error: + Unexpected kind variable ‘k’ + Perhaps you intended to use PolyKinds + In the standalone kind signature for D diff --git a/testsuite/tests/saks/should_fail/T16725.hs b/testsuite/tests/saks/should_fail/T16725.hs new file mode 100644 index 0000000000..904cabe083 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16725.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TemplateHaskell #-} + +module T16725 where + +import Data.Kind (Type) + +type W :: Type diff --git a/testsuite/tests/saks/should_fail/T16725.stderr b/testsuite/tests/saks/should_fail/T16725.stderr new file mode 100644 index 0000000000..4fed187f73 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16725.stderr @@ -0,0 +1,3 @@ + +T16725.hs:8:6: error: + The standalone kind signature for ‘W’ lacks an accompanying binding diff --git a/testsuite/tests/saks/should_fail/T16727a.hs b/testsuite/tests/saks/should_fail/T16727a.hs new file mode 100644 index 0000000000..c258a4cc81 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16727a.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module T16727a where + +type T1 :: T2 +data T1 + +type T2 :: T1 +data T2 diff --git a/testsuite/tests/saks/should_fail/T16727a.stderr b/testsuite/tests/saks/should_fail/T16727a.stderr new file mode 100644 index 0000000000..9d0f3e11d7 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16727a.stderr @@ -0,0 +1,5 @@ + +T16727a.hs:8:12: error: + • Type constructor ‘T1’ cannot be used here + (it is defined and used in the same recursive group) + • In a standalone kind signature for ‘T2’: T1 diff --git a/testsuite/tests/saks/should_fail/T16727b.hs b/testsuite/tests/saks/should_fail/T16727b.hs new file mode 100644 index 0000000000..eb8fa62c50 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16727b.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module T16727b where + +type T :: T +data T diff --git a/testsuite/tests/saks/should_fail/T16727b.stderr b/testsuite/tests/saks/should_fail/T16727b.stderr new file mode 100644 index 0000000000..0a50ffe2e4 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16727b.stderr @@ -0,0 +1,5 @@ + +T16727b.hs:5:11: error: + • Type constructor ‘T’ cannot be used here + (it is defined and used in the same recursive group) + • In a standalone kind signature for ‘T’: T diff --git a/testsuite/tests/saks/should_fail/T16756b.hs b/testsuite/tests/saks/should_fail/T16756b.hs new file mode 100644 index 0000000000..8b71a67dad --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16756b.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module T16756b where + +import Data.Kind (Type) + +type T :: Type -> Type +data T + -- We must write: + -- data T a + -- See https://gitlab.haskell.org/ghc/ghc/issues/16756#note_203567 diff --git a/testsuite/tests/saks/should_fail/T16756b.stderr b/testsuite/tests/saks/should_fail/T16756b.stderr new file mode 100644 index 0000000000..d8324628d2 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16756b.stderr @@ -0,0 +1,4 @@ + +T16756b.hs:8:1: error: + • Expected a type, but found something with kind ‘* -> *’ + • In the data type declaration for ‘T’ diff --git a/testsuite/tests/saks/should_fail/T16826.hs b/testsuite/tests/saks/should_fail/T16826.hs new file mode 100644 index 0000000000..60f305edef --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16826.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeFamilies #-} + +module T16826 where + +import Data.Kind + +type family Id (x :: Type) :: Type where + Id x = x + +type C :: Type -> Id Constraint +class C a diff --git a/testsuite/tests/saks/should_fail/T16826.stderr b/testsuite/tests/saks/should_fail/T16826.stderr new file mode 100644 index 0000000000..c2272806c9 --- /dev/null +++ b/testsuite/tests/saks/should_fail/T16826.stderr @@ -0,0 +1,5 @@ + +T16826.hs:14:1: error: + • Kind signature on a class must end with Constraint + unobscured by type families + • In the class declaration for ‘C’ diff --git a/testsuite/tests/saks/should_fail/all.T b/testsuite/tests/saks/should_fail/all.T new file mode 100644 index 0000000000..82ae24181c --- /dev/null +++ b/testsuite/tests/saks/should_fail/all.T @@ -0,0 +1,32 @@ +test('saks007_fail', normal, compile_fail, ['']) +test('saks_fail001', normal, compile_fail, ['']) +test('saks_fail002', normal, compile_fail, ['']) +test('saks_fail003', normal, compile_fail, ['']) +test('saks_fail004', normal, compile_fail, ['']) +test('saks_fail005', normal, compile_fail, ['']) +test('saks_fail006', normal, compile_fail, ['']) +test('saks_fail007', normal, compile_fail, ['']) +test('saks_fail008', normal, compile_fail, ['']) +test('saks_fail009', normal, compile_fail, ['']) +test('saks_fail010', normal, compile_fail, ['']) +test('saks_fail011', normal, compile_fail, ['']) +test('saks_fail012', normal, compile_fail, ['']) +test('saks_fail013', normal, compile_fail, ['']) +test('saks_fail014', normal, compile_fail, ['']) +test('saks_fail015', normal, compile_fail, ['']) +test('saks_fail016', normal, compile_fail, ['']) +test('saks_fail017', normal, compile_fail, ['']) +test('saks_fail018', normal, compile_fail, ['']) +test('saks_fail019', normal, compile_fail, ['']) +test('saks_fail020', normal, compile_fail, ['']) +test('saks_fail021', normal, compile_fail, ['']) +test('saks_fail022', normal, compile_fail, ['']) +test('saks_fail023', normal, compile_fail, ['']) +test('saks_fail024', normal, compile_fail, ['']) +test('saks_fail025', normal, compile_fail, ['']) +test('T16722', normal, compile_fail, ['']) +test('T16727a', normal, compile_fail, ['']) +test('T16727b', normal, compile_fail, ['']) +test('T16725', normal, compile_fail, ['']) +test('T16826', normal, compile_fail, ['']) +test('T16756b', normal, compile_fail, ['']) diff --git a/testsuite/tests/saks/should_fail/saks007_fail.hs b/testsuite/tests/saks/should_fail/saks007_fail.hs new file mode 100644 index 0000000000..701ffcc17f --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks007_fail.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, GADTs, PolyKinds, DataKinds, ExplicitForAll #-} + +-- See also: saks007.hs +module SAKS_007_fail where + +import GHC.TypeLits (Nat) +import Data.Kind (Type, Constraint) + +type family F a where { F Type = True; F _ = False } +type family G a where { G Type = False; G _ = True } + +type X :: forall k1 k2. (F k1 ~ G k2) => k1 -> k2 -> Type +data X a b where + MkX :: X Integer String -- FAIL: F Type ~ G Type + -- True ~ False diff --git a/testsuite/tests/saks/should_fail/saks007_fail.stderr b/testsuite/tests/saks/should_fail/saks007_fail.stderr new file mode 100644 index 0000000000..ab15984030 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks007_fail.stderr @@ -0,0 +1,8 @@ + +saks007_fail.hs:15:10: error: + • Couldn't match kind ‘'True’ with ‘'False’ + Expected kind: G * + Actual kind: F * + • In the type ‘X Integer String’ + In the definition of data constructor ‘MkX’ + In the data declaration for ‘X’ diff --git a/testsuite/tests/saks/should_fail/saks_fail001.hs b/testsuite/tests/saks/should_fail/saks_fail001.hs new file mode 100644 index 0000000000..c71f7a4a68 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail001.hs @@ -0,0 +1,8 @@ +-- No -XStandaloneKindSignatures! + +module SAKS_Fail001 where + +import Data.Kind (Type) + +type T :: Type +data T diff --git a/testsuite/tests/saks/should_fail/saks_fail001.stderr b/testsuite/tests/saks/should_fail/saks_fail001.stderr new file mode 100644 index 0000000000..81ab28278d --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail001.stderr @@ -0,0 +1,4 @@ + +saks_fail001.hs:7:1: error: + Illegal standalone kind signature + Did you mean to enable StandaloneKindSignatures? diff --git a/testsuite/tests/saks/should_fail/saks_fail002.hs b/testsuite/tests/saks/should_fail/saks_fail002.hs new file mode 100644 index 0000000000..8f37e99ead --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail002.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_Fail002 where + +import Data.Kind (Type) + +data D + +type D :: Type +type D :: Type +type D :: Type diff --git a/testsuite/tests/saks/should_fail/saks_fail002.stderr b/testsuite/tests/saks/should_fail/saks_fail002.stderr new file mode 100644 index 0000000000..bac0492f3a --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail002.stderr @@ -0,0 +1,6 @@ + +saks_fail002.hs:9:1: error: + Duplicate standalone kind signatures for ‘D’: + type D :: Type -- written at saks_fail002.hs:9:1-14 + type D :: Type -- written at saks_fail002.hs:10:1-14 + type D :: Type -- written at saks_fail002.hs:11:1-14 diff --git a/testsuite/tests/saks/should_fail/saks_fail003.hs b/testsuite/tests/saks/should_fail/saks_fail003.hs new file mode 100644 index 0000000000..a1bf05e005 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail003.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds #-} + +module SAKS_Fail003 where + +type T :: _ +data T = MkT diff --git a/testsuite/tests/saks/should_fail/saks_fail003.stderr b/testsuite/tests/saks/should_fail/saks_fail003.stderr new file mode 100644 index 0000000000..f8f7f7af0d --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail003.stderr @@ -0,0 +1,4 @@ + +saks_fail003.hs:6:11: error: + Wildcard ‘_’ not allowed + in the standalone kind signature for T diff --git a/testsuite/tests/saks/should_fail/saks_fail004.hs b/testsuite/tests/saks/should_fail/saks_fail004.hs new file mode 100644 index 0000000000..d5d6b1558a --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail004.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds #-} + +module SAKS_Fail004 where + +import Data.Kind (Type) + +-- See also: T16263 +type Q :: Eq a => Type +data Q diff --git a/testsuite/tests/saks/should_fail/saks_fail004.stderr b/testsuite/tests/saks/should_fail/saks_fail004.stderr new file mode 100644 index 0000000000..15ec978340 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail004.stderr @@ -0,0 +1,4 @@ + +saks_fail004.hs:9:11: error: + • Illegal constraint in a kind: forall a. Eq a => * + • In a standalone kind signature for ‘Q’: Eq a => Type diff --git a/testsuite/tests/saks/should_fail/saks_fail005.hs b/testsuite/tests/saks/should_fail/saks_fail005.hs new file mode 100644 index 0000000000..e930920a0a --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail005.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE GADTs, PolyKinds #-} + +module SAKS_Fail005 where + +import Data.Kind (Type) +import Data.Proxy (Proxy) + +-- GADT constructors do not run under bindTyClTyVars, +-- and thus have no access to scoped type variables. +type G :: forall k. k -> Type +data G a where + MkG :: forall a. Proxy (a :: k) -> G a diff --git a/testsuite/tests/saks/should_fail/saks_fail005.stderr b/testsuite/tests/saks/should_fail/saks_fail005.stderr new file mode 100644 index 0000000000..c0230a9fef --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail005.stderr @@ -0,0 +1,2 @@ + +saks_fail005.hs:14:32: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail006.hs b/testsuite/tests/saks/should_fail/saks_fail006.hs new file mode 100644 index 0000000000..fc9bc51cf3 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail006.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications, PolyKinds #-} + +module SAKS_Fail006 where + +import Data.Kind (Type) + +-- Type family equations do not run under bindTyClTyVars, +-- and thus have no access to scoped type variables. +type F :: forall k. k -> k +type family F a where + F (Maybe a) = F @k a + F x = x diff --git a/testsuite/tests/saks/should_fail/saks_fail006.stderr b/testsuite/tests/saks/should_fail/saks_fail006.stderr new file mode 100644 index 0000000000..fb7cbe18a7 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail006.stderr @@ -0,0 +1,2 @@ + +saks_fail006.hs:13:20: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail007.hs b/testsuite/tests/saks/should_fail/saks_fail007.hs new file mode 100644 index 0000000000..0baeda837b --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail007.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_Fail007 where + +import Data.Kind (Type) + +type May a :: Type +data May a = Nay | Yay a diff --git a/testsuite/tests/saks/should_fail/saks_fail007.stderr b/testsuite/tests/saks/should_fail/saks_fail007.stderr new file mode 100644 index 0000000000..bc2764b1e7 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail007.stderr @@ -0,0 +1,2 @@ + +saks_fail007.hs:7:12: error: parse error on input ‘::’ diff --git a/testsuite/tests/saks/should_fail/saks_fail008.hs b/testsuite/tests/saks/should_fail/saks_fail008.hs new file mode 100644 index 0000000000..4083e4bfcb --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail008.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE KindSignatures #-} + +module SAKS_Fail008 where + +import Data.Kind (Type) + +type T :: Type -> (Type -> Type) -> Type +data T a (b :: Type -> Type) x1 (x2 :: Type -> Type) diff --git a/testsuite/tests/saks/should_fail/saks_fail008.stderr b/testsuite/tests/saks/should_fail/saks_fail008.stderr new file mode 100644 index 0000000000..4679afb564 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail008.stderr @@ -0,0 +1,5 @@ + +saks_fail008.hs:9:1: error: + • Not a function kind: * + but extra binders found: x1 (x2 :: Type -> Type) + • In the data type declaration for ‘T’ diff --git a/testsuite/tests/saks/should_fail/saks_fail009.hs b/testsuite/tests/saks/should_fail/saks_fail009.hs new file mode 100644 index 0000000000..317c0e7644 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail009.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} + +module SAKS_Fail009 where + +import Data.Kind (Type) + +type T :: forall k -> k -> Type +data T (k :: Type -> Type) (a :: k) diff --git a/testsuite/tests/saks/should_fail/saks_fail009.stderr b/testsuite/tests/saks/should_fail/saks_fail009.stderr new file mode 100644 index 0000000000..8ce43f6d5d --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail009.stderr @@ -0,0 +1,4 @@ + +saks_fail009.hs:9:1: error: + • Expected kind ‘* -> *’, but ‘k’ has kind ‘*’ + • In the data type declaration for ‘T’ diff --git a/testsuite/tests/saks/should_fail/saks_fail010.hs b/testsuite/tests/saks/should_fail/saks_fail010.hs new file mode 100644 index 0000000000..a427515a82 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail010.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_Fail010 where + +import Data.Kind (Type) + +type T :: Type -> Type +data T = MkT Int diff --git a/testsuite/tests/saks/should_fail/saks_fail010.stderr b/testsuite/tests/saks/should_fail/saks_fail010.stderr new file mode 100644 index 0000000000..b270ff2e67 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail010.stderr @@ -0,0 +1,4 @@ + +saks_fail010.hs:8:1: error: + • Expected a type, but found something with kind ‘* -> *’ + • In the data type declaration for ‘T’ diff --git a/testsuite/tests/saks/should_fail/saks_fail011.hs b/testsuite/tests/saks/should_fail/saks_fail011.hs new file mode 100644 index 0000000000..b5c6a11026 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail011.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE GADTs #-} + +module SAKS_Fail011 where + +import Data.Kind (Type) + +type G :: Type -> Type +data G where + MkG :: a -> G a diff --git a/testsuite/tests/saks/should_fail/saks_fail011.stderr b/testsuite/tests/saks/should_fail/saks_fail011.stderr new file mode 100644 index 0000000000..ff23c7b1a3 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail011.stderr @@ -0,0 +1,4 @@ + +saks_fail011.hs:9:1: error: + • Expected a type, but found something with kind ‘* -> *’ + • In the data type declaration for ‘G’ diff --git a/testsuite/tests/saks/should_fail/saks_fail012.hs b/testsuite/tests/saks/should_fail/saks_fail012.hs new file mode 100644 index 0000000000..892eb8c418 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail012.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_Fail012 where + +import Data.Kind (Type, Constraint) + +type C :: Type -> Type -> Constraint +class C a where diff --git a/testsuite/tests/saks/should_fail/saks_fail012.stderr b/testsuite/tests/saks/should_fail/saks_fail012.stderr new file mode 100644 index 0000000000..d43a0ac028 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail012.stderr @@ -0,0 +1,5 @@ + +saks_fail012.hs:8:1: error: + • Couldn't match expected kind ‘Constraint’ + with actual kind ‘* -> Constraint’ + • In the class declaration for ‘C’ diff --git a/testsuite/tests/saks/should_fail/saks_fail013.hs b/testsuite/tests/saks/should_fail/saks_fail013.hs new file mode 100644 index 0000000000..111b521b8a --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail013.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds #-} + +module SAKS_Fail013 where + +import Data.Kind (Type) + +type T :: forall (k :: Type) -> Type +data T j = MkT (j -> k) diff --git a/testsuite/tests/saks/should_fail/saks_fail013.stderr b/testsuite/tests/saks/should_fail/saks_fail013.stderr new file mode 100644 index 0000000000..4e041ba756 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail013.stderr @@ -0,0 +1,2 @@ + +saks_fail013.hs:10:22: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail014.hs b/testsuite/tests/saks/should_fail/saks_fail014.hs new file mode 100644 index 0000000000..e68f448f73 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail014.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies, PolyKinds, ExplicitForAll #-} + +module SAKS_Fail014 where + +import Data.Kind (Type) + +type T :: forall k. k +type family T :: forall j. j where + T = Maybe + T = Integer diff --git a/testsuite/tests/saks/should_fail/saks_fail014.stderr b/testsuite/tests/saks/should_fail/saks_fail014.stderr new file mode 100644 index 0000000000..68733410ee --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail014.stderr @@ -0,0 +1,11 @@ + +saks_fail014.hs:10:7: error: + • Expecting one more argument to ‘Maybe’ + Expected kind ‘forall k. k’, but ‘Maybe’ has kind ‘* -> *’ + • In the type ‘Maybe’ + In the type family declaration for ‘T’ + +saks_fail014.hs:11:7: error: + • Expected kind ‘forall k. k’, but ‘Integer’ has kind ‘*’ + • In the type ‘Integer’ + In the type family declaration for ‘T’ diff --git a/testsuite/tests/saks/should_fail/saks_fail015.hs b/testsuite/tests/saks/should_fail/saks_fail015.hs new file mode 100644 index 0000000000..78ee15e314 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail015.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds #-} + +module SAKS_Fail015 where + +import Data.Kind (Type) +import Data.Proxy (Proxy) + +type T :: forall k. k -> Type +data T a = MkT (Proxy (a :: k)) -- 'k' is not brought into scope by ScopedTypeVariables diff --git a/testsuite/tests/saks/should_fail/saks_fail015.stderr b/testsuite/tests/saks/should_fail/saks_fail015.stderr new file mode 100644 index 0000000000..d85b1a4c22 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail015.stderr @@ -0,0 +1,2 @@ + +saks_fail015.hs:11:29: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail016.hs b/testsuite/tests/saks/should_fail/saks_fail016.hs new file mode 100644 index 0000000000..f2966876ba --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail016.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds, ConstraintKinds, ExplicitForAll #-} + +module SAKS_Fail016 where + +import Data.Kind (Constraint) + +data T (a :: k) + +type C :: forall k. k -> Constraint +class C a where + getC :: forall. T (a :: k) -- 'k' is not brought into scope by ScopedTypeVariables diff --git a/testsuite/tests/saks/should_fail/saks_fail016.stderr b/testsuite/tests/saks/should_fail/saks_fail016.stderr new file mode 100644 index 0000000000..8f501674ea --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail016.stderr @@ -0,0 +1,2 @@ + +saks_fail016.hs:13:27: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail017.hs b/testsuite/tests/saks/should_fail/saks_fail017.hs new file mode 100644 index 0000000000..b13f27c7f9 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail017.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds, TypeApplications #-} + +module SAKS_Fail017 where + +import Data.Kind (Type) + +data T (a :: k) + +type S :: forall k. k -> Type +type S = T @k -- 'k' is not brought into scope by ScopedTypeVariables diff --git a/testsuite/tests/saks/should_fail/saks_fail017.stderr b/testsuite/tests/saks/should_fail/saks_fail017.stderr new file mode 100644 index 0000000000..b43ff35632 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail017.stderr @@ -0,0 +1,2 @@ + +saks_fail017.hs:12:13: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail018.hs b/testsuite/tests/saks/should_fail/saks_fail018.hs new file mode 100644 index 0000000000..4febbe2530 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail018.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} + +module SAKS_Fail018 where + +import Data.Kind (Type) + +data P w + +-- j = k, x = a +type T :: forall k. forall (a :: k) -> Type +data T (x :: j) = MkT (P k) (P j) (P x) -- 'k' is not brought into scope by ScopedTypeVariables diff --git a/testsuite/tests/saks/should_fail/saks_fail018.stderr b/testsuite/tests/saks/should_fail/saks_fail018.stderr new file mode 100644 index 0000000000..38b7c59662 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail018.stderr @@ -0,0 +1,2 @@ + +saks_fail018.hs:13:26: error: Not in scope: type variable ‘k’ diff --git a/testsuite/tests/saks/should_fail/saks_fail019.hs b/testsuite/tests/saks/should_fail/saks_fail019.hs new file mode 100644 index 0000000000..51cdd54ca2 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail019.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} + +module SAKS_Fail019 where + +import Data.Kind (Type) + +type T :: Type -> Type -> Type +data T a :: a -> Type + -- Should not panic with: + -- GHC internal error: ‘a’ is not in scope during type checking, but it passed the renamer diff --git a/testsuite/tests/saks/should_fail/saks_fail019.stderr b/testsuite/tests/saks/should_fail/saks_fail019.stderr new file mode 100644 index 0000000000..5bdb26a933 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail019.stderr @@ -0,0 +1,6 @@ + +saks_fail019.hs:9:1: error: + • Couldn't match kind ‘a’ with ‘*’ + Expected kind: a -> * + Actual kind: * -> * + • In the data type declaration for ‘T’ diff --git a/testsuite/tests/saks/should_fail/saks_fail020.hs b/testsuite/tests/saks/should_fail/saks_fail020.hs new file mode 100644 index 0000000000..69812aea8b --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail020.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE RankNTypes, PolyKinds, DataKinds, TypeFamilies #-} + +module SAKS_Fail020 where + +import Data.Kind +import Data.Proxy + +type Foo2 :: () -> forall (k :: Type) -> Proxy (a :: k) +type family Foo2 d k where {} + diff --git a/testsuite/tests/saks/should_fail/saks_fail020.stderr b/testsuite/tests/saks/should_fail/saks_fail020.stderr new file mode 100644 index 0000000000..7f4f33f631 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail020.stderr @@ -0,0 +1,6 @@ + +saks_fail020.hs:9:49: error: + • Expected kind ‘k’, but ‘a’ has kind ‘k0’ + • In the first argument of ‘Proxy’, namely ‘(a :: k)’ + In a standalone kind signature for ‘Foo2’: + () -> forall (k :: Type) -> Proxy (a :: k) diff --git a/testsuite/tests/saks/should_fail/saks_fail021.hs b/testsuite/tests/saks/should_fail/saks_fail021.hs new file mode 100644 index 0000000000..a702ea0a6a --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail021.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE RankNTypes, PolyKinds, DataKinds, TypeFamilies #-} + +module SAKS_Fail021 where + +import Data.Kind +import Data.Proxy + +type C :: Type -> Constraint +class C (a :: k) where + type F k diff --git a/testsuite/tests/saks/should_fail/saks_fail021.stderr b/testsuite/tests/saks/should_fail/saks_fail021.stderr new file mode 100644 index 0000000000..6128aff165 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail021.stderr @@ -0,0 +1,4 @@ + +saks_fail021.hs:10:1: error: + • Expected kind ‘k’, but ‘a’ has kind ‘*’ + • In the class declaration for ‘C’ diff --git a/testsuite/tests/saks/should_fail/saks_fail022.hs b/testsuite/tests/saks/should_fail/saks_fail022.hs new file mode 100644 index 0000000000..47638f84b5 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail022.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE RankNTypes, PolyKinds, DataKinds, TypeFamilies #-} + +module SAKS_Fail022 where + +import Data.Kind +import Data.Proxy + +type C :: (x,y) -> Constraint +class C (a :: k) where + type F k diff --git a/testsuite/tests/saks/should_fail/saks_fail022.stderr b/testsuite/tests/saks/should_fail/saks_fail022.stderr new file mode 100644 index 0000000000..e0cc222344 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail022.stderr @@ -0,0 +1,4 @@ + +saks_fail022.hs:10:1: error: + • Expected kind ‘k’, but ‘a’ has kind ‘(x, y)’ + • In the class declaration for ‘C’ diff --git a/testsuite/tests/saks/should_fail/saks_fail023.hs b/testsuite/tests/saks/should_fail/saks_fail023.hs new file mode 100644 index 0000000000..371f7ac925 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail023.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE RankNTypes, PolyKinds, DataKinds, TypeFamilies #-} + +module SAKS_Fail023 where + +import Data.Kind +import Data.Proxy + +type C :: Type -> Constraint +class C (a :: k) where + type F :: k -> k diff --git a/testsuite/tests/saks/should_fail/saks_fail023.stderr b/testsuite/tests/saks/should_fail/saks_fail023.stderr new file mode 100644 index 0000000000..3af24c7abb --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail023.stderr @@ -0,0 +1,4 @@ + +saks_fail023.hs:10:1: error: + • Expected kind ‘k’, but ‘a’ has kind ‘*’ + • In the class declaration for ‘C’ diff --git a/testsuite/tests/saks/should_fail/saks_fail024.hs b/testsuite/tests/saks/should_fail/saks_fail024.hs new file mode 100644 index 0000000000..714b19c4b6 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail024.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_Fail024 where + +import Data.Kind (Type) + +type Data.Kind.Type :: Type diff --git a/testsuite/tests/saks/should_fail/saks_fail024.stderr b/testsuite/tests/saks/should_fail/saks_fail024.stderr new file mode 100644 index 0000000000..0266358356 --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail024.stderr @@ -0,0 +1,3 @@ + +saks_fail024.hs:7:6: error: + Expected an unqualified type constructor: Data.Kind.Type diff --git a/testsuite/tests/saks/should_fail/saks_fail025.hs b/testsuite/tests/saks/should_fail/saks_fail025.hs new file mode 100644 index 0000000000..01c0af016a --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail025.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + +module SAKS_Fail024 where + +import Data.Kind (Type) + +type A, B, C :: Type + +data A +data B +data C diff --git a/testsuite/tests/saks/should_fail/saks_fail025.stderr b/testsuite/tests/saks/should_fail/saks_fail025.stderr new file mode 100644 index 0000000000..52e1527d3b --- /dev/null +++ b/testsuite/tests/saks/should_fail/saks_fail025.stderr @@ -0,0 +1,5 @@ + +saks_fail025.hs:7:6: error: + Standalone kind signatures do not support multiple names at the moment: + A, B, C + See https://gitlab.haskell.org/ghc/ghc/issues/16754 for details. |