[commit: ghc] wip/T9023: Add toPatSynSigDetails to turn a HsConDeclDetails into a HsPatSynDetails (2d86eef)

git at git.haskell.org git at git.haskell.org
Wed Jul 2 11:24:11 UTC 2014


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

On branch  : wip/T9023
Link       : http://ghc.haskell.org/trac/ghc/changeset/2d86eeff134baac96d708eaa4c161455350da14d/ghc

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

commit 2d86eeff134baac96d708eaa4c161455350da14d
Author: Dr. ERDI Gergo <gergo at erdi.hu>
Date:   Wed Jul 2 19:16:23 2014 +0800

    Add toPatSynSigDetails to turn a HsConDeclDetails into a HsPatSynDetails


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

2d86eeff134baac96d708eaa4c161455350da14d
 compiler/parser/RdrHsSyn.lhs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs
index 29e88ea..932ccd2 100644
--- a/compiler/parser/RdrHsSyn.lhs
+++ b/compiler/parser/RdrHsSyn.lhs
@@ -14,7 +14,7 @@ module RdrHsSyn (
         mkTySynonym, mkTyFamInstEqn,
         mkTyFamInst, 
         mkFamDecl, 
-        splitCon, mkInlinePragma,
+        splitCon, toPatSynSigDetails, mkInlinePragma,
         mkRecConstrOrUpdate, -- HsExp -> [HsFieldUpdate] -> P HsExp
         mkTyLit,
         mkTyClD, mkInstD,
@@ -410,6 +410,16 @@ splitCon ty
    mk_rest [L _ (HsRecTy flds)] = RecCon flds
    mk_rest ts                   = PrefixCon ts
 
+toPatSynSigDetails :: SrcSpan -> HsConDeclDetails RdrName
+                   -> P (HsPatSynDetails (LHsType RdrName))
+toPatSynSigDetails _ (PrefixCon ts) = return $ PrefixPatSyn ts
+toPatSynSigDetails _ (InfixCon t1 t2) = return $ InfixPatSyn t1 t2
+toPatSynSigDetails loc (RecCon flds)
+  = parseErrorSDoc loc $
+    text "record syntax not supported for pattern synonym:" <+> ppr_rec
+  where
+    ppr_rec = ppr (noLoc $ HsRecTy flds)
+
 mkDeprecatedGadtRecordDecl :: SrcSpan
                            -> Located RdrName
                            -> [ConDeclField RdrName]



More information about the ghc-commits mailing list