From 079dfc9c1b2662df52992cd7fe25b4c6f5f445db Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Fri, 26 Dec 2025 22:44:06 +0100 Subject: [PATCH] refactor: migrate from GHC.Prim/GHC.Word to standard imports Modernize import structure by switching from GHC internal modules to their standard library equivalents. This change improves compatibility and reduces dependency on GHC internals. Changes made: - Replace GHC.Word with Data.Word in Pdep/Pext modules - Replace GHC.Prim with GHC.Exts for BMI2-enabled builds - Remove ghc-prim dependency from cabal file (library, tests, benchmarks) - Simplify conditional compilation flag check (remove GHC version constraint) The BMI2 conditional now applies to all GHC versions with the flag enabled, relying on the standard library's GHC.Exts module instead of the lower-level GHC.Prim for primitive operations. --- bits-extra.cabal | 6 +----- src/Data/Bits/Pdep/Prim.hs | 4 ++-- src/Data/Bits/Pext/Prim.hs | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/bits-extra.cabal b/bits-extra.cabal index fca597b..25b6454 100644 --- a/bits-extra.cabal +++ b/bits-extra.cabal @@ -31,7 +31,6 @@ common base { build-depends: base >= common criterion { build-depends: criterion >= 1.3 && < 1.7 } common doctest { build-depends: doctest >= 0.16.2 && < 0.25 } common doctest-discover { build-depends: doctest-discover >= 0.2 && < 0.3 } -common ghc-prim { build-depends: ghc-prim >= 0.5 && < 0.14 } common hedgehog { build-depends: hedgehog >= 0.5.3 && < 1.6 } common hspec { build-depends: hspec >= 2.4 && < 3 } common hw-hedgehog { build-depends: hw-hedgehog >= 0.1 && < 0.2 } @@ -41,7 +40,7 @@ common vector { build-depends: vector >= common config default-language: Haskell2010 ghc-options: -Wall - if (flag(bmi2)) && (impl(ghc >= 8.4.1)) + if flag(bmi2) ghc-options: -mbmi2 -msse4.2 cpp-options: -DBMI2_ENABLED @@ -50,7 +49,6 @@ common bits-extra library import: base, config - , ghc-prim , vector hs-source-dirs: src ghc-options: -O2 @@ -66,7 +64,6 @@ library test-suite bits-extra-test import: base, config - , ghc-prim , hedgehog , hspec , hw-hedgehog @@ -85,7 +82,6 @@ test-suite bits-extra-test benchmark bench import: base, config , criterion - , ghc-prim , vector type: exitcode-stdio-1.0 main-is: Main.hs diff --git a/src/Data/Bits/Pdep/Prim.hs b/src/Data/Bits/Pdep/Prim.hs index 9daab05..6c4ded6 100644 --- a/src/Data/Bits/Pdep/Prim.hs +++ b/src/Data/Bits/Pdep/Prim.hs @@ -19,10 +19,10 @@ module Data.Bits.Pdep.Prim , fastPdepEnabled ) where -import GHC.Prim -import GHC.Word +import Data.Word #if MIN_VERSION_base(4,11,0) && defined(BMI2_ENABLED) +import GHC.Exts #else import Data.Bits.Pdep.Slow #endif diff --git a/src/Data/Bits/Pext/Prim.hs b/src/Data/Bits/Pext/Prim.hs index 3d83f70..fd86ac4 100644 --- a/src/Data/Bits/Pext/Prim.hs +++ b/src/Data/Bits/Pext/Prim.hs @@ -19,10 +19,10 @@ module Data.Bits.Pext.Prim , fastPextEnabled ) where -import GHC.Word +import Data.Word #if MIN_VERSION_base(4,11,0) && defined(BMI2_ENABLED) -import GHC.Prim +import GHC.Exts #else import Data.Bits.Pext.Slow #endif