@@ -9,27 +9,32 @@ import Flags(Flags)
99
1010import PreIds (idSizeOf )
1111import ISyntax
12+ import Changed
1213import IConv (iConvT )
1314import SymTab
1415
1516iNormTypes :: Flags -> SymTab -> IModule a -> IModule a
1617iNormTypes flags symt = iNorm fullNorm
17- where fullNorm c@ (ITCon _ _ _) = c
18- fullNorm n@ (ITNum _) = n
19- fullNorm s@ (ITStr _) = s
20- fullNorm v@ (ITVar i) = v
21- fullNorm (ITForAll i k t) = ITForAll i k $ fullNorm t
22- fullNorm (ITAp f@ (ITCon op _ _) a)
23- | op == idSizeOf && canNorm a' = normalizeSizeOf $ ITAp f a'
24- where a' = fullNorm a
18+ where fullNorm :: IType -> IType
19+ fullNorm t = changedOr t $ fullNorm' t
20+
21+ fullNorm' :: IType -> Changed IType
22+ fullNorm' tf@ (ITForAll i k t) = changed1 (ITForAll i k) (fullNorm' t)
23+ fullNorm' (ITAp f@ (ITCon op _ _) a)
24+ | op == idSizeOf && canNorm a' = Changed $ normalizeSizeOf $ ITAp f a'
25+ where -- Could use changedOr directly, but fullNorm does the right thing
26+ -- because we will normalize this type whether or not a changes
27+ a' = fullNorm a
2528 -- iToCT which we use below cannot handle ITVar and ITForAll
2629 canNorm (ITVar _) = False
2730 canNorm (ITForAll _ _ _) = False
2831 canNorm (ITAp f a) = canNorm f && canNorm a
2932 canNorm _ = True
30- fullNorm t@ (ITAp f a) = normITAp f' a'
31- where f' = fullNorm f
32- a' = fullNorm a
33+ fullNorm' t@ (ITAp f a) = changed2 normITAp f a f' a'
34+ where f' = fullNorm' f
35+ a' = fullNorm' a
36+ fullNorm' _ = Unchanged
37+
3338 normalizeSizeOf t =
3439 let t' = iConvT flags symt $ iToCT t
3540 in case t' of
0 commit comments