mirror of
https://github.com/google/ghc-source-gen.git
synced 2024-09-11 22:07:09 +03:00
Fix listPromotedTy on lists of one or zero elements. (#55)
We need the explicit `'` to distinguish from regular lists. For simplicity, just use it for all type-level lists of any length.
This commit is contained in:
parent
5986388e5b
commit
cf6eb5e260
@ -2,6 +2,8 @@
|
||||
|
||||
## Unreleased
|
||||
- Add `occNameToStr` and `nameToStr` to convert from the GHC types.
|
||||
- Make `listPromotedTy` emit the promoted form `'[..]`,
|
||||
to distinguish from regular list types of zero or one elements.
|
||||
|
||||
## 0.2.0.1
|
||||
- Bump upper-bound to allow `QuickCheck-2.13`.
|
||||
|
@ -40,7 +40,9 @@ listTy :: HsType' -> HsType'
|
||||
listTy = noExt HsListTy . builtLoc
|
||||
|
||||
listPromotedTy :: [HsType'] -> HsType'
|
||||
listPromotedTy = withPlaceHolder (noExt HsExplicitListTy notPromoted) . map builtLoc
|
||||
-- Lists of two or more elements don't need the explicit tick (`'`).
|
||||
-- But for consistency, just always add it.
|
||||
listPromotedTy = withPlaceHolder (noExt HsExplicitListTy promoted) . map builtLoc
|
||||
|
||||
-- | A function type.
|
||||
--
|
||||
|
@ -95,9 +95,9 @@ typesTest dflags = testGroup "Type"
|
||||
[ "()" :~ unit ]
|
||||
, test "list"
|
||||
[ "[x]" :~ listTy (var "x")
|
||||
, "[]" :~ listPromotedTy []
|
||||
, "[x]" :~ listPromotedTy [var "x"]
|
||||
, "[y, z]" :~ listPromotedTy [var "y", var "z"]
|
||||
, "'[]" :~ listPromotedTy []
|
||||
, "'[x]" :~ listPromotedTy [var "x"]
|
||||
, "'[y, z]" :~ listPromotedTy [var "y", var "z"]
|
||||
]
|
||||
, test "tyPromotedVar"
|
||||
-- For some reason, older GHC pretty-printed an extra space.
|
||||
|
Loading…
Reference in New Issue
Block a user