Skip to content

Commit

Permalink
Implement pure isAscii
Browse files Browse the repository at this point in the history
  • Loading branch information
chreekat committed Jan 27, 2024
1 parent 65c7472 commit a897be5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Data/Text.hs-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Data.Text where

import Data.Text.Internal (Text(..))

-- Used by Data.Text.Internal.IsAscii
all :: (Char -> Bool) -> Text -> Bool
4 changes: 3 additions & 1 deletion src/Data/Text/Internal/IsAscii.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module Data.Text.Internal.IsAscii where

#if defined(PURE_HASKELL)
import Prelude (Bool(..), Int)
import qualified Data.Char as Char
import {-# SOURCE #-} Data.Text (all)
#else
import Data.Text.Internal.ByteStringCompat (withBS)
import Data.Text.Internal.Unsafe (unsafeWithForeignPtr)
Expand Down Expand Up @@ -45,7 +47,7 @@ import qualified Prelude as P
-- @since 2.0.2
isAscii :: Text -> Bool
#if defined(PURE_HASKELL)
isAscii = P.const False
isAscii = all Char.isAscii
#else
cSizeToInt :: CSize -> Int
cSizeToInt = P.fromIntegral
Expand Down

0 comments on commit a897be5

Please sign in to comment.