diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2023-01-25 13:03:43 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2023-02-26 10:26:15 +0100 |
commit | ebea18357b325dc96e68bfd7103497571b2cbd77 (patch) | |
tree | e64df968d7ce990737e1c5ad505ef84ad104af65 | |
parent | 92caedb60c8fb6961446d223b623c41bed808acd (diff) | |
download | guix-ebea18357b325dc96e68bfd7103497571b2cbd77.tar.gz |
gnu: elm: Support GHC 9.2.
* gnu/packages/elm.scm (elm-sans-reactor)[source]: Add patch to support GHC 9.2. * gnu/packages/patches/elm-ghc9.2.patch: This one. * gnu/local.mk: Add it.
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/elm.scm | 3 | ||||
-rw-r--r-- | gnu/packages/patches/elm-ghc9.2.patch | 187 |
3 files changed, 190 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 04a7320960..89dee3cf6a 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1055,6 +1055,7 @@ dist_patch_DATA = \ %D%/packages/patches/einstein-build.patch \ %D%/packages/patches/elfutils-tests-ptrace.patch \ %D%/packages/patches/elixir-path-length.patch \ + %D%/packages/patches/elm-ghc9.2.patch \ %D%/packages/patches/elm-offline-package-registry.patch \ %D%/packages/patches/elm-reactor-static-files.patch \ %D%/packages/patches/elogind-revert-polkit-detection.patch \ diff --git a/gnu/packages/elm.scm b/gnu/packages/elm.scm index 6d301cf51c..a74d294ae5 100644 --- a/gnu/packages/elm.scm +++ b/gnu/packages/elm.scm @@ -56,7 +56,8 @@ (base32 "1rdg3xp3js9xadclk3cdypkscm5wahgsfmm4ldcw3xswzhw6ri8w")) (patches (search-patches "elm-reactor-static-files.patch" - "elm-offline-package-registry.patch")))) + "elm-offline-package-registry.patch" + "elm-ghc9.2.patch")))) (build-system haskell-build-system) (arguments (list diff --git a/gnu/packages/patches/elm-ghc9.2.patch b/gnu/packages/patches/elm-ghc9.2.patch new file mode 100644 index 0000000000..7b1e653e80 --- /dev/null +++ b/gnu/packages/patches/elm-ghc9.2.patch @@ -0,0 +1,187 @@ +From f88043586337ba33cf3e852908003a71dfe493ec Mon Sep 17 00:00:00 2001 +From: vlkrs <codeberg@schlecht.dev> +Date: Sat, 7 May 2022 17:51:15 +0200 +Subject: [PATCH] Quick hack to build on ghc-9.2.2 + +Taken from +https://codeberg.org/vlkrs/elm-compiler/commit/f88043586337ba33cf3e852908003a71dfe493ec.patch + +diff --git a/compiler/src/Data/Name.hs b/compiler/src/Data/Name.hs +index beecf114..39b64029 100644 +--- a/compiler/src/Data/Name.hs ++++ b/compiler/src/Data/Name.hs +@@ -47,6 +47,7 @@ import qualified Data.Utf8 as Utf8 + import GHC.Exts + ( Int(I#), Ptr + , MutableByteArray# ++ , int8ToInt# + , isTrue# + , newByteArray# + , sizeofByteArray# +@@ -241,7 +242,7 @@ fromTypeVariable name@(Utf8.Utf8 ba#) index = + else + let + len# = sizeofByteArray# ba# +- end# = indexWord8Array# ba# (len# -# 1#) ++ end# = word8ToWord# (indexWord8Array# ba# (len# -# 1#)) + in + if isTrue# (leWord# 0x30## end#) && isTrue# (leWord# end# 0x39##) then + runST +@@ -316,11 +317,11 @@ fromManyNames names = + ST $ \s -> + case newByteArray# (len# +# 3#) s of + (# s, mba# #) -> +- case writeWord8Array# mba# 0# 0x5F## {-_-} s of ++ case writeWord8Array# mba# 0# (wordToWord8# 0x5F##) {-_-} s of + s -> +- case writeWord8Array# mba# 1# 0x4D## {-M-} s of ++ case writeWord8Array# mba# 1# (wordToWord8# 0x4D##) {-M-} s of + s -> +- case writeWord8Array# mba# 2# 0x24## {-$-} s of ++ case writeWord8Array# mba# 2# (wordToWord8# 0x24##) {-$-} s of + s -> + case copyByteArray# ba# 0# mba# 3# len# s of + s -> +diff --git a/compiler/src/Data/Utf8.hs b/compiler/src/Data/Utf8.hs +index e985aa64..472777df 100644 +--- a/compiler/src/Data/Utf8.hs ++++ b/compiler/src/Data/Utf8.hs +@@ -109,10 +109,10 @@ contains (W8# word#) (Utf8 ba#) = + containsHelp word# ba# 0# (sizeofByteArray# ba#) + + +-containsHelp :: Word# -> ByteArray# -> Int# -> Int# -> Bool ++containsHelp :: Word8# -> ByteArray# -> Int# -> Int# -> Bool + containsHelp word# ba# !offset# len# = + if isTrue# (offset# <# len#) then +- if isTrue# (eqWord# word# (indexWord8Array# ba# offset#)) ++ if isTrue# (eqWord8# word# (indexWord8Array# ba# offset#)) + then True + else containsHelp word# ba# (offset# +# 1#) len# + else +@@ -147,10 +147,10 @@ startsWithChar isGood bytes@(Utf8 ba#) = + let + !w# = indexWord8Array# ba# 0# + !char +- | isTrue# (ltWord# w# 0xC0##) = C# (chr# (word2Int# w#)) +- | isTrue# (ltWord# w# 0xE0##) = chr2 ba# 0# w# +- | isTrue# (ltWord# w# 0xF0##) = chr3 ba# 0# w# +- | True = chr4 ba# 0# w# ++ | isTrue# (ltWord8# w# (wordToWord8# 0xC0##)) = C# (chr# (int8ToInt# (word8ToInt8# w#))) ++ | isTrue# (ltWord8# w# (wordToWord8# 0xE0##)) = chr2 ba# 0# (word8ToWord# w#) ++ | isTrue# (ltWord8# w# (wordToWord8# 0xF0##)) = chr3 ba# 0# (word8ToWord# w#) ++ | True = chr4 ba# 0# (word8ToWord# w#) + in + isGood char + +@@ -164,7 +164,7 @@ endsWithWord8 (W8# w#) (Utf8 ba#) = + let len# = sizeofByteArray# ba# in + isTrue# (len# ># 0#) + && +- isTrue# (eqWord# w# (indexWord8Array# ba# (len# -# 1#))) ++ isTrue# (eqWord8# w# (indexWord8Array# ba# (len# -# 1#))) + + + +@@ -186,11 +186,11 @@ splitHelp str start offsets = + unsafeSlice str start offset : splitHelp str (offset + 1) offsets + + +-findDividers :: Word# -> ByteArray# -> Int# -> Int# -> [Int] -> [Int] ++findDividers :: Word8# -> ByteArray# -> Int# -> Int# -> [Int] -> [Int] + findDividers divider# ba# !offset# len# revOffsets = + if isTrue# (offset# <# len#) then + findDividers divider# ba# (offset# +# 1#) len# $ +- if isTrue# (eqWord# divider# (indexWord8Array# ba# offset#)) ++ if isTrue# (eqWord8# divider# (indexWord8Array# ba# offset#)) + then I# offset# : revOffsets + else revOffsets + else +@@ -353,10 +353,10 @@ toCharsHelp ba# offset# len# = + let + !w# = indexWord8Array# ba# offset# + !(# char, width# #) +- | isTrue# (ltWord# w# 0xC0##) = (# C# (chr# (word2Int# w#)), 1# #) +- | isTrue# (ltWord# w# 0xE0##) = (# chr2 ba# offset# w#, 2# #) +- | isTrue# (ltWord# w# 0xF0##) = (# chr3 ba# offset# w#, 3# #) +- | True = (# chr4 ba# offset# w#, 4# #) ++ | isTrue# (ltWord8# w# (wordToWord8# 0xC0##)) = (# C# (chr# (int8ToInt# (word8ToInt8# w#))), 1# #) ++ | isTrue# (ltWord8# w# (wordToWord8# 0xE0##)) = (# chr2 ba# offset# (word8ToWord# w#), 2# #) ++ | isTrue# (ltWord8# w# (wordToWord8# 0xF0##)) = (# chr3 ba# offset# (word8ToWord# w#), 3# #) ++ | True = (# chr4 ba# offset# (word8ToWord# w#), 4# #) + + !newOffset# = offset# +# width# + in +@@ -368,7 +368,7 @@ chr2 :: ByteArray# -> Int# -> Word# -> Char + chr2 ba# offset# firstWord# = + let + !i1# = word2Int# firstWord# +- !i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#)) ++ !i2# = int8ToInt# (word8ToInt8# (indexWord8Array# ba# (offset# +# 1#))) + !c1# = uncheckedIShiftL# (i1# -# 0xC0#) 6# + !c2# = i2# -# 0x80# + in +@@ -380,8 +380,8 @@ chr3 :: ByteArray# -> Int# -> Word# -> Char + chr3 ba# offset# firstWord# = + let + !i1# = word2Int# firstWord# +- !i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#)) +- !i3# = word2Int# (indexWord8Array# ba# (offset# +# 2#)) ++ !i2# = int8ToInt# (word8ToInt8# (indexWord8Array# ba# (offset# +# 1#))) ++ !i3# = int8ToInt# (word8ToInt8# (indexWord8Array# ba# (offset# +# 2#))) + !c1# = uncheckedIShiftL# (i1# -# 0xE0#) 12# + !c2# = uncheckedIShiftL# (i2# -# 0x80#) 6# + !c3# = i3# -# 0x80# +@@ -394,9 +394,9 @@ chr4 :: ByteArray# -> Int# -> Word# -> Char + chr4 ba# offset# firstWord# = + let + !i1# = word2Int# firstWord# +- !i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#)) +- !i3# = word2Int# (indexWord8Array# ba# (offset# +# 2#)) +- !i4# = word2Int# (indexWord8Array# ba# (offset# +# 3#)) ++ !i2# = int8ToInt# (word8ToInt8# (indexWord8Array# ba# (offset# +# 1#))) ++ !i3# = int8ToInt# (word8ToInt8# (indexWord8Array# ba# (offset# +# 2#))) ++ !i4# = int8ToInt# (word8ToInt8# (indexWord8Array# ba# (offset# +# 3#))) + !c1# = uncheckedIShiftL# (i1# -# 0xF0#) 18# + !c2# = uncheckedIShiftL# (i2# -# 0x80#) 12# + !c3# = uncheckedIShiftL# (i3# -# 0x80#) 6# +@@ -471,7 +471,7 @@ toEscapedBuilderHelp before after !name@(Utf8 ba#) k = + escape :: Word8 -> Word8 -> Ptr a -> Utf8 t -> Int -> Int -> Int -> IO () + escape before@(W8# before#) after ptr name@(Utf8 ba#) offset@(I# offset#) len@(I# len#) i@(I# i#) = + if isTrue# (i# <# len#) then +- if isTrue# (eqWord# before# (indexWord8Array# ba# (offset# +# i#))) ++ if isTrue# (eqWord8# before# (indexWord8Array# ba# (offset# +# i#))) + then + do writeWordToPtr ptr i after + escape before after ptr name offset len (i + 1) +diff --git a/compiler/src/Parse/Primitives.hs b/compiler/src/Parse/Primitives.hs +index bb973193..3747cfac 100644 +--- a/compiler/src/Parse/Primitives.hs ++++ b/compiler/src/Parse/Primitives.hs +@@ -82,7 +82,7 @@ instance Functor (Parser x) where + + instance Applicative.Applicative (Parser x) where + {-# INLINE pure #-} +- pure = return ++ pure = pure + + {-# INLINE (<*>) #-} + (<*>) (Parser parserFunc) (Parser parserArg) = +diff --git a/compiler/src/Parse/Variable.hs b/compiler/src/Parse/Variable.hs +index f3d86145..5e0ea802 100644 +--- a/compiler/src/Parse/Variable.hs ++++ b/compiler/src/Parse/Variable.hs +@@ -22,6 +22,7 @@ import qualified Data.Set as Set + import Data.Word (Word8) + import Foreign.Ptr (Ptr, plusPtr) + import GHC.Exts (Char(C#), Int#, (+#), (-#), chr#, uncheckedIShiftL#, word2Int#) ++import GHC.Prim + import GHC.Word (Word8(W8#)) + + import qualified AST.Source as Src +@@ -384,4 +385,4 @@ chr4 pos firstWord = + + unpack :: Word8 -> Int# + unpack (W8# word#) = +- word2Int# word# ++ int8ToInt# (word8ToInt8# word#) |