[commit: ghc] imp-param-class: Add a function to deconstruct IP predicates. (82ee7cf)
Iavor Diatchki
diatchki at galois.com
Mon Jun 11 02:19:36 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : imp-param-class
http://hackage.haskell.org/trac/ghc/changeset/82ee7cfdf4bec20050fbf24b3119eeb085b01427
>---------------------------------------------------------------
commit 82ee7cfdf4bec20050fbf24b3119eeb085b01427
Author: Iavor S. Diatchki <iavor.diatchki at gmail.com>
Date: Sun Jun 10 16:55:57 2012 -0700
Add a function to deconstruct IP predicates.
>---------------------------------------------------------------
compiler/types/Type.lhs | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs
index b977b25..1099303 100644
--- a/compiler/types/Type.lhs
+++ b/compiler/types/Type.lhs
@@ -53,7 +53,7 @@ module Type (
isDictLikeTy,
mkEqPred, mkPrimEqPred,
mkClassPred,
- noParenPred, isClassPred, isEqPred, isIPPred,
+ noParenPred, isClassPred, isEqPred, isIPPred, isIPPred_maybe,
-- Deconstructing predicate types
PredTree(..), predTreePredType, classifyPredType,
@@ -165,6 +165,7 @@ import FastString
import Data.List ( partition )
import Maybes ( orElse )
import Data.Maybe ( isJust )
+import Control.Monad ( guard )
infixr 3 `mkFunTy` -- Associates to the right
\end{code}
@@ -857,6 +858,13 @@ isEqPred ty = case tyConAppTyCon_maybe ty of
isIPPred ty = case tyConAppTyCon_maybe ty of
Just tyCon -> tyConName tyCon == ipClassName
_ -> False
+
+isIPPred_maybe :: Type -> Maybe (FastString, Type)
+isIPPred_maybe ty =
+ do (tc,[t1,t2]) <- splitTyConApp_maybe ty
+ guard (tyConName tc == ipClassName)
+ x <- isStrLitTy t1
+ return (x,t2)
\end{code}
Make PredTypes
More information about the Cvs-ghc
mailing list