From patchwork Sat Feb 11 10:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Dominik Braun X-Patchwork-Id: 46815 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DF65A1661A; Sat, 11 Feb 2023 10:09:49 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3FE44165B0 for ; Sat, 11 Feb 2023 10:09:48 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQmop-0004tN-VT; Sat, 11 Feb 2023 05:09:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQmol-0004oy-23 for guix-patches@gnu.org; Sat, 11 Feb 2023 05:09:15 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQmof-0000AG-H9 for guix-patches@gnu.org; Sat, 11 Feb 2023 05:09:11 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQmof-0004E1-BH for guix-patches@gnu.org; Sat, 11 Feb 2023 05:09:09 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61420] [PATCH 18/31] gnu: elm: Support GHC 9.2. Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 11 Feb 2023 10:09:09 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61420 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61420@debbugs.gnu.org Cc: Lars-Dominik Braun Received: via spool by 61420-submit@debbugs.gnu.org id=B61420.167611014016072 (code B ref 61420); Sat, 11 Feb 2023 10:09:09 +0000 Received: (at 61420) by debbugs.gnu.org; 11 Feb 2023 10:09:00 +0000 Received: from localhost ([127.0.0.1]:38892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQmoV-0004B3-9k for submit@debbugs.gnu.org; Sat, 11 Feb 2023 05:08:59 -0500 Received: from mout-p-101.mailbox.org ([80.241.56.151]:59350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQmoJ-00046c-Ol for 61420@debbugs.gnu.org; Sat, 11 Feb 2023 05:08:50 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PDRBw2Sknz9sbx; Sat, 11 Feb 2023 11:08:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1676110120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ALKZUi48Ay9OJcrxa0OAkgN8e2dX5e+1SfKegOqSaj0=; b=p5iGyR3nmbbZrBvQa+In4+YlNDN0WnvSxPAL8x9npZ5Mh8D5CGG3pDG1BLMC0ppEXVAeQH EeBrvATwPSI/bM0DUJ3Yquug7hrYyH7EHtYO66OG816vbr+VBOWo05bMuwy4oScVLcvyus f0QKNYXdmHc4yYETbt4uDrcY9BKiYiC7emNNy4IzEOtEAh3Fb0hBtjFyA1bxw4rLJHM5qn 9+RFp5Bcx3gXR+/mYhttbIHBWfmISuxKTIUTwJnzSqpUoNp8bimTMttGSejLUyoV5GWK8y o8FAvVDI9Q3SYj7u0dhiRQdJDTeHtrIU525+n4ydU1P3W6W/tD7s+wwUpe82qw== From: Lars-Dominik Braun Date: Sat, 11 Feb 2023 11:08:12 +0100 Message-Id: <20230211100825.47971-15-lars@6xq.net> In-Reply-To: <20230211100825.47971-1-lars@6xq.net> References: <20230211100825.47971-1-lars@6xq.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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. --- gnu/local.mk | 1 + gnu/packages/elm.scm | 3 +- gnu/packages/patches/elm-ghc9.2.patch | 187 ++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/elm-ghc9.2.patch diff --git a/gnu/local.mk b/gnu/local.mk index 61e0598a5f..b6b44f7836 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1054,6 +1054,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 @@ (define-public elm-sans-reactor (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 +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#)