strongweak 0.8.0 → 0.9.0
raw patch · 3 files changed
+18/−12 lines, 3 filesdep ~text-builder-linear
Dependency ranges changed: text-builder-linear
Files
- CHANGELOG.md +4/−0
- src/Strongweak/Strengthen.hs +10/−8
- strongweak.cabal +4/−4
CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.9.0 (2024-10-01)+* fix `Strengthen [a]` instance reversing list+* support GHC 9.4 - GHC 9.8+ ## 0.8.0 (2024-06-11) * no longer use `Validation`: failures now must wrap explicitly instead of being implicitly collated
src/Strongweak/Strengthen.hs view
@@ -128,12 +128,15 @@ -- | Strengthen a plain list into a sized vector by asserting length. instance (VG.Vector v a, KnownNat n) => Strengthen (VGS.Vector v n a) where- -- TODO another case of TBL not supporting unbounded integrals+ -- as of text-linear-builder-0.1.3, we can use 'fromUnboundedDec' for the+ -- phantom vector size+ -- I don't believe you can actually ever construct a vector with size+ -- greater than @'maxBound' \@'Int'@. but still! strengthen as = case VGS.fromList as of Just va -> Right va Nothing -> failStrengthen1 $- [ "type: [a] -> Vector v "<>fromString (show n)<>" a"+ [ "type: [a] -> Vector v "<>TBL.fromUnboundedDec n<>" a" , "fail: wrong length (got "<>TBL.fromDec (length as)<>")" ] where n = natVal'' @n @@ -168,12 +171,10 @@ -- -- @n@ must be "wider" than @m@. ----- @'FiniteBits' m@ and @'Show' n@ are for error printing. We're forced to--- @'Show' n@ because linear-text-builder can't print unbounded integrals. PR:--- https://github.com/Bodigrim/linear-builder/pull/20+-- @'FiniteBits' m@ is for error printing. strengthenBounded :: forall m n- . ( Typeable n, Integral n, Show n+ . ( Typeable n, Integral n , Typeable m, Integral m, Bounded m, FiniteBits m ) => n -> Either StrengthenFailure' m strengthenBounded n@@ -182,7 +183,7 @@ [ "numeric strengthen: "<>fromString (show (typeRep' @n)) <>" -> "<>fromString (show (typeRep' @m)) , "bounds check does not hold: "- <>TBL.fromDec minBm<>" <= "<>fromString (show n)+ <>TBL.fromDec minBm<>" <= "<>TBL.fromUnboundedDec n <>" <= "<>TBL.fromDec maxBm ] where@@ -197,6 +198,7 @@ instance Strengthen a => Strengthen [a] where strengthen = strengthenList +-- TODO using reverse, SLOW!! >:( strengthenList :: Strengthen a => [Weak a] -> Either StrengthenFailure' [a] strengthenList = goR (0 :: Int) [] . map strengthen where@@ -205,7 +207,7 @@ case r of Right a -> goR (i+1) (a:as) rs Left e -> goL (i+1) [(TBL.fromDec i, e)] rs- [] -> Right as+ [] -> Right (reverse as) goL i es = \case r:rs -> case r of
strongweak.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2.+-- This file has been generated from package.yaml by hpack version 0.36.1. -- -- see: https://github.com/sol/hpack name: strongweak-version: 0.8.0+version: 0.9.0 synopsis: Convert between strong and weak representations of types description: Please see README.md. category: Data@@ -57,7 +57,7 @@ base >=4.18 && <5 , rerefined >=0.5.0 && <0.6 , text >=2.0 && <2.2- , text-builder-linear >=0.1.2 && <0.2+ , text-builder-linear >=0.1.3 && <0.2 , vector >=0.12.3.1 && <0.14 , vector-sized >=1.5.0 && <1.7 default-language: GHC2021@@ -94,7 +94,7 @@ , rerefined >=0.5.0 && <0.6 , strongweak , text >=2.0 && <2.2- , text-builder-linear >=0.1.2 && <0.2+ , text-builder-linear >=0.1.3 && <0.2 , vector >=0.12.3.1 && <0.14 , vector-sized >=1.5.0 && <1.7 default-language: GHC2021