diff options
author | Baldur Blöndal <baldurpet@gmail.com> | 2021-05-14 16:45:47 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-19 23:38:20 -0400 |
commit | d3ef2dc2bdfec457d5e0973f3e8f3e92767c16af (patch) | |
tree | 293621534c0a9932ab89fd9afedcd2169e7b0258 /testsuite/tests/lib | |
parent | e87b8e108303634af8a7247037d50ab10456c189 (diff) | |
download | haskell-d3ef2dc2bdfec457d5e0973f3e8f3e92767c16af.tar.gz |
Add pattern TypeRep (#19691), exported by Type.Reflection.
Diffstat (limited to 'testsuite/tests/lib')
-rw-r--r-- | testsuite/tests/lib/base/T19691.hs | 33 | ||||
-rw-r--r-- | testsuite/tests/lib/base/all.T | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/tests/lib/base/T19691.hs b/testsuite/tests/lib/base/T19691.hs new file mode 100644 index 0000000000..0525b8b499 --- /dev/null +++ b/testsuite/tests/lib/base/T19691.hs @@ -0,0 +1,33 @@ +{-# Language DerivingStrategies #-} +{-# Language TypeApplications #-} +{-# Language GADTs #-} +{-# Language StandaloneKindSignatures #-} +{-# Language TypeFamilies #-} + +import Data.Kind +import Type.Reflection + +type Dict :: Constraint -> Type +data Dict cls where + Dict :: cls => Dict cls + +deriving stock + instance Show (Dict cls) + +type WitnessList :: forall k. k -> Type +data WitnessList as where + WitnessList :: Typeable a => WitnessList (f a) + +deriving stock + instance Show (WitnessList as) + +toDict :: TypeRep a -> Dict (Typeable a) +toDict TypeRep = Dict + +witness :: TypeRep as -> Maybe (WitnessList as) +witness (App _ TypeRep) = Just WitnessList + +main :: IO () +main = do + print (toDict (TypeRep @[Int])) + print (witness (TypeRep @[Int])) diff --git a/testsuite/tests/lib/base/all.T b/testsuite/tests/lib/base/all.T index 6bf890c148..170bfe4d85 100644 --- a/testsuite/tests/lib/base/all.T +++ b/testsuite/tests/lib/base/all.T @@ -3,3 +3,4 @@ test('T16586', normal, compile_and_run, ['-O2']) # Event-manager not supported on Windows test('T16916', when(opsys('mingw32'), skip), compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) test('T17310', normal, compile, ['']) +test('T19691', normal, compile, [''])
\ No newline at end of file |