[commit: ghc] wip/pattern-synonyms: tcLookupPatSyn: look up the PatSyn record for a given Id (21fba5d)

git at git.haskell.org git at git.haskell.org
Sun Jul 27 19:13:08 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/pattern-synonyms
Link       : http://ghc.haskell.org/trac/ghc/changeset/21fba5de4dc269ed5a104ac0e29e467f8168990f/ghc

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

commit 21fba5de4dc269ed5a104ac0e29e467f8168990f
Author: Dr. ERDI Gergo <gergo at erdi.hu>
Date:   Sun Jul 27 21:00:15 2014 +0200

    tcLookupPatSyn: look up the PatSyn record for a given Id


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

21fba5de4dc269ed5a104ac0e29e467f8168990f
 compiler/typecheck/TcEnv.lhs | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/compiler/typecheck/TcEnv.lhs b/compiler/typecheck/TcEnv.lhs
index 6020797..9c9739c 100644
--- a/compiler/typecheck/TcEnv.lhs
+++ b/compiler/typecheck/TcEnv.lhs
@@ -18,8 +18,8 @@ module TcEnv(
         tcExtendGlobalEnv, tcExtendGlobalEnvImplicit, setGlobalTypeEnv,
         tcExtendGlobalValEnv,
         tcLookupLocatedGlobal, tcLookupGlobal, 
-        tcLookupField, tcLookupTyCon, tcLookupClass, tcLookupDataCon,
-        tcLookupConLike,
+        tcLookupField, tcLookupTyCon, tcLookupClass,
+        tcLookupDataCon, tcLookupPatSyn, tcLookupConLike,
         tcLookupLocatedGlobalId, tcLookupLocatedTyCon,
         tcLookupLocatedClass, tcLookupInstance, tcLookupAxiom,
         
@@ -73,7 +73,8 @@ import Var
 import VarSet
 import RdrName
 import InstEnv
-import DataCon
+import DataCon ( DataCon )
+import PatSyn  ( PatSyn )
 import ConLike
 import TyCon
 import CoAxiom
@@ -160,6 +161,13 @@ tcLookupDataCon name = do
         AConLike (RealDataCon con) -> return con
         _                          -> wrongThingErr "data constructor" (AGlobal thing) name
 
+tcLookupPatSyn :: Name -> TcM PatSyn
+tcLookupPatSyn name = do
+    thing <- tcLookupGlobal name
+    case thing of
+        AConLike (PatSynCon ps) -> return ps
+        _                       -> wrongThingErr "pattern synonym" (AGlobal thing) name
+
 tcLookupConLike :: Name -> TcM ConLike
 tcLookupConLike name = do
     thing <- tcLookupGlobal name



More information about the ghc-commits mailing list