diff options
author | RyanGlScott <ryan.gl.scott@ku.edu> | 2015-07-17 00:04:24 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-07-17 00:08:10 +0200 |
commit | 2c5c29722c78e089eda0baa7ff89154b58f23165 (patch) | |
tree | 384abe9bb8703dacd310ab4006274ec1b9d78107 /testsuite/tests/deriving/should_run | |
parent | 415351a938e86c4def60228552f121d91bbe7e59 (diff) | |
download | haskell-2c5c29722c78e089eda0baa7ff89154b58f23165.tar.gz |
DeriveFoldable for data types with existential constraints (#10447)
Reviewers: dolio, shachaf, ekmett, austin, #core_libraries_committee,
simonpj, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie, bgamari
Differential Revision: https://phabricator.haskell.org/D1031
GHC Trac Issues: #10447
Diffstat (limited to 'testsuite/tests/deriving/should_run')
-rw-r--r-- | testsuite/tests/deriving/should_run/T10447.hs | 41 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_run/T10447.stdout | 9 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_run/all.T | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_run/T10447.hs b/testsuite/tests/deriving/should_run/T10447.hs new file mode 100644 index 0000000000..e91ce98f64 --- /dev/null +++ b/testsuite/tests/deriving/should_run/T10447.hs @@ -0,0 +1,41 @@ +{-# LANGUAGE DeriveFoldable, GADTs, StandaloneDeriving #-} +module Main where + +class (a ~ Int) => Foo a +instance Foo Int + +data A a where + A1 :: Ord a => a -> A a + A2 :: Int -> A Int + A3 :: b ~ Int => b -> A Int + A4 :: a ~ Int => Int -> A a + A5 :: a ~ Int => a -> A a + A6 :: (a ~ b, b ~ Int) => Int -> b -> A a + A7 :: Foo a => Int -> a -> A a + +deriving instance Foldable A + +data HK f a where + HK1 :: f a -> HK f (f a) + HK2 :: f a -> HK f a + +deriving instance Foldable f => Foldable (HK f) + +one :: Int +one = 1 + +main :: IO () +main = do + mapM_ (print . foldr (+) one) + [ A1 one + , A2 one + , A3 one + , A4 one + , A5 one + , A6 one one + , A7 one one + ] + mapM_ (print . foldr mappend Nothing) + [ HK1 (Just "Hello") + , HK2 (Just (Just "World")) + ] diff --git a/testsuite/tests/deriving/should_run/T10447.stdout b/testsuite/tests/deriving/should_run/T10447.stdout new file mode 100644 index 0000000000..079b327601 --- /dev/null +++ b/testsuite/tests/deriving/should_run/T10447.stdout @@ -0,0 +1,9 @@ +2 +1 +1 +1 +2 +1 +2 +Nothing +Just "World" diff --git a/testsuite/tests/deriving/should_run/all.T b/testsuite/tests/deriving/should_run/all.T index 1ccbdd77f8..d47e5c1312 100644 --- a/testsuite/tests/deriving/should_run/all.T +++ b/testsuite/tests/deriving/should_run/all.T @@ -39,3 +39,4 @@ test('T7931', normal, compile_and_run, ['']) test('T9576', exit_code(1), compile_and_run, ['']) test('T9830', extra_clean(['T9830a.hi', 'T9830a.o']), multimod_compile_and_run, ['T9830','-v0']) test('T10104', normal, compile_and_run, ['']) +test('T10447', normal, compile_and_run, ['']) |