Skip to content

Commit

Permalink
Hack attempt #2
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Jun 11, 2024
1 parent 689bb50 commit 2e52950
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src-ghc-9.4/GHC/TypeLits/Normalise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,9 @@ simplifyNats opts@Opts {..} leqT eqsG eqsW = do
x' = substsSOP subst x
y' = substsSOP subst y
uS = (x',y',b)
leqsG' | isGiven (ctEvidence ct) = (x',y',b):leqsG
| otherwise = leqsG
isG = isGiven (ctEvidence ct)
leqsG' | isG = (x',y',b):leqsG
| otherwise = leqsG
ineqs = concat [ leqsG
, map (substLeq subst) leqsG
, map snd (rights (map fst eqsG))
Expand All @@ -519,7 +520,7 @@ simplifyNats opts@Opts {..} leqT eqsG eqsW = do
evs' <- maybe evs (:evs) <$> evMagic ct knW (subToPred opts leqT k)
simples subst evs' leqsG' xs eqs'

Just (False,_) | null k -> return (Impossible (fst eq))
Just (False,_) | null k && not isG -> return (Impossible (fst eq))
_ -> do
let solvedIneq = mapMaybe runWriterT
-- it is an inequality that can be instantly solved, such as
Expand Down
6 changes: 3 additions & 3 deletions src/GHC/TypeLits/Normalise/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ unifiers' ct (S ((P [I i]):ps1)) (S ((P [I j]):ps2))
unifiers' ct s1@(S ps1) s2@(S ps2) = case sopToIneq k1 of
Just (s1',s2',_)
| s1' /= s1 || s2' /= s1
, maybe False (uncurry (&&) . second Set.null) (runWriterT (isNatural s1'))
, maybe False (uncurry (&&) . second Set.null) (runWriterT (isNatural s2'))
, maybe True (uncurry (&&) . second Set.null) (runWriterT (isNatural s1'))
, maybe True (uncurry (&&) . second Set.null) (runWriterT (isNatural s2'))
-> unifiers' ct s1' s2'
_ | null psx
, length ps1 == length ps2
Expand Down Expand Up @@ -655,7 +655,7 @@ isNatural (S []) = return True
isNatural (S [P []]) = return True
isNatural (S [P (I i:ps)])
| i >= 0 = isNatural (S [P ps])
| otherwise = WriterT Nothing
| otherwise = return False
-- If i is not a natural number then their sum *might* be natural,
-- but we simply can't be sure since ps might be zero
isNatural (S [P (V _:ps)]) = isNatural (S [P ps])
Expand Down

0 comments on commit 2e52950

Please sign in to comment.