diff options
Diffstat (limited to 'testsuite/tests/parser/should_run/RecordDotSyntax5.hs')
-rw-r--r-- | testsuite/tests/parser/should_run/RecordDotSyntax5.hs | 15 |
1 files changed, 15 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 |