diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2016-08-23 14:20:36 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-08-23 15:35:18 -0400 |
commit | 613d745523f181991f6f916bbe58082b7970f7e6 (patch) | |
tree | b93c010d19b953271a828eb97fa8fcdb05c2a8c7 /testsuite/tests/th/T12478_3.hs | |
parent | 1766bb3cfd1460796c78bd5651f89d53603586f9 (diff) | |
download | haskell-613d745523f181991f6f916bbe58082b7970f7e6.tar.gz |
Template Haskell support for unboxed sums
This adds new constructors `UnboxedSumE`, `UnboxedSumT`, and
`UnboxedSumP` to represent unboxed sums in Template Haskell.
One thing you can't currently do is, e.g., `reify ''(#||#)`, since I
don't believe unboxed sum type/data constructors can be written in
prefix form. I will look at fixing that as part of #12514.
Fixes #12478.
Test Plan: make test TEST=T12478_{1,2,3}
Reviewers: osa1, goldfire, austin, bgamari
Reviewed By: goldfire, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2448
GHC Trac Issues: #12478
Diffstat (limited to 'testsuite/tests/th/T12478_3.hs')
-rw-r--r-- | testsuite/tests/th/T12478_3.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/th/T12478_3.hs b/testsuite/tests/th/T12478_3.hs new file mode 100644 index 0000000000..7c84eee50f --- /dev/null +++ b/testsuite/tests/th/T12478_3.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE UnboxedSums #-} +module T12478_3 where + +import Language.Haskell.TH + +$(do let ubxSum = unboxedSumT 2 `appT` conT ''Int `appT` conT ''Int + x <- newName "x" + y <- newName "y" + + [d| swap :: $(ubxSum) -> $(ubxSum) + swap $(unboxedSumP (varP x) 1 2) = $(unboxedSumE (varE x) 2 2) + swap $(unboxedSumP (varP y) 2 2) = $(unboxedSumE (varE y) 1 2) + |]) |