mirror of
https://github.com/google/ghc-source-gen.git
synced 2024-10-26 22:37:41 +03:00
promoted tuples (#62)
Also adds an internal `withPlaceHolders` combinator.
This commit is contained in:
parent
766dbae97c
commit
079fb254db
@ -10,6 +10,7 @@
|
||||
|
||||
## Other Changes
|
||||
- Add `kindedVar`.
|
||||
- Add `tuplePromotedTy`.
|
||||
|
||||
## 0.3.0.0
|
||||
- Add `occNameToStr` and `nameToStr` to convert from the GHC types.
|
||||
|
@ -77,6 +77,9 @@ noExtOrPlaceHolder = noExt
|
||||
withPlaceHolder :: a -> a
|
||||
withPlaceHolder = id
|
||||
|
||||
withPlaceHolders :: a -> a
|
||||
withPlaceHolders = id
|
||||
|
||||
#else
|
||||
|
||||
noExt :: a -> a
|
||||
@ -88,6 +91,9 @@ noExtOrPlaceHolder = withPlaceHolder
|
||||
withPlaceHolder :: (PlaceHolder -> a) -> a
|
||||
withPlaceHolder = ($ PlaceHolder)
|
||||
|
||||
withPlaceHolders :: ([PlaceHolder] -> a) -> a
|
||||
withPlaceHolders = ($ [])
|
||||
|
||||
#endif
|
||||
|
||||
builtSpan :: SrcSpan
|
||||
|
@ -12,6 +12,7 @@ module GHC.SourceGen.Type
|
||||
, numTy
|
||||
, listTy
|
||||
, listPromotedTy
|
||||
, tuplePromotedTy
|
||||
, (-->)
|
||||
, forall'
|
||||
, HsTyVarBndr'
|
||||
@ -45,6 +46,9 @@ listPromotedTy :: [HsType'] -> HsType'
|
||||
-- But for consistency, just always add it.
|
||||
listPromotedTy = withPlaceHolder (noExt HsExplicitListTy promoted) . map builtLoc
|
||||
|
||||
tuplePromotedTy :: [HsType'] -> HsType'
|
||||
tuplePromotedTy = withPlaceHolders (noExt HsExplicitTupleTy) . map builtLoc
|
||||
|
||||
-- | A function type.
|
||||
--
|
||||
-- > a -> b
|
||||
|
@ -99,13 +99,20 @@ typesTest dflags = testGroup "Type"
|
||||
, "123" :~ numTy 123
|
||||
]
|
||||
, test "unit"
|
||||
[ "()" :~ unit ]
|
||||
[ "()" :~ unit
|
||||
, "(# #)" :~ unboxedTuple []
|
||||
]
|
||||
, test "list"
|
||||
[ "[x]" :~ listTy (var "x")
|
||||
, "'[]" :~ listPromotedTy []
|
||||
, "'[x]" :~ listPromotedTy [var "x"]
|
||||
, "'[y, z]" :~ listPromotedTy [var "y", var "z"]
|
||||
]
|
||||
, test "tuple"
|
||||
[ "(a, b)" :~ tuple [(var "a"), (var "b")]
|
||||
, "(# a, b #)" :~ unboxedTuple [(var "a"), (var "b")]
|
||||
, "'(a, b)" :~ tuplePromotedTy [(var "a"), (var "b")]
|
||||
]
|
||||
, test "tyPromotedVar"
|
||||
-- For some reason, older GHC pretty-printed an extra space.
|
||||
[ ifGhc88 "'Abc" " 'Abc" :~ tyPromotedVar "Abc"
|
||||
|
Loading…
Reference in New Issue
Block a user