diff options
author | Sebastian Graf <sgraf1337@gmail.com> | 2019-09-16 16:04:00 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-09-21 09:52:34 -0400 |
commit | 1ea8c451375be9829df22e87213137e71c9c05ac (patch) | |
tree | 1ac781519986068f4b852c62ca58a24147d25c76 /compiler/utils | |
parent | 0dad81ca5fd1f63bf8a3b6ad09787559e8bd05c0 (diff) | |
download | haskell-1ea8c451375be9829df22e87213137e71c9c05ac.tar.gz |
PredType for type constraints in the pattern match checker instead of EvVar
Using EvVars for capturing type constraints implied side-effects in DsM
when we just wanted to *construct* type constraints.
But giving names to type constraints is only necessary when passing
Givens to the type checker, of which the majority of the pattern match
checker should be unaware.
Thus, we simply generate `newtype TyCt = TyCt PredType`, which are
nicely stateless. But at the same time this means we have to allocate
EvVars when we want to query the type oracle! So we keep the type oracle
state as `newtype TyState = TySt (Bag EvVar)`, which nicely makes a
distinction between new, unchecked `TyCt`s and the inert set in
`TyState`.
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Bag.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/utils/Bag.hs b/compiler/utils/Bag.hs index be46640920..e1eea48000 100644 --- a/compiler/utils/Bag.hs +++ b/compiler/utils/Bag.hs @@ -327,3 +327,9 @@ instance Foldable.Foldable Bag where foldl' k z (UnitBag x) = k z x foldl' k z (TwoBags b1 b2) = let r1 = foldl' k z b1 in seq r1 $ foldl' k r1 b2 foldl' k z (ListBag xs) = foldl' k z xs + +instance Traversable Bag where + traverse _ EmptyBag = pure EmptyBag + traverse f (UnitBag x) = UnitBag <$> f x + traverse f (TwoBags b1 b2) = TwoBags <$> traverse f b1 <*> traverse f b2 + traverse f (ListBag xs) = ListBag <$> traverse f xs |