---------------------------------------------------------------- -- unify.phs -- contains the polytypic part of the unification algorithm -- (i.e. almost nothing) -- To test this: see README.txt module PolyUnify where import Base(inn,out,fmap2) import Flatten(fflatten) import Equal(fequal) ---------------------------------------------------------------- --instance Regular d => Children (d a) where -- children = children' -- mapChildren = mapChildren' children' = fflatten . fmap2 nil singleton . out mapChildren' f = inn . fmap2 id f . out --instance (Regular d, Eq a) => TopEq (d a) where -- topEq = topEq' topEq' t t' = fequal (==) (\_ _ -> True) (out t) (out t') ---------------------------------------------------------------- -- all the examples have the variable as their first constructor varCheck' = fvarCheck' . out polytypic fvarCheck' :: f a b -> Maybe Int = case f of g + h -> either fvarCheck' err Const Int -> ok g -> err ok = Just err = const Nothing