{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GADTs #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.Tc.Solver.Types (
DictMap, emptyDictMap, findDictsByClass, addDict,
addDictsByClass, delDict, foldDicts, filterDicts, findDict,
dictsToBag, partitionDicts,
FunEqMap, emptyFunEqs, foldFunEqs, findFunEq, insertFunEq,
findFunEqsByTyCon,
TcAppMap, emptyTcAppMap, isEmptyTcAppMap,
insertTcApp, alterTcApp, filterTcAppMap,
tcAppMapToBag, foldTcAppMap,
EqualCtList, filterEqualCtList, addToEqualCtList
) where
import GHC.Prelude
import GHC.Tc.Types.Constraint
import GHC.Tc.Types.Origin
import GHC.Tc.Utils.TcType
import GHC.Core.Class
import GHC.Core.Map.Type
import GHC.Core.Predicate
import GHC.Core.TyCon
import GHC.Core.TyCon.Env
import GHC.Data.Bag
import GHC.Data.Maybe
import GHC.Data.TrieMap
import GHC.Utils.Constants
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
type TcAppMap a = DTyConEnv (ListMap LooseTypeMap a)
isEmptyTcAppMap :: TcAppMap a -> Bool
isEmptyTcAppMap :: forall a. TcAppMap a -> Bool
isEmptyTcAppMap TcAppMap a
m = TcAppMap a -> Bool
forall a. DTyConEnv a -> Bool
isEmptyDTyConEnv TcAppMap a
m
emptyTcAppMap :: TcAppMap a
emptyTcAppMap :: forall a. TcAppMap a
emptyTcAppMap = DTyConEnv (ListMap LooseTypeMap a)
forall a. DTyConEnv a
emptyDTyConEnv
findTcApp :: TcAppMap a -> TyCon -> [Type] -> Maybe a
findTcApp :: forall a. TcAppMap a -> TyCon -> [Xi] -> Maybe a
findTcApp TcAppMap a
m TyCon
tc [Xi]
tys = do { ListMap LooseTypeMap a
tys_map <- TcAppMap a -> TyCon -> Maybe (ListMap LooseTypeMap a)
forall a. DTyConEnv a -> TyCon -> Maybe a
lookupDTyConEnv TcAppMap a
m TyCon
tc
; Key (ListMap LooseTypeMap) -> ListMap LooseTypeMap a -> Maybe a
forall b.
Key (ListMap LooseTypeMap) -> ListMap LooseTypeMap b -> Maybe b
forall (m :: * -> *) b. TrieMap m => Key m -> m b -> Maybe b
lookupTM [Xi]
Key (ListMap LooseTypeMap)
tys ListMap LooseTypeMap a
tys_map }
delTcApp :: TcAppMap a -> TyCon -> [Type] -> TcAppMap a
delTcApp :: forall a. TcAppMap a -> TyCon -> [Xi] -> TcAppMap a
delTcApp TcAppMap a
m TyCon
tc [Xi]
tys = (ListMap LooseTypeMap a -> ListMap LooseTypeMap a)
-> TcAppMap a -> TyCon -> TcAppMap a
forall a. (a -> a) -> DTyConEnv a -> TyCon -> DTyConEnv a
adjustDTyConEnv (Key (ListMap LooseTypeMap)
-> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall (m :: * -> *) a. TrieMap m => Key m -> m a -> m a
deleteTM [Xi]
Key (ListMap LooseTypeMap)
tys) TcAppMap a
m TyCon
tc
insertTcApp :: TcAppMap a -> TyCon -> [Type] -> a -> TcAppMap a
insertTcApp :: forall a. TcAppMap a -> TyCon -> [Xi] -> a -> TcAppMap a
insertTcApp TcAppMap a
m TyCon
tc [Xi]
tys a
ct = (Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a))
-> TcAppMap a -> TyCon -> TcAppMap a
forall a.
(Maybe a -> Maybe a) -> DTyConEnv a -> TyCon -> DTyConEnv a
alterDTyConEnv Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a)
alter_tm TcAppMap a
m TyCon
tc
where
alter_tm :: Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a)
alter_tm Maybe (ListMap LooseTypeMap a)
mb_tm = ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a)
forall a. a -> Maybe a
Just (Key (ListMap LooseTypeMap)
-> a -> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall (m :: * -> *) a. TrieMap m => Key m -> a -> m a -> m a
insertTM [Xi]
Key (ListMap LooseTypeMap)
tys a
ct (Maybe (ListMap LooseTypeMap a)
mb_tm Maybe (ListMap LooseTypeMap a)
-> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall a. Maybe a -> a -> a
`orElse` ListMap LooseTypeMap a
forall a. ListMap LooseTypeMap a
forall (m :: * -> *) a. TrieMap m => m a
emptyTM))
alterTcApp :: forall a. TcAppMap a -> TyCon -> [Type] -> XT a -> TcAppMap a
alterTcApp :: forall a. TcAppMap a -> TyCon -> [Xi] -> XT a -> TcAppMap a
alterTcApp TcAppMap a
m TyCon
tc [Xi]
tys XT a
upd = (Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a))
-> TcAppMap a -> TyCon -> TcAppMap a
forall a.
(Maybe a -> Maybe a) -> DTyConEnv a -> TyCon -> DTyConEnv a
alterDTyConEnv Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a)
alter_tm TcAppMap a
m TyCon
tc
where
alter_tm :: Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a)
alter_tm :: Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a)
alter_tm Maybe (ListMap LooseTypeMap a)
m_elt = ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a)
forall a. a -> Maybe a
Just (Key (ListMap LooseTypeMap)
-> XT a -> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall b.
Key (ListMap LooseTypeMap)
-> XT b -> ListMap LooseTypeMap b -> ListMap LooseTypeMap b
forall (m :: * -> *) b. TrieMap m => Key m -> XT b -> m b -> m b
alterTM [Xi]
Key (ListMap LooseTypeMap)
tys XT a
upd (Maybe (ListMap LooseTypeMap a)
m_elt Maybe (ListMap LooseTypeMap a)
-> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall a. Maybe a -> a -> a
`orElse` ListMap LooseTypeMap a
forall a. ListMap LooseTypeMap a
forall (m :: * -> *) a. TrieMap m => m a
emptyTM))
filterTcAppMap :: forall a. (a -> Bool) -> TcAppMap a -> TcAppMap a
filterTcAppMap :: forall a. (a -> Bool) -> TcAppMap a -> TcAppMap a
filterTcAppMap a -> Bool
f TcAppMap a
m = (ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a))
-> TcAppMap a -> TcAppMap a
forall a b. (a -> Maybe b) -> DTyConEnv a -> DTyConEnv b
mapMaybeDTyConEnv ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a)
one_tycon TcAppMap a
m
where
one_tycon :: ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a)
one_tycon :: ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a)
one_tycon ListMap LooseTypeMap a
tm
| ListMap LooseTypeMap a -> Bool
forall (m :: * -> *) a. TrieMap m => m a -> Bool
isEmptyTM ListMap LooseTypeMap a
filtered_tm = Maybe (ListMap LooseTypeMap a)
forall a. Maybe a
Nothing
| Bool
otherwise = ListMap LooseTypeMap a -> Maybe (ListMap LooseTypeMap a)
forall a. a -> Maybe a
Just ListMap LooseTypeMap a
filtered_tm
where
filtered_tm :: ListMap LooseTypeMap a
filtered_tm = (a -> Bool) -> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall a.
(a -> Bool) -> ListMap LooseTypeMap a -> ListMap LooseTypeMap a
forall (m :: * -> *) a. TrieMap m => (a -> Bool) -> m a -> m a
filterTM a -> Bool
f ListMap LooseTypeMap a
tm
tcAppMapToBag :: TcAppMap a -> Bag a
tcAppMapToBag :: forall a. TcAppMap a -> Bag a
tcAppMapToBag TcAppMap a
m = (a -> Bag a -> Bag a) -> TcAppMap a -> Bag a -> Bag a
forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldTcAppMap a -> Bag a -> Bag a
forall a. a -> Bag a -> Bag a
consBag TcAppMap a
m Bag a
forall a. Bag a
emptyBag
foldTcAppMap :: (a -> b -> b) -> TcAppMap a -> b -> b
foldTcAppMap :: forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldTcAppMap a -> b -> b
k TcAppMap a
m b
z = (ListMap LooseTypeMap a -> b -> b) -> b -> TcAppMap a -> b
forall elt a. (elt -> a -> a) -> a -> DTyConEnv elt -> a
foldDTyConEnv ((a -> b -> b) -> ListMap LooseTypeMap a -> b -> b
forall a b. (a -> b -> b) -> ListMap LooseTypeMap a -> b -> b
forall (m :: * -> *) a b.
TrieMap m =>
(a -> b -> b) -> m a -> b -> b
foldTM a -> b -> b
k) b
z TcAppMap a
m
type DictMap a = TcAppMap a
emptyDictMap :: DictMap a
emptyDictMap :: forall a. TcAppMap a
emptyDictMap = TcAppMap a
forall a. TcAppMap a
emptyTcAppMap
findDict :: DictMap a -> CtLoc -> Class -> [Type] -> Maybe a
findDict :: forall a. DictMap a -> CtLoc -> Class -> [Xi] -> Maybe a
findDict DictMap a
m CtLoc
loc Class
cls [Xi]
tys
| Class -> [Xi] -> Bool
hasIPSuperClasses Class
cls [Xi]
tys
= Maybe a
forall a. Maybe a
Nothing
| Just {} <- Class -> [Xi] -> Maybe FastString
isCallStackPred Class
cls [Xi]
tys
, CtOrigin -> Bool
isPushCallStackOrigin (CtLoc -> CtOrigin
ctLocOrigin CtLoc
loc)
= Maybe a
forall a. Maybe a
Nothing
| Bool
otherwise
= DictMap a -> TyCon -> [Xi] -> Maybe a
forall a. TcAppMap a -> TyCon -> [Xi] -> Maybe a
findTcApp DictMap a
m (Class -> TyCon
classTyCon Class
cls) [Xi]
tys
findDictsByClass :: DictMap a -> Class -> Bag a
findDictsByClass :: forall a. DictMap a -> Class -> Bag a
findDictsByClass DictMap a
m Class
cls
| Just ListMap LooseTypeMap a
tm <- DictMap a -> TyCon -> Maybe (ListMap LooseTypeMap a)
forall a. DTyConEnv a -> TyCon -> Maybe a
lookupDTyConEnv DictMap a
m (Class -> TyCon
classTyCon Class
cls) = (a -> Bag a -> Bag a) -> ListMap LooseTypeMap a -> Bag a -> Bag a
forall a b. (a -> b -> b) -> ListMap LooseTypeMap a -> b -> b
forall (m :: * -> *) a b.
TrieMap m =>
(a -> b -> b) -> m a -> b -> b
foldTM a -> Bag a -> Bag a
forall a. a -> Bag a -> Bag a
consBag ListMap LooseTypeMap a
tm Bag a
forall a. Bag a
emptyBag
| Bool
otherwise = Bag a
forall a. Bag a
emptyBag
delDict :: DictMap a -> Class -> [Type] -> DictMap a
delDict :: forall a. DictMap a -> Class -> [Xi] -> DictMap a
delDict DictMap a
m Class
cls [Xi]
tys = DictMap a -> TyCon -> [Xi] -> DictMap a
forall a. TcAppMap a -> TyCon -> [Xi] -> TcAppMap a
delTcApp DictMap a
m (Class -> TyCon
classTyCon Class
cls) [Xi]
tys
addDict :: DictMap a -> Class -> [Type] -> a -> DictMap a
addDict :: forall a. DictMap a -> Class -> [Xi] -> a -> DictMap a
addDict DictMap a
m Class
cls [Xi]
tys a
item = DictMap a -> TyCon -> [Xi] -> a -> DictMap a
forall a. TcAppMap a -> TyCon -> [Xi] -> a -> TcAppMap a
insertTcApp DictMap a
m (Class -> TyCon
classTyCon Class
cls) [Xi]
tys a
item
addDictsByClass :: DictMap Ct -> Class -> Bag Ct -> DictMap Ct
addDictsByClass :: DictMap Ct -> Class -> Bag Ct -> DictMap Ct
addDictsByClass DictMap Ct
m Class
cls Bag Ct
items
= DictMap Ct -> TyCon -> ListMap LooseTypeMap Ct -> DictMap Ct
forall a. DTyConEnv a -> TyCon -> a -> DTyConEnv a
extendDTyConEnv DictMap Ct
m (Class -> TyCon
classTyCon Class
cls) ((Ct -> ListMap LooseTypeMap Ct -> ListMap LooseTypeMap Ct)
-> ListMap LooseTypeMap Ct -> Bag Ct -> ListMap LooseTypeMap Ct
forall a b. (a -> b -> b) -> b -> Bag a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Ct -> ListMap LooseTypeMap Ct -> ListMap LooseTypeMap Ct
forall {m :: * -> *}.
(Key m ~ [Xi], TrieMap m) =>
Ct -> m Ct -> m Ct
add ListMap LooseTypeMap Ct
forall a. ListMap LooseTypeMap a
forall (m :: * -> *) a. TrieMap m => m a
emptyTM Bag Ct
items)
where
add :: Ct -> m Ct -> m Ct
add ct :: Ct
ct@(CDictCan { cc_tyargs :: Ct -> [Xi]
cc_tyargs = [Xi]
tys }) m Ct
tm = Key m -> Ct -> m Ct -> m Ct
forall (m :: * -> *) a. TrieMap m => Key m -> a -> m a -> m a
insertTM [Xi]
Key m
tys Ct
ct m Ct
tm
add Ct
ct m Ct
_ = String -> SDoc -> m Ct
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"addDictsByClass" (Ct -> SDoc
forall a. Outputable a => a -> SDoc
ppr Ct
ct)
filterDicts :: (Ct -> Bool) -> DictMap Ct -> DictMap Ct
filterDicts :: (Ct -> Bool) -> DictMap Ct -> DictMap Ct
filterDicts Ct -> Bool
f DictMap Ct
m = (Ct -> Bool) -> DictMap Ct -> DictMap Ct
forall a. (a -> Bool) -> TcAppMap a -> TcAppMap a
filterTcAppMap Ct -> Bool
f DictMap Ct
m
partitionDicts :: (Ct -> Bool) -> DictMap Ct -> (Bag Ct, DictMap Ct)
partitionDicts :: (Ct -> Bool) -> DictMap Ct -> (Bag Ct, DictMap Ct)
partitionDicts Ct -> Bool
f DictMap Ct
m = (Ct -> (Bag Ct, DictMap Ct) -> (Bag Ct, DictMap Ct))
-> DictMap Ct -> (Bag Ct, DictMap Ct) -> (Bag Ct, DictMap Ct)
forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldTcAppMap Ct -> (Bag Ct, DictMap Ct) -> (Bag Ct, DictMap Ct)
k DictMap Ct
m (Bag Ct
forall a. Bag a
emptyBag, DictMap Ct
forall a. TcAppMap a
emptyDictMap)
where
k :: Ct -> (Bag Ct, DictMap Ct) -> (Bag Ct, DictMap Ct)
k Ct
ct (Bag Ct
yeses, DictMap Ct
noes) | Ct -> Bool
f Ct
ct = (Ct
ct Ct -> Bag Ct -> Bag Ct
forall a. a -> Bag a -> Bag a
`consBag` Bag Ct
yeses, DictMap Ct
noes)
| Bool
otherwise = (Bag Ct
yeses, Ct -> DictMap Ct -> DictMap Ct
add Ct
ct DictMap Ct
noes)
add :: Ct -> DictMap Ct -> DictMap Ct
add ct :: Ct
ct@(CDictCan { cc_class :: Ct -> Class
cc_class = Class
cls, cc_tyargs :: Ct -> [Xi]
cc_tyargs = [Xi]
tys }) DictMap Ct
m
= DictMap Ct -> Class -> [Xi] -> Ct -> DictMap Ct
forall a. DictMap a -> Class -> [Xi] -> a -> DictMap a
addDict DictMap Ct
m Class
cls [Xi]
tys Ct
ct
add Ct
ct DictMap Ct
_ = String -> SDoc -> DictMap Ct
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"partitionDicts" (Ct -> SDoc
forall a. Outputable a => a -> SDoc
ppr Ct
ct)
dictsToBag :: DictMap a -> Bag a
dictsToBag :: forall a. TcAppMap a -> Bag a
dictsToBag = TcAppMap a -> Bag a
forall a. TcAppMap a -> Bag a
tcAppMapToBag
foldDicts :: (a -> b -> b) -> DictMap a -> b -> b
foldDicts :: forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldDicts = (a -> b -> b) -> TcAppMap a -> b -> b
forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldTcAppMap
type FunEqMap a = TcAppMap a
emptyFunEqs :: TcAppMap a
emptyFunEqs :: forall a. TcAppMap a
emptyFunEqs = TcAppMap a
forall a. TcAppMap a
emptyTcAppMap
findFunEq :: FunEqMap a -> TyCon -> [Type] -> Maybe a
findFunEq :: forall a. TcAppMap a -> TyCon -> [Xi] -> Maybe a
findFunEq FunEqMap a
m TyCon
tc [Xi]
tys = FunEqMap a -> TyCon -> [Xi] -> Maybe a
forall a. TcAppMap a -> TyCon -> [Xi] -> Maybe a
findTcApp FunEqMap a
m TyCon
tc [Xi]
tys
findFunEqsByTyCon :: FunEqMap a -> TyCon -> [a]
findFunEqsByTyCon :: forall a. FunEqMap a -> TyCon -> [a]
findFunEqsByTyCon FunEqMap a
m TyCon
tc
| Just ListMap LooseTypeMap a
tm <- FunEqMap a -> TyCon -> Maybe (ListMap LooseTypeMap a)
forall a. DTyConEnv a -> TyCon -> Maybe a
lookupDTyConEnv FunEqMap a
m TyCon
tc = (a -> [a] -> [a]) -> ListMap LooseTypeMap a -> [a] -> [a]
forall a b. (a -> b -> b) -> ListMap LooseTypeMap a -> b -> b
forall (m :: * -> *) a b.
TrieMap m =>
(a -> b -> b) -> m a -> b -> b
foldTM (:) ListMap LooseTypeMap a
tm []
| Bool
otherwise = []
foldFunEqs :: (a -> b -> b) -> FunEqMap a -> b -> b
foldFunEqs :: forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldFunEqs = (a -> b -> b) -> TcAppMap a -> b -> b
forall a b. (a -> b -> b) -> TcAppMap a -> b -> b
foldTcAppMap
insertFunEq :: FunEqMap a -> TyCon -> [Type] -> a -> FunEqMap a
insertFunEq :: forall a. TcAppMap a -> TyCon -> [Xi] -> a -> TcAppMap a
insertFunEq FunEqMap a
m TyCon
tc [Xi]
tys a
val = FunEqMap a -> TyCon -> [Xi] -> a -> FunEqMap a
forall a. TcAppMap a -> TyCon -> [Xi] -> a -> TcAppMap a
insertTcApp FunEqMap a
m TyCon
tc [Xi]
tys a
val
type EqualCtList = [Ct]
addToEqualCtList :: Ct -> EqualCtList -> EqualCtList
addToEqualCtList :: Ct -> EqualCtList -> EqualCtList
addToEqualCtList Ct
ct EqualCtList
old_eqs
| Bool
debugIsOn
= case Ct
ct of
CEqCan { cc_lhs :: Ct -> CanEqLHS
cc_lhs = TyVarLHS TcTyVar
tv } ->
let shares_lhs :: Ct -> Bool
shares_lhs (CEqCan { cc_lhs :: Ct -> CanEqLHS
cc_lhs = TyVarLHS TcTyVar
old_tv }) = TcTyVar
tv TcTyVar -> TcTyVar -> Bool
forall a. Eq a => a -> a -> Bool
== TcTyVar
old_tv
shares_lhs Ct
_other = Bool
False
in
Bool -> EqualCtList -> EqualCtList
forall a. HasCallStack => Bool -> a -> a
assert ((Ct -> Bool) -> EqualCtList -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Ct -> Bool
shares_lhs EqualCtList
old_eqs) (EqualCtList -> EqualCtList) -> EqualCtList -> EqualCtList
forall a b. (a -> b) -> a -> b
$
Bool -> EqualCtList -> EqualCtList
forall a. HasCallStack => Bool -> a -> a
assert ([(Ct, Ct)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([ (Ct
ct1, Ct
ct2) | Ct
ct1 <- Ct
ct Ct -> EqualCtList -> EqualCtList
forall a. a -> [a] -> [a]
: EqualCtList
old_eqs
, Ct
ct2 <- Ct
ct Ct -> EqualCtList -> EqualCtList
forall a. a -> [a] -> [a]
: EqualCtList
old_eqs
, let { fr1 :: CtFlavourRole
fr1 = Ct -> CtFlavourRole
ctFlavourRole Ct
ct1
; fr2 :: CtFlavourRole
fr2 = Ct -> CtFlavourRole
ctFlavourRole Ct
ct2 }
, CtFlavourRole
fr1 CtFlavourRole -> CtFlavourRole -> Bool
`eqCanRewriteFR` CtFlavourRole
fr2 ])) (EqualCtList -> EqualCtList) -> EqualCtList -> EqualCtList
forall a b. (a -> b) -> a -> b
$
(Ct
ct Ct -> EqualCtList -> EqualCtList
forall a. a -> [a] -> [a]
: EqualCtList
old_eqs)
Ct
_ -> String -> SDoc -> EqualCtList
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"addToEqualCtList not CEqCan" (Ct -> SDoc
forall a. Outputable a => a -> SDoc
ppr Ct
ct)
| Bool
otherwise
= Ct
ct Ct -> EqualCtList -> EqualCtList
forall a. a -> [a] -> [a]
: EqualCtList
old_eqs
filterEqualCtList :: (Ct -> Bool) -> EqualCtList -> Maybe EqualCtList
filterEqualCtList :: (Ct -> Bool) -> EqualCtList -> Maybe EqualCtList
filterEqualCtList Ct -> Bool
pred EqualCtList
cts
| EqualCtList -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null EqualCtList
new_list
= Maybe EqualCtList
forall a. Maybe a
Nothing
| Bool
otherwise
= EqualCtList -> Maybe EqualCtList
forall a. a -> Maybe a
Just EqualCtList
new_list
where
new_list :: EqualCtList
new_list = (Ct -> Bool) -> EqualCtList -> EqualCtList
forall a. (a -> Bool) -> [a] -> [a]
filter Ct -> Bool
pred EqualCtList
cts