1 It's better to read it as: "if we know these, then we're going to know these"
4 module FunDeps(oclose, instantiateFdClassTys, pprFundeps) where
6 #include "HsVersions.h"
8 import Class (classTvsFds)
9 import Outputable (interppSP, ptext, empty, hsep, punctuate, comma)
10 import UniqSet (elementOfUniqSet, addOneToUniqSet )
11 import List (elemIndex)
14 case oclose1 fds vs of
16 (vs', True) -> oclose fds vs'
18 oclose1 [] vs = (vs, False)
19 oclose1 (fd@(ls, rs):fds) vs =
25 vs'b1@(vs', b1) = oclose1 fds vs
26 (vs'', b2) = ounion rs vs'
29 osubset (u:us) vs = if u `elementOfUniqSet` vs then osubset us vs else False
31 ounion [] ys = (ys, False)
33 if x `elementOfUniqSet` ys then (ys', b) else (addOneToUniqSet ys' x, True)
35 (ys', b) = ounion xs ys
37 instantiateFdClassTys clas ts =
38 map (lookupInstFundep tyvars ts) fundeps
40 (tyvars, fundeps) = classTvsFds clas
41 lookupInstFundep tyvars ts (us, vs) =
42 (lookupInstTys tyvars ts us, lookupInstTys tyvars ts vs)
43 lookupInstTys tyvars ts = map (lookupInstTy tyvars ts)
44 lookupInstTy tyvars ts u = ts !! i
45 where Just i = elemIndex u tyvars
48 pprFundeps fds = hsep (ptext SLIT("|") : punctuate comma (map ppr_fd fds))
50 ppr_fd (us, vs) = hsep [interppSP us, ptext SLIT("->"), interppSP vs]