Skip to content

Commit

Permalink
update to build with GHC 9.4.*
Browse files Browse the repository at this point in the history
  • Loading branch information
evancz committed Sep 27, 2023
1 parent 047d502 commit 0421dfb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 41 deletions.
8 changes: 4 additions & 4 deletions compiler/src/Data/Name.hs
Expand Up @@ -241,7 +241,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
Expand Down Expand Up @@ -316,11 +316,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 ->
Expand Down
28 changes: 14 additions & 14 deletions compiler/src/Data/Utf8.hs
Expand Up @@ -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
Expand Down Expand Up @@ -145,7 +145,7 @@ startsWithChar isGood bytes@(Utf8 ba#) =
False
else
let
!w# = indexWord8Array# ba# 0#
!w# = word8ToWord# (indexWord8Array# ba# 0#)
!char
| isTrue# (ltWord# w# 0xC0##) = C# (chr# (word2Int# w#))
| isTrue# (ltWord# w# 0xE0##) = chr2 ba# 0# w#
Expand All @@ -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#)))



Expand All @@ -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
Expand Down Expand Up @@ -353,7 +353,7 @@ toCharsHelp ba# offset# len# =
[]
else
let
!w# = indexWord8Array# ba# offset#
!w# = word8ToWord# (indexWord8Array# ba# offset#)
!(# char, width# #)
| isTrue# (ltWord# w# 0xC0##) = (# C# (chr# (word2Int# w#)), 1# #)
| isTrue# (ltWord# w# 0xE0##) = (# chr2 ba# offset# w#, 2# #)
Expand All @@ -370,7 +370,7 @@ chr2 :: ByteArray# -> Int# -> Word# -> Char
chr2 ba# offset# firstWord# =
let
!i1# = word2Int# firstWord#
!i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#))
!i2# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 1#)))
!c1# = uncheckedIShiftL# (i1# -# 0xC0#) 6#
!c2# = i2# -# 0x80#
in
Expand All @@ -382,8 +382,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# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 1#)))
!i3# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 2#)))
!c1# = uncheckedIShiftL# (i1# -# 0xE0#) 12#
!c2# = uncheckedIShiftL# (i2# -# 0x80#) 6#
!c3# = i3# -# 0x80#
Expand All @@ -396,9 +396,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# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 1#)))
!i3# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 2#)))
!i4# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 3#)))
!c1# = uncheckedIShiftL# (i1# -# 0xF0#) 18#
!c2# = uncheckedIShiftL# (i2# -# 0x80#) 12#
!c3# = uncheckedIShiftL# (i3# -# 0x80#) 6#
Expand Down Expand Up @@ -473,7 +473,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)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/Parse/Variable.hs
Expand Up @@ -21,7 +21,7 @@ import qualified Data.Name as Name
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.Exts (Char(C#), Int#, (+#), (-#), chr#, uncheckedIShiftL#, word2Int#, word8ToWord#)
import GHC.Word (Word8(W8#))

import qualified AST.Source as Src
Expand Down Expand Up @@ -384,4 +384,4 @@ chr4 pos firstWord =

unpack :: Word8 -> Int#
unpack (W8# word#) =
word2Int# word#
word2Int# (word8ToWord# word#)
39 changes: 18 additions & 21 deletions elm.cabal
Expand Up @@ -35,9 +35,6 @@ Flag dev {


Executable elm
if flag(dev)
ghc-options: -O0 -Wall -Werror
else
ghc-options: -O2 -rtsopts -threaded "-with-rtsopts=-N -qg -A128m"
-- add -eventlog for (elm make src/Main.elm +RTS -l; threadscope elm.eventlog)
-- https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/
Expand Down Expand Up @@ -203,26 +200,26 @@ Executable elm
Paths_elm

Build-depends:
ansi-terminal >= 0.8 && < 0.9,
ansi-wl-pprint >= 0.6.8 && < 0.7,
base >=4.11 && <5,
binary >= 0.8 && < 0.9,
bytestring >= 0.9 && < 0.11,
containers >= 0.5.8.2 && < 0.6,
directory >= 1.2.3.0 && < 2.0,
edit-distance >= 0.2 && < 0.3,
ansi-terminal,
ansi-wl-pprint < 1,
base,
binary,
bytestring,
containers,
directory,
edit-distance,
file-embed,
filelock,
filepath >= 1 && < 2.0,
ghc-prim >= 0.5.2,
filepath,
ghc-prim,
haskeline,
HTTP >= 4000.2.5 && < 4000.4,
http-client >= 0.6 && < 0.7,
http-client-tls >= 0.3 && < 0.4,
http-types >= 0.12 && < 1.0,
language-glsl >= 0.3,
mtl >= 2.2.1 && < 3,
network >= 2.4 && < 2.7,
HTTP,
http-client,
http-client-tls,
http-types,
language-glsl,
mtl,
network,
parsec,
process,
raw-strings-qq,
Expand All @@ -231,7 +228,7 @@ Executable elm
snap-core,
snap-server,
template-haskell,
time >= 1.9.1,
time,
unordered-containers,
utf8-string,
vector,
Expand Down

0 comments on commit 0421dfb

Please sign in to comment.