diff options
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/parser/should_run/RecordDotSyntax5.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/parser/should_run/RecordDotSyntax5.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/parser/should_run/all.T | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/parser/should_run/RecordDotSyntax5.hs b/testsuite/tests/parser/should_run/RecordDotSyntax5.hs new file mode 100644 index 0000000000..72749e876f --- /dev/null +++ b/testsuite/tests/parser/should_run/RecordDotSyntax5.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE DataKinds #-} + +import GHC.Records + +data Pair t = P { a, b :: t } + +instance Num t => HasField "sum" (Pair t) t where + getField p = p.a + p.b + +newtype Wrap = W { p :: Pair Double } + +main = do + print $ P{ a = 40, b = 2 }.sum + print $ W{ p = P 0 0 }.p{ a = 1 }{ b = 10 }.sum diff --git a/testsuite/tests/parser/should_run/RecordDotSyntax5.stdout b/testsuite/tests/parser/should_run/RecordDotSyntax5.stdout new file mode 100644 index 0000000000..5d68dd9d70 --- /dev/null +++ b/testsuite/tests/parser/should_run/RecordDotSyntax5.stdout @@ -0,0 +1,2 @@ +42 +11.0 diff --git a/testsuite/tests/parser/should_run/all.T b/testsuite/tests/parser/should_run/all.T index caf0e2bc65..5c2112057e 100644 --- a/testsuite/tests/parser/should_run/all.T +++ b/testsuite/tests/parser/should_run/all.T @@ -27,3 +27,4 @@ test('RecordDotSyntax1', normal, compile_and_run, ['']) test('RecordDotSyntax2', normal, compile_and_run, ['']) test('RecordDotSyntax3', [extra_files(['RecordDotSyntaxA.hs'])], multimod_compile_and_run, ['RecordDotSyntax3', '']) test('RecordDotSyntax4', [extra_files(['RecordDotSyntaxA.hs'])], multimod_compile_and_run, ['RecordDotSyntax4', '']) +test('RecordDotSyntax5', normal, compile_and_run, ['']) |