You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
where s’ = foldr Map.delete s as<br />
ftv (Forall as t) = ftv t ‘Set.difference‘ Set.fromList as<br />
instance Substitutable a => Substitutable [a] where<br />
apply = fmap . apply<br />
ftv = foldr (Set.union . ftv) Set.empty<br />
instance Substitutable TypeEnv where<br />
apply s (TypeEnv env) = TypeEnv $ Map.map (apply s) env<br />
ftv (TypeEnv env) = ftv $ Map.elems env<br />
roughout both the typing rules and substitutions we will require a fresh supply of names. In this naive<br />
version we will simply use an infinite list of strings and slice into n’th element of list per a index that we<br />
hold in a State monad. is is a simplest implementation possible, and later we will adapt this name<br />
generation technique to be more robust.<br />
letters :: [String]<br />
letters = [1..] >>= flip replicateM [’a’..’z’]<br />
fresh :: Infer Type<br />
fresh = do<br />
s