diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-09-30 20:15:25 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-09-30 23:23:44 -0400 |
commit | 9e862765ffe161da8a4fd9cd67b0a600874feaa9 (patch) | |
tree | 235c1ba702b0101e1fa6a8fe7f8146e2c7ec9c69 /testsuite/tests/ghc-api | |
parent | b3d55e20d20344bfc09f4ca4a554a819c4ecbfa8 (diff) | |
download | haskell-9e862765ffe161da8a4fd9cd67b0a600874feaa9.tar.gz |
Implement deriving strategies
Allows users to explicitly request which approach to `deriving` to use
via keywords, e.g.,
```
newtype Foo = Foo Bar
deriving Eq
deriving stock Ord
deriving newtype Show
```
Fixes #10598. Updates haddock submodule.
Test Plan: ./validate
Reviewers: hvr, kosmikus, goldfire, alanz, bgamari, simonpj, austin,
erikd, simonmar
Reviewed By: alanz, bgamari, simonpj
Subscribers: thomie, mpickering, oerjan
Differential Revision: https://phabricator.haskell.org/D2280
GHC Trac Issues: #10598
Diffstat (limited to 'testsuite/tests/ghc-api')
-rw-r--r-- | testsuite/tests/ghc-api/annotations/Makefile | 4 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10598.stdout | 36 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/Test10598.hs | 18 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/all.T | 1 |
4 files changed, 59 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-api/annotations/Makefile b/testsuite/tests/ghc-api/annotations/Makefile index c557c66624..158dadb72c 100644 --- a/testsuite/tests/ghc-api/annotations/Makefile +++ b/testsuite/tests/ghc-api/annotations/Makefile @@ -112,6 +112,10 @@ T11018: T10276: $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test10276.hs +.PHONY: T10598 +T10598: + $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test10598.hs + .PHONY: T11321 T11321: $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test11321.hs diff --git a/testsuite/tests/ghc-api/annotations/T10598.stdout b/testsuite/tests/ghc-api/annotations/T10598.stdout new file mode 100644 index 0000000000..21029da26d --- /dev/null +++ b/testsuite/tests/ghc-api/annotations/T10598.stdout @@ -0,0 +1,36 @@ +---Problems (should be empty list)--- +[] +---Annotations----------------------- +-- SrcSpan the annotation is attached to, AnnKeywordId, +-- list of locations the keyword item appears in +[ +((Test10598.hs:1:1,AnnModule), [Test10598.hs:5:1-6]), +((Test10598.hs:1:1,AnnWhere), [Test10598.hs:5:18-22]), +((Test10598.hs:(7,1)-(9,10),AnnClass), [Test10598.hs:7:1-5]), +((Test10598.hs:(7,1)-(9,10),AnnSemi), [Test10598.hs:11:1]), +((Test10598.hs:(7,1)-(9,10),AnnWhere), [Test10598.hs:7:11-15]), +((Test10598.hs:8:3-21,AnnDcolon), [Test10598.hs:8:5-6]), +((Test10598.hs:8:3-21,AnnSemi), [Test10598.hs:9:3]), +((Test10598.hs:8:8-21,AnnRarrow), [Test10598.hs:8:16-17]), +((Test10598.hs:9:3-10,AnnEqual), [Test10598.hs:9:7]), +((Test10598.hs:9:3-10,AnnFunId), [Test10598.hs:9:3]), +((Test10598.hs:(11,1)-(12,10),AnnInstance), [Test10598.hs:11:1-8]), +((Test10598.hs:(11,1)-(12,10),AnnSemi), [Test10598.hs:14:1]), +((Test10598.hs:(11,1)-(12,10),AnnWhere), [Test10598.hs:11:16-20]), +((Test10598.hs:12:3-10,AnnEqual), [Test10598.hs:12:7]), +((Test10598.hs:12:3-10,AnnFunId), [Test10598.hs:12:3]), +((Test10598.hs:(14,1)-(17,21),AnnEqual), [Test10598.hs:14:13]), +((Test10598.hs:(14,1)-(17,21),AnnNewtype), [Test10598.hs:14:1-7]), +((Test10598.hs:(14,1)-(17,21),AnnSemi), [Test10598.hs:18:1]), +((Test10598.hs:15:3-22,AnnDeriving), [Test10598.hs:15:3-10]), +((Test10598.hs:16:3-23,AnnDeriving), [Test10598.hs:16:3-10]), +((Test10598.hs:16:12-16,AnnStock), [Test10598.hs:16:12-16]), +((Test10598.hs:17:3-21,AnnDeriving), [Test10598.hs:17:3-10]), +((Test10598.hs:17:12-19,AnnAnyclass), [Test10598.hs:17:12-19]), +((Test10598.hs:18:1-34,AnnDeriving), [Test10598.hs:18:1-8]), +((Test10598.hs:18:1-34,AnnInstance), [Test10598.hs:18:18-25]), +((Test10598.hs:18:1-34,AnnSemi), [Test10598.hs:19:1]), +((Test10598.hs:18:10-16,AnnNewtype), [Test10598.hs:18:10-16]), +((<no location info>,AnnEofPos), [Test10598.hs:19:1]) +] + diff --git a/testsuite/tests/ghc-api/annotations/Test10598.hs b/testsuite/tests/ghc-api/annotations/Test10598.hs new file mode 100644 index 0000000000..8a7651c154 --- /dev/null +++ b/testsuite/tests/ghc-api/annotations/Test10598.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE StandaloneDeriving #-} +module Test10598 where + +class C a where + c :: proxy a -> Int + c _ = 42 + +instance C Int where + c _ = 27 + +newtype Foo = MkFoo Int + deriving Eq + deriving stock Ord + deriving anyclass C +deriving newtype instance Show Foo diff --git a/testsuite/tests/ghc-api/annotations/all.T b/testsuite/tests/ghc-api/annotations/all.T index c14153dfbb..fac5d56658 100644 --- a/testsuite/tests/ghc-api/annotations/all.T +++ b/testsuite/tests/ghc-api/annotations/all.T @@ -21,6 +21,7 @@ test('T10313', normal, run_command, ['$MAKE -s --no-print-directory T10313' test('T11018', normal, run_command, ['$MAKE -s --no-print-directory T11018']) test('bundle-export', normal, run_command, ['$MAKE -s --no-print-directory bundle-export']) test('T10276', normal, run_command, ['$MAKE -s --no-print-directory T10276']) +test('T10598', normal, run_command, ['$MAKE -s --no-print-directory T10598']) test('T11321', normal, run_command, ['$MAKE -s --no-print-directory T11321']) test('T11332', normal, run_command, ['$MAKE -s --no-print-directory T11332']) test('T11430', normal, run_command, ['$MAKE -s --no-print-directory T11430']) |