classSuperDictSelId, classOpId, classDefaultMethodId,
classSig, classBigSig, classInstEnv,
isSuperClassOf,
- classOpTagByString,
+ classOpTagByString, classOpTagByString_maybe,
derivableClassKeys, needsDataDeclCtxtClassKeys,
cCallishClassKeys, isNoDictClass,
import Maybes ( assocMaybe )
import Name ( changeUnique, Name )
import Unique -- Keys for built-in classes
-import Pretty ( SYN_IE(Pretty), ppCat{-ToDo:rm-}, ppPStr{-ditto-} )
-import PprStyle ( PprStyle )
+import Pretty ( SYN_IE(Pretty), ppCat, ppPStr )
+--import PprStyle ( PprStyle )
import SrcLoc ( SrcLoc )
import Util
\end{code}
Rather unsavoury ways of getting ClassOp tags:
\begin{code}
-classOpTagByString :: Class -> FAST_STRING -> Int
+classOpTagByString_maybe :: Class -> FAST_STRING -> Maybe Int
+classOpTagByString :: Class -> FAST_STRING -> Int
classOpTagByString clas op
+ = case (classOpTagByString_maybe clas op) of
+ Just tag -> tag
+#ifdef DEBUG
+ Nothing -> pprPanic "classOpTagByString:" (ppCat (ppPStr op : map (ppPStr . classOpString) (classOps clas)))
+#endif
+
+classOpTagByString_maybe clas op
= go (map classOpString (classOps clas)) 1
where
+ go [] _ = Nothing
go (n:ns) tag = if n == op
- then tag
+ then Just tag
else go ns (tag+1)
-#ifdef DEBUG
- go [] tag = pprPanic "classOpTagByString:" (ppCat (ppPStr op : map (ppPStr . classOpString) (classOps clas)))
-#endif
\end{code}
%************************************************************************