[Type-constraints] Compounds type substitution
This commit is contained in:
parent
966c694dbf
commit
549d3e1006
@ -96,21 +96,20 @@ getSrcSpanType modSum lineNo colNo = do
|
|||||||
where
|
where
|
||||||
ct [pid] = (,) (fst gt) <$> lookup pid as
|
ct [pid] = (,) (fst gt) <$> lookup pid as
|
||||||
ct [] = Nothing
|
ct [] = Nothing
|
||||||
-- TODO: A case of multiple ids should probably
|
|
||||||
-- collect all constraints and then apply
|
|
||||||
-- them to calculated type. No idea how
|
|
||||||
-- to do that at the moment.
|
|
||||||
-- NB: The following does not work, since
|
|
||||||
-- "inner" types have different IDs from
|
|
||||||
-- exported types. So we need some sort of
|
|
||||||
-- type substitution.
|
|
||||||
ct pids =
|
ct pids =
|
||||||
let
|
let
|
||||||
ctys = mapMaybe (`lookup` as) pids
|
ctys = mapMaybe build pids
|
||||||
preds = concatMap (fst . getPreds) ctys
|
build x | Just cti <- x `lookup` as
|
||||||
--typs = map (snd . getPreds) ctys
|
= let
|
||||||
ty = mkFunTys preds $ snd gt
|
(preds', ctt) = getPreds cti
|
||||||
in Just (fst gt, ty)
|
vt = G.varType x
|
||||||
|
in Just (preds', flip (,) vt <$> getTyVar_maybe ctt)
|
||||||
|
| otherwise = Nothing
|
||||||
|
sty = snd gt
|
||||||
|
preds = concatMap fst ctys
|
||||||
|
subs = mkTopTvSubst $ mapMaybe snd ctys
|
||||||
|
ty = substTy subs $ mkFunTys preds sty
|
||||||
|
in Just (fst gt, tidyTopType ty)
|
||||||
getPreds x | isForAllTy x = getPreds $ dropForAlls x
|
getPreds x | isForAllTy x = getPreds $ dropForAlls x
|
||||||
| Just (c, t) <- splitFunTy_maybe x
|
| Just (c, t) <- splitFunTy_maybe x
|
||||||
, isPredTy c = first (c:) $ getPreds t
|
, isPredTy c = first (c:) $ getPreds t
|
||||||
|
Loading…
Reference in New Issue
Block a user