-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support GHC 9.4 #69
Closed
Closed
Support GHC 9.4 #69
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eb8fece
Support GHC 9.4
parsonsmatt 8d8447c
aw yeah
parsonsmatt 4d91acc
also support ghc 9.2.4 lol
parsonsmatt 4189a64
hmm
parsonsmatt bbb6511
Significantly less CPP
parsonsmatt 18912bd
works with ghc 9.2, 9.4
parsonsmatt f26f51d
isolate compat
parsonsmatt 83a5ac4
trash
parsonsmatt edddfab
Clean up other modules
parsonsmatt 319823a
works on 9.2 and 9.4
parsonsmatt cfc3904
izZeroWord intsead of comparison
parsonsmatt ee441fc
lmao
parsonsmatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE MagicHash #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE StrictData #-} | ||
{-# LANGUAGE UnboxedTuples #-} | ||
|
||
-- | This module exists to centralize compatibility shims for GHC 9.4. | ||
module Data.WideWord.Compat | ||
( plusWord2# | ||
, timesWord2# | ||
, int2Word# | ||
, minusWord# | ||
, subWordC# | ||
, not# | ||
, isZeroWord# | ||
, or# | ||
, and# | ||
, xor# | ||
, timesWord# | ||
, plusWord# | ||
, word2Int# | ||
, quotRemWord2# | ||
, compatWordLiteral# | ||
, compatIntLiteral# | ||
, compatCaseOnWordLiteral# | ||
, compatCaseOnIntLiteral# | ||
) where | ||
|
||
#if MIN_VERSION_base(4,17,0) | ||
import qualified GHC.Base | ||
import GHC.Prim (Word64#, wordToWord64#, word64ToWord#, Int64#) | ||
#else | ||
import qualified GHC.Base | ||
import GHC.Base (Int#(..), Word#, quotRemWord2#, int2Word#, subWordC#, plusWord2#, or#, minusWord#, timesWord2#, word2Int#, xor#, and#, not#, plusWord#, timesWord#) | ||
#endif | ||
|
||
#if MIN_VERSION_base(4,17,0) | ||
plusWord2# :: Word64# -> Word64# -> (# Word64#, Word64# #) | ||
plusWord2# a b = | ||
case GHC.Base.plusWord2# (word64ToWord# a) (word64ToWord# b) of | ||
(# a', b' #) -> | ||
(# wordToWord64# a', wordToWord64# b' #) | ||
|
||
timesWord2# :: Word64# -> Word64# -> (# Word64#, Word64# #) | ||
timesWord2# a b = | ||
case GHC.Base.timesWord2# (word64ToWord# a) (word64ToWord# b) of | ||
(# a', b' #) -> | ||
(# wordToWord64# a', wordToWord64# b' #) | ||
|
||
int2Word# :: Int64# -> Word64# | ||
int2Word# = GHC.Base.int64ToWord64# | ||
|
||
minusWord# :: Word64# -> Word64# -> Word64# | ||
minusWord# a b = | ||
wordToWord64# (GHC.Base.minusWord# (word64ToWord# a) (word64ToWord# b)) | ||
|
||
subWordC# :: Word64# -> Word64# -> (# Word64#, Int64# #) | ||
subWordC# a b = | ||
case GHC.Base.subWordC# (word64ToWord# a) (word64ToWord# b) of | ||
(# a', b' #) -> | ||
(# wordToWord64# a', GHC.Base.intToInt64# b' #) | ||
|
||
not# :: Word64# -> Word64# | ||
not# = GHC.Base.not64# | ||
|
||
or# :: Word64# -> Word64# -> Word64# | ||
or# = GHC.Base.or64# | ||
|
||
xor# :: Word64# -> Word64# -> Word64# | ||
xor# = GHC.Base.xor64# | ||
|
||
and# :: Word64# -> Word64# -> Word64# | ||
and# = GHC.Base.and64# | ||
|
||
timesWord# :: Word64# -> Word64# -> Word64# | ||
timesWord# = GHC.Base.timesWord64# | ||
|
||
plusWord# :: Word64# -> Word64# -> Word64# | ||
plusWord# = GHC.Base.plusWord64# | ||
|
||
word2Int# :: Word64# -> Int64# | ||
word2Int# = GHC.Base.word64ToInt64# | ||
|
||
quotRemWord2# :: Word64# -> Word64# -> Word64# -> (# Word64#, Word64# #) | ||
quotRemWord2# a b c = | ||
case GHC.Base.quotRemWord2# (word64ToWord# a) (word64ToWord# b) (word64ToWord# c) of | ||
(# x, y #) -> | ||
(# wordToWord64# x, wordToWord64# y #) | ||
#endif | ||
|
||
isZeroWord# | ||
#if MIN_VERSION_base(4,17,0) | ||
:: Word64# -> Bool | ||
isZeroWord# a = GHC.Base.isTrue# (GHC.Base.eqWord# (word64ToWord# a) 0##) | ||
#else | ||
:: Word# -> Bool | ||
isZeroWord# 0## = True | ||
isZeroWord# _ = False | ||
#endif | ||
|
||
compatWordLiteral# | ||
#if MIN_VERSION_base(4,17,0) | ||
:: GHC.Base.Word# -> Word64# | ||
compatWordLiteral# = wordToWord64# | ||
#else | ||
:: Word# -> Word# | ||
compatWordLiteral# a = a | ||
#endif | ||
|
||
compatIntLiteral# | ||
#if MIN_VERSION_base(4,17,0) | ||
:: GHC.Base.Int# -> Int64# | ||
compatIntLiteral# = GHC.Base.intToInt64# | ||
#else | ||
:: Int# -> Int# | ||
compatIntLiteral# a = a | ||
#endif | ||
|
||
compatCaseOnWordLiteral# | ||
#if MIN_VERSION_base(4,17,0) | ||
:: Word64# -> GHC.Base.Word# | ||
compatCaseOnWordLiteral# = word64ToWord# | ||
#else | ||
:: Word# -> Word# | ||
compatCaseOnWordLiteral# a = a | ||
#endif | ||
|
||
compatCaseOnIntLiteral# | ||
#if MIN_VERSION_base(4,17,0) | ||
:: Int64# -> GHC.Base.Int# | ||
compatCaseOnIntLiteral# = GHC.Base.int64ToInt# | ||
#else | ||
:: Int# -> Int# | ||
compatCaseOnIntLiteral# a = a | ||
#endif | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erikd I've consolidated the
compat
stuff to minimize noise here. Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. That is a significant improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I would still like to address is the
CPP
andViewPatterns
use in things like sayData.WideWord.Word256.signum256
. I am sure there is a neater way to do that (in say thatCompat
module).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like:
With the
isZeroWord64
being defined in theCompat
module.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also wondering if some of the other CPPisms like this:
could be lifted into the
Compat
module.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all made more difficult because
ghc-9.4
insists on being built with the Hadrian build system which complete breaks the way I used to manage installing multiple GHC versions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, totally - I only did the
Int128
to start since I didn't want to do a bunch of work if it wasn't to your tastes 😅 I'll port the rest over.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also tbh
ghcup
does work very well, you may consider adopting it? i was pretty skeptical but it is legitimately very goodThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
ghcup
produce a package I can install on several machines? Can I specify where it installs stuff like/usr/lib/ghc-X.Y
?