Skip to content
Snippets Groups Projects
Commit 2122de54 authored by Alec Theriault's avatar Alec Theriault
Browse files

Properly synify promoted list types

We reconstruct promoted list literals whenever possible. That means
that 'synifyType' produces

   '[Int, Bool, ()]

instead of

   (Int ': (() ': (Bool ': ([] :: [Type]))))
parent 6a9ada24
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ import Type
import TyCoRep
import TysPrim ( alphaTyVars )
import TysWiredIn ( eqTyConName, listTyConName, liftedTypeKindTyConName
, unitTy )
, unitTy, promotedNilDataCon, promotedConsDataCon )
import PrelNames ( hasKey, eqTyConKey, ipClassKey, tYPETyConKey
, liftedRepDataConKey )
import Unique ( getUnique )
......@@ -465,6 +465,16 @@ synifyType _ (TyConApp tc tys)
-- ditto for lists
| getName tc == listTyConName, [ty] <- tys =
noLoc $ HsListTy noExt (synifyType WithinType ty)
| tc == promotedNilDataCon, [] <- vis_tys
= noLoc $ HsExplicitListTy noExt Promoted []
| tc == promotedConsDataCon
, [ty1, ty2] <- vis_tys
= let hTy = synifyType WithinType ty1
in case synifyType WithinType ty2 of
tTy | L _ (HsExplicitListTy _ Promoted tTy') <- stripKindSig tTy
-> noLoc $ HsExplicitListTy noExt Promoted (hTy : tTy')
| otherwise
-> noLoc $ HsOpTy noExt hTy (noLoc $ getName tc) tTy
-- ditto for implicit parameter tycons
| tc `hasKey` ipClassKey
, [name, ty] <- tys
......@@ -572,6 +582,10 @@ synifyTyLit (StrTyLit s) = HsStrTy NoSourceText s
synifyKindSig :: Kind -> LHsKind GhcRn
synifyKindSig k = synifyType WithinType k
stripKindSig :: LHsType GhcRn -> LHsType GhcRn
stripKindSig (L _ (HsKindSig _ t _)) = t
stripKindSig t = t
synifyInstHead :: ([TyVar], [PredType], Class, [Type]) -> InstHead GhcRn
synifyInstHead (_, preds, cls, types) = specializeInstHead $ InstHead
{ ihdClsName = getName cls
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment