aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/elm-ghc9.2.patch
blob: 7b1e653e805d9f5ed2152fde3995b29e7499a2a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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#)