refactor: Migrate from GHC.Prim/GHC.Word to standard imports#69
Merged
refactor: Migrate from GHC.Prim/GHC.Word to standard imports#69
Conversation
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.
831a701 to
079dfc9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.