[commit: ghc] master: Look through type synonyms when deciding if something is a type literal. (bc00d90)

Iavor Diatchki diatchki at galois.com
Fri Feb 15 21:53:18 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/bc00d9016568baa51bb9dff588d8d27021808c75

>---------------------------------------------------------------

commit bc00d9016568baa51bb9dff588d8d27021808c75
Author: Iavor S. Diatchki <iavor.diatchki at gmail.com>
Date:   Fri Feb 15 09:40:35 2013 -0800

    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.

>---------------------------------------------------------------

 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 1add302..679d39c 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
 





More information about the ghc-commits mailing list