Skip to content

Commit

Permalink
Reduce inside arithmetic equations
Browse files Browse the repository at this point in the history
  • Loading branch information
christiaanb committed Mar 9, 2020
1 parent ae29109 commit 9e7eb8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GHC/TypeLits/Extra/Solver/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ normaliseNat defs (TyConApp tc tys) = do
tyM <- lift (matchFam tc tys')
case tyM of
Just (_,ty) -> normaliseNat defs ty
_ -> let q = fst (runWriter (Normalise.normaliseNat (TyConApp tc tys)))
_ -> let q = fst (runWriter (Normalise.normaliseNat (TyConApp tc tys')))
in return (C (CType (Normalise.reifySOP q)))

normaliseNat _ t = return (C (CType t))
Expand Down
11 changes: 11 additions & 0 deletions tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ test51
-> Proxy (2+((2^n)*2))
test51 _ = id

type family BitPack a :: Nat

test52
:: Proxy a
-> Proxy (1 + BitPack a)
-> Proxy (Max 0 (BitPack a) + CLog 2 2)
test52 _ = id

main :: IO ()
main = defaultMain tests

Expand Down Expand Up @@ -342,6 +350,9 @@ tests = testGroup "ghc-typelits-natnormalise"
, testCase "forall n . Max (((2 ^ n) + 1) + ((2 ^ n) + 1)) 1 ~ 2 + ((2 ^ n) * 2)" $
show (test51 Proxy Proxy) @?=
"Proxy"
, testCase "forall a . (1 + BitPack a) ~ (Max 0 (BitPack a) + CLog 2 2" $
show (test52 Proxy Proxy) @?=
"Proxy"
]
, testGroup "errors"
[ testCase "GCD 6 8 /~ 4" $ testFail1 `throws` testFail1Errors
Expand Down

0 comments on commit 9e7eb8a

Please sign in to comment.