+ Instance Testing
+%* *
+%************************************************************************
+
+\begin{code}
+lookupClassInstances :: TH.Name -> [TH.Type] -> TcM [TH.Name]
+lookupClassInstances c ts
+ = do { loc <- getSrcSpanM
+ ; case convertToHsPred loc (TH.ClassP c ts) of
+ Left msg -> failWithTc msg
+ Right rdr_pred -> do
+ { rn_pred <- rnLPred doc rdr_pred -- Rename
+ ; kc_pred <- kcHsLPred rn_pred -- Kind check
+ ; ClassP cls tys <- dsHsLPred kc_pred -- Type check
+
+ -- Now look up instances
+ ; inst_envs <- tcGetInstEnvs
+ ; let (matches, unifies) = lookupInstEnv inst_envs cls tys
+ dfuns = map is_dfun (map fst matches ++ unifies)
+ ; return (map reifyName dfuns) } }
+ where
+ doc = ptext (sLit "TcSplice.classInstances")
+\end{code}
+
+
+%************************************************************************
+%* *