refactor: Migrate from GHC.Prim/GHC.Word to standard imports #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR modernizes the import structure by migrating from GHC internal modules (
GHC.Prim,GHC.Word) to their standard library equivalents (GHC.Exts,Data.Word). This change improves compatibility, reduces dependency on GHC internals, and removes the explicitghc-primpackage dependency while maintaining full functionality across all build configurations.Type of Change
Changes Made
Import Modernization
GHC.WordwithData.Wordin bothsrc/Data/Bits/Pdep/Prim.hsandsrc/Data/Bits/Pext/Prim.hsfor standard Word type importsGHC.PrimwithGHC.Extsin BMI2-enabled code paths (src/Data/Bits/Pext/Prim.hs)GHC.Extsre-exports the necessary primitives from bothGHC.PrimandGHC.Word, providing a cleaner unified interfaceDependency Cleanup
ghc-primdependency frombits-extra.cabal:ghc-primsection entirelyBuild Configuration Simplification
if (flag(bmi2)) && (impl(ghc >= 8.4.1))toif flag(bmi2)GHC.Extsmodule available in all supported GHC versionsTesting
Additional Notes
Motivation: This refactoring reduces the direct dependency on GHC's internal primitive modules, making the codebase more maintainable and less susceptible to changes in GHC's internal structure. The
GHC.Extsmodule provides a stable interface for accessing GHC extensions and primitives that's part of the base library.Compatibility: The changes maintain full backward compatibility as
GHC.Extsre-exports all necessary types and functions fromGHC.PrimandGHC.Word. The functionality remains identical while the import structure is cleaner and more idiomatic.Impact: This is a pure refactoring with no functional changes—all primitive operations and Word types remain available through the new import paths. The removal of
ghc-primas an explicit dependency simplifies the package's dependency tree.