Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Aug 18, 2024
1 parent de9bed5 commit 51d81a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/Data/Text/Builder/Linear/Array.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ module Data.Text.Builder.Linear.Array (
) where

import Data.Text.Array qualified as A
import GHC.Exts (Int (..), isByteArrayPinned#, isTrue#, setByteArray#, sizeofByteArray#)
import GHC.ST (ST (..))

#if __GLASGOW_HASKELL__ >= 909
import GHC.Exts (unsafeThawByteArray#)
#if MIN_VERSION_base(4,20,0)
import GHC.Exts (Int (..), isByteArrayPinned#, isTrue#, setByteArray#, sizeofByteArray#, unsafeThawByteArray#)
#else
import GHC.Exts (unsafeCoerce#)
import GHC.Exts (Int (..), isByteArrayPinned#, isTrue#, setByteArray#, sizeofByteArray#, unsafeCoerce#)
#endif

unsafeThaw A.Array ST s (A.MArray s)
#if __GLASGOW_HASKELL__ >= 909
#if MIN_VERSION_base(4,20,0)
unsafeThaw (A.ByteArray a) = ST $ \s# case unsafeThawByteArray# a s# of
(# s'#, ma #) -> (# s'#, A.MutableByteArray ma #)
#else
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Text/Builder/Linear/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ newEmptyBuffer (Buffer t@(Text arr _ _)) =
-- from [@linear-base@](https://hackage.haskell.org/package/linear-base).
--
-- It is a bit tricky to use because of
-- <https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/linear_types.html#limitations current limitations>
-- <https://downloads.haskell.org/ghc/9.8.1/docs/users_guide/exts/linear_types.html#limitations current limitations>
-- of linear types with regards to @let@ and @where@. E. g., one cannot write
--
-- > let (# b1, b2 #) = dupBuffer b in ("foo" <| b1) >< (b2 |> "bar")
Expand Down Expand Up @@ -296,7 +296,7 @@ appendBounded' maxSrcLen writer (Buffer (Text dst dstOff dstLen)) = Buffer $ run
-- Note: we rely on copyM allowing overlaps
A.copyM newM (dstOff + dstLen) newM (off' - count) count
pure (dstOff, count)
!(dstOff', srcLen) writer append prepend
(dstOff', srcLen) writer append prepend
new A.unsafeFreeze newM
pure $ Text new dstOff' (dstLen + srcLen)
{-# INLINE appendBounded' #-}
Expand Down

0 comments on commit 51d81a8

Please sign in to comment.