diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-04-01 20:36:31 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-04 04:29:29 -0400 |
commit | 25c02ea172ef1dad2d12d8baff6ce57a68bf4127 (patch) | |
tree | 6b1a044b85ecb82c2b7f1edaece878aec6a9098b /testsuite | |
parent | 75abaaead796415cf2b5da610f4b3ee75b9d7759 (diff) | |
download | haskell-25c02ea172ef1dad2d12d8baff6ce57a68bf4127.tar.gz |
Fix #16518 with some more kind-splitting smarts
This patch corrects two simple oversights that led to #16518:
1. `HsUtils.typeToLHsType` was taking visibility into account in the
`TyConApp` case, but not the `AppTy` case. I've factored out the
visibility-related logic into its own `go_app` function and now
invoke `go_app` from both the `TyConApp` and `AppTy` cases.
2. `Type.fun_kind_arg_flags` did not properly split kinds with
nested `forall`s, such as
`(forall k. k -> Type) -> (forall k. k -> Type)`. This was simply
because `fun_kind_arg_flags`'s `FunTy` case always bailed out and
assumed all subsequent arguments were `Required`, which clearly
isn't the case for nested `forall`s. I tweaked the `FunTy` case
to recur on the result kind.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/deriving/should_compile/T16518.hs | 36 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_compile/all.T | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_compile/T16518.hs b/testsuite/tests/deriving/should_compile/T16518.hs new file mode 100644 index 0000000000..49efe34673 --- /dev/null +++ b/testsuite/tests/deriving/should_compile/T16518.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} +module T16518 where + +import Data.Coerce +import Data.Kind +import Data.Type.Equality + +----- + +class HTestEquality1 (f :: forall k. k -> Type) where + hTestEquality1 :: forall k1 k2 (a :: k1) (b :: k2). + f a -> f b -> Maybe (a :~~: b) +newtype T1 :: (forall k. k -> Type) -> (forall k. k -> Type) where + MkT1 :: forall (f :: forall k. k -> Type) k (a :: k). f a -> T1 f a + +deriving instance forall (f :: forall k. k -> Type). + HTestEquality1 f => HTestEquality1 (T1 f) + +----- + +class HTestEquality2 (f :: forall k -> k -> Type) where + hTestEquality2 :: forall k1 k2 (a :: k1) (b :: k2). + f k1 a -> f k2 b -> Maybe (a :~~: b) +newtype T2 :: (forall k -> k -> Type) -> (forall k -> k -> Type) where + MkT2 :: forall (f :: forall k -> k -> Type) k (a :: k). f k a -> T2 f k a + +deriving instance forall (f :: forall k -> k -> Type). + HTestEquality2 f => HTestEquality2 (T2 f) diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index 23f152e195..a5f666c062 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -115,3 +115,4 @@ test('T15290d', normal, compile, ['']) test('T15398', normal, compile, ['']) test('T15637', normal, compile, ['']) test('T16179', normal, compile, ['']) +test('T16518', normal, compile, ['']) |