File tree 4 files changed +14
-15
lines changed
src/GHC/TypeLits/Normalise
src-pre-ghc-9.4/GHC/TypeLits 4 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -507,8 +507,9 @@ simplifyNats opts@Opts {..} leqT eqsG eqsW = do
507
507
x' = substsSOP subst x
508
508
y' = substsSOP subst y
509
509
uS = (x',y',b)
510
- leqsG' | isGiven (ctEvidence ct) = (x',y',b): leqsG
511
- | otherwise = leqsG
510
+ isG = isGiven (ctEvidence ct)
511
+ leqsG' | isG = (x',y',b): leqsG
512
+ | otherwise = leqsG
512
513
ineqs = concat [ leqsG
513
514
, map (substLeq subst) leqsG
514
515
, map snd (rights (map fst eqsG))
@@ -519,7 +520,7 @@ simplifyNats opts@Opts {..} leqT eqsG eqsW = do
519
520
evs' <- maybe evs (: evs) <$> evMagic ct knW (subToPred opts leqT k)
520
521
simples subst evs' leqsG' xs eqs'
521
522
522
- Just (False ,_) | null k -> return (Impossible (fst eq))
523
+ Just (False ,_) | null k && not isG -> return (Impossible (fst eq))
523
524
_ -> do
524
525
let solvedIneq = mapMaybe runWriterT
525
526
-- it is an inequality that can be instantly solved, such as
Original file line number Diff line number Diff line change @@ -640,8 +640,9 @@ simplifyNats opts@Opts {..} ordCond eqsG eqsW = do
640
640
x' = substsSOP subst x
641
641
y' = substsSOP subst y
642
642
uS = (x',y',b)
643
- leqsG' | isGiven (ctEvidence ct) = (x',y',b): leqsG
644
- | otherwise = leqsG
643
+ isG = isGiven (ctEvidence ct)
644
+ leqsG' | isG = (x',y',b): leqsG
645
+ | otherwise = leqsG
645
646
ineqs = concat [ leqsG
646
647
, map (substLeq subst) leqsG
647
648
, map snd (rights (map fst eqsG))
@@ -652,7 +653,7 @@ simplifyNats opts@Opts {..} ordCond eqsG eqsW = do
652
653
evs' <- maybe evs (: evs) <$> evMagic ct knW (subToPred opts ordCond k)
653
654
simples subst evs' leqsG' xs eqs'
654
655
655
- Just (False ,_) | null k -> return (Impossible (fst eq))
656
+ Just (False ,_) | null k && not isG -> return (Impossible (fst eq))
656
657
_ -> do
657
658
let solvedIneq = mapMaybe runWriterT
658
659
-- it is an inequality that can be instantly solved, such as
Original file line number Diff line number Diff line change @@ -568,8 +568,8 @@ unifiers' ct (S ((P [I i]):ps1)) (S ((P [I j]):ps2))
568
568
unifiers' ct s1@ (S ps1) s2@ (S ps2) = case sopToIneq k1 of
569
569
Just (s1',s2',_)
570
570
| s1' /= s1 || s2' /= s1
571
- , maybe False (uncurry (&&) . second Set. null ) (runWriterT (isNatural s1'))
572
- , maybe False (uncurry (&&) . second Set. null ) (runWriterT (isNatural s2'))
571
+ , maybe True (uncurry (&&) . second Set. null ) (runWriterT (isNatural s1'))
572
+ , maybe True (uncurry (&&) . second Set. null ) (runWriterT (isNatural s2'))
573
573
-> unifiers' ct s1' s2'
574
574
_ | null psx
575
575
, length ps1 == length ps2
@@ -655,7 +655,7 @@ isNatural (S []) = return True
655
655
isNatural (S [P [] ]) = return True
656
656
isNatural (S [P (I i: ps)])
657
657
| i >= 0 = isNatural (S [P ps])
658
- | otherwise = WriterT Nothing
658
+ | otherwise = return False
659
659
-- If i is not a natural number then their sum *might* be natural,
660
660
-- but we simply can't be sure since ps might be zero
661
661
isNatural (S [P (V _: ps)]) = isNatural (S [P ps])
Original file line number Diff line number Diff line change @@ -508,11 +508,8 @@ oneLtPowSubst = go
508
508
go :: 1 <= b => Proxy a -> Proxy a
509
509
go = id
510
510
511
- givenLEZeroNotImpossible :: forall (a :: Nat ) . Proxy a -> a <= 0 => ()
512
- givenLEZeroNotImpossible _ = go (Proxy @ (a + a - a ))
513
- where
514
- go :: Proxy b -> b <= 0 => ()
515
- go _ = ()
511
+ givenLEZeroNotImpossible :: forall (a :: Nat ) . Proxy (a <= 0 ) -> Proxy 'True
512
+ givenLEZeroNotImpossible p = id (Proxy @ (a + 0 <=? 0 ))
516
513
517
514
main :: IO ()
518
515
main = defaultMain tests
@@ -618,7 +615,7 @@ tests = testGroup "ghc-typelits-natnormalise"
618
615
show (oneLtPowSubst (Proxy :: Proxy 0 )) @?=
619
616
" Proxy"
620
617
, testCase " given a <= 0 is not impossible" $
621
- givenLEZeroNotImpossible (Proxy @ 0 ) @?= ()
618
+ givenLEZeroNotImpossible (Proxy @ ( 0 <=? 0 )) @?= Proxy
622
619
]
623
620
, testGroup " errors"
624
621
[ testCase " x + 2 ~ 3 + x" $ testProxy1 `throws` testProxy1Errors
You can’t perform that action at this time.
0 commit comments