packages feed

checked-literals 0.1.1 → 0.1.2

raw patch · 6 files changed

+26/−33 lines, 6 filesdep −directorydep −filepathdep ~basedep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependencies removed: directory, filepath

Dependency ranges changed: base, template-haskell

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ # Revision history for `checked-literals` +## 0.1.2 -- 2026-05-22+* Made package testing structure more friendly for Nix builds+ ## 0.1.1 -- 2026-05-13 * Added support for macOS 
checked-literals.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name: checked-literals-version: 0.1.1+version: 0.1.2 synopsis: GHC plugin for checked numeric literals description:   GHC plugin that rewrites numeric literals so out-of-bounds and inexact@@ -20,6 +20,11 @@   CHANGELOG.md   README.md +data-files:+  src-nums/CheckedLiterals/Nums/Fixed.hs+  src-nums/CheckedLiterals/Nums/Signed.hs+  src-nums/CheckedLiterals/Nums/Unsigned.hs+ common warnings   ghc-options: -Wall @@ -78,36 +83,15 @@     NoStarIsType     TypeOperators --- XXX: These modules are just here to provide convincing tests for Clash-like types. They're---      not tested well in any way, are incomplete in their implementation, and are certainly---      not translatable to RTL.-library clash-nums-  import: warnings, typechecker-plugins, sane-records-  visibility: private-  exposed-modules:-    CheckedLiterals.Nums.Fixed-    CheckedLiterals.Nums.Signed-    CheckedLiterals.Nums.Unsigned--  build-depends:-    base,-    checked-literals,-    template-haskell,--  hs-source-dirs: src-nums-  default-language: GHC2021-  default-extensions:-    DataKinds-    NoStarIsType-    TypeOperators- test-suite unittests   import: warnings, typechecker-plugins, sane-records   type: exitcode-stdio-1.0   main-is: Main.hs   ghc-options: -fplugin=CheckedLiterals+  autogen-modules: Paths_checked_literals   other-modules:     Data.Ratio.Extra+    Paths_checked_literals     Test.Tasty.AssertGhc     Tests.Common     Tests.Integer@@ -132,9 +116,6 @@   build-depends:     base,     checked-literals,-    checked-literals:clash-nums,-    directory,-    filepath,     process,     string-interpolate >=0.3.4.0,     tasty >=0.10,
src-nums/CheckedLiterals/Nums/Fixed.hs view
@@ -12,6 +12,7 @@   CheckedNegativeRationalLiteral,   CheckedPositiveIntegerLiteral,   CheckedPositiveRationalLiteral,+  uncheckedLiteral,  ) import CheckedLiterals.Class.Rational.TypeNats (IsPowerOfTwo) import CheckedLiterals.Nums.Signed (Signed (..))@@ -24,6 +25,7 @@ import GHC.TypeError (Assert, ErrorMessage (ShowType, Text, (:$$:), (:<>:)), TypeError) import GHC.TypeLits (KnownNat, Nat, natVal, type Div, type (+), type (-), type (<=?), type (^)) import GHC.TypeLits.Extra (CLog)+import Prelude  {- | Fixed-point number @@ -132,9 +134,9 @@   abs (Fixed a) = Fixed (abs a)    signum (Fixed a)-    | a == 0 = 0-    | a < 0 = -1-    | otherwise = 1+    | a == uncheckedLiteral 0 = uncheckedLiteral 0+    | a < uncheckedLiteral 0 = uncheckedLiteral (-1)+    | otherwise = uncheckedLiteral 1    fromInteger i = Fixed (fromInteger sat)    where@@ -168,7 +170,7 @@    where     nF = fromInteger (natVal (Proxy @frac)) :: Int     -- 1.0 in fixed point is 1 << frac-    one = 1 `shiftL` nF :: Integer+    one = uncheckedLiteral 1 `shiftL` nF :: Integer     -- (1 << frac) / a in fixed point needs another shift     num = one `shiftL` nF     res = num `quot` toInteger a
src-nums/CheckedLiterals/Nums/Signed.hs view
@@ -15,6 +15,7 @@ import GHC.TypeError (Assert, ErrorMessage (ShowType, Text, (:$$:), (:<>:)), TypeError) import GHC.TypeLits (KnownNat, Nat, natVal, type (+), type (-), type (<=?), type (^)) import GHC.TypeLits.Extra (CLog)+import Prelude  -- | Signed integer with @n@ bits (including sign bit) newtype Signed (n :: Nat) = Signed Integer
src-nums/CheckedLiterals/Nums/Unsigned.hs view
@@ -8,6 +8,7 @@   CheckedNegativeIntegerLiteral,   CheckedPositiveIntegerLiteral,   NegativeUnsignedError,+  uncheckedLiteral,  ) import Data.Bits (Bits (..), FiniteBits (..)) import Data.Proxy (Proxy (..))@@ -15,6 +16,7 @@ import GHC.TypeError (Assert, ErrorMessage (ShowType, Text, (:$$:), (:<>:)), TypeError) import GHC.TypeLits (KnownNat, Nat, natVal, type (+), type (-), type (<=?), type (^)) import GHC.TypeLits.Extra (CLog)+import Prelude  -- | Unsigned integer with @n@ bits newtype Unsigned (n :: Nat) = Unsigned Integer@@ -35,8 +37,8 @@   Unsigned a - Unsigned b = fromInteger (a - b)   negate (Unsigned a) = fromInteger (negate a)   abs u = u-  signum (Unsigned 0) = 0-  signum _ = 1+  signum (Unsigned 0) = uncheckedLiteral 0+  signum _ = uncheckedLiteral 1   fromInteger i =     let u = Unsigned i'         Unsigned maxB = maxBound `asTypeOf` u
tests/Test/Tasty/AssertGhc.hs view
@@ -16,6 +16,8 @@ import Test.Tasty.Options import Text.Read (readMaybe) +import Paths_checked_literals (getDataFileName)+ data Expected = ExpectFailure [String] | ExpectSuccess  -- | Option to enable debug output of GHC error messages@@ -45,6 +47,7 @@   --      isn't set and the test suite is compiled with a GHC compiler other than the   --      system's default.   hc <- fromMaybe "ghc" <$> lookupEnv "HC"+  srcNums <- getDataFileName "src-nums"   withSystemTempFile "ShouldError.hs" $ \tempFile tempHandle -> do     -- Write source with proper Main module structure     hPutStr tempHandle "module Main where\n"@@ -64,6 +67,7 @@         , "-XViewPatterns"         , "-XNoImplicitPrelude"         , "-fno-code"+        , "-i" ++ srcNums         , "-fplugin=GHC.TypeLits.KnownNat.Solver"         , "-fplugin=GHC.TypeLits.Normalise"         , "-fplugin=GHC.TypeLits.Extra.Solver"