packages feed

ghc-typelits-extra 0.3.3 → 0.4

raw patch · 5 files changed

+21/−4 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog for the [`ghc-typelits-extra`](http://hackage.haskell.org/package/ghc-typelits-extra) package +# 0.4 *March 9 2020*+* `Max` short-circuits on zero, but is stuckness preserving. i.e. `Max (0-1) 0` reduces to `(0-1)`+* Reduce inside arithmetic equations. e.g. `1 + a ~ Max 0 a + CLog 2 2`+ # 0.3.3 *February 6th 2020* * Add support for GHC 8.10.1-alpha2 
ghc-typelits-extra.cabal view
@@ -1,5 +1,5 @@ name:                ghc-typelits-extra-version:             0.3.3+version:             0.4 synopsis:            Additional type-level operations on GHC.TypeLits.Nat description:   Additional type-level operations on @GHC.TypeLits.Nat@:
src/GHC/TypeLits/Extra/Solver/Operations.hs view
@@ -111,6 +111,8 @@                                                        ,reifyEOP defs y]  mergeMax :: ExtraDefs -> ExtraOp -> ExtraOp -> ExtraOp+mergeMax _ (I 0) y = y+mergeMax _ x (I 0) = x mergeMax defs x y =   let x' = reifyEOP defs x       y' = reifyEOP defs y
src/GHC/TypeLits/Extra/Solver/Unify.hs view
@@ -76,7 +76,7 @@   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))
tests/Main.hs view
@@ -132,7 +132,7 @@ test38 :: Proxy (Min (0-1) 0) -> Proxy (0-1) test38 = id -test39 :: Proxy (Max (0-1) 0) -> Proxy 0+test39 :: Proxy (Max (0-1) 0) -> Proxy (0-1) test39 = id  test40 :: Proxy x -> Proxy y -> Proxy (Max x y) -> Proxy (Max y x)@@ -183,6 +183,14 @@   -> 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 @@ -303,7 +311,7 @@     , testCase "Min (0-1) 0 ~ (0-1)" $       show (test38 Proxy) @?=       "Proxy"-    , testCase "Max (0-1) 0 ~ 0" $+    , testCase "Max (0-1) 0 ~ (0-1)" $       show (test39 Proxy) @?=       "Proxy"     , testCase "forall x y . Max x y ~ Max y x" $@@ -341,6 +349,9 @@       "Proxy"     , 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"