diff options
author | Iavor S. Diatchki <iavor.diatchki@gmail.com> | 2013-02-15 09:40:35 -0800 |
---|---|---|
committer | Iavor S. Diatchki <iavor.diatchki@gmail.com> | 2013-02-15 09:42:06 -0800 |
commit | bc00d9016568baa51bb9dff588d8d27021808c75 (patch) | |
tree | b96f302d16954b8fb164fb8a04459f7e061357f1 /compiler | |
parent | ed2108267b93e6abd769192bdc8fe86cefef7a70 (diff) | |
download | haskell-bc00d9016568baa51bb9dff588d8d27021808c75.tar.gz |
Look through type synonyms when deciding if something is a type literal.
This is needed to make things like this work:
type N = 9
myValue = fromSing (sing :: Sing N)
If we don't look trough the synonym, we get an error that `SingI N` can't
be solved.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/types/Type.lhs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index 1add302eb0..679d39cb7c 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -419,14 +419,18 @@ splitAppTys ty = split ty ty [] mkNumLitTy :: Integer -> Type mkNumLitTy n = LitTy (NumTyLit n) +-- | Is this a numeric literal. We also look through type synonyms. isNumLitTy :: Type -> Maybe Integer +isNumLitTy ty | Just ty1 <- tcView ty = isNumLitTy ty1 isNumLitTy (LitTy (NumTyLit n)) = Just n isNumLitTy _ = Nothing mkStrLitTy :: FastString -> Type mkStrLitTy s = LitTy (StrTyLit s) +-- | Is this a symbol literal. We also look through type synonyms. isStrLitTy :: Type -> Maybe FastString +isStrLitTy ty | Just ty1 <- tcView ty = isStrLitTy ty1 isStrLitTy (LitTy (StrTyLit s)) = Just s isStrLitTy _ = Nothing |