{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE ViewPatterns #-}
module System.OsString.Internal where
import System.OsString.Internal.Types
import Control.Monad.Catch
( MonadThrow )
import Data.ByteString
( ByteString )
import Data.Char
import Language.Haskell.TH.Quote
( QuasiQuoter (..) )
import Language.Haskell.TH.Syntax
( Lift (..), lift )
import System.IO
( TextEncoding )
import System.OsString.Encoding ( EncodingException(..) )
import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
import GHC.IO.Encoding.UTF16 ( mkUTF16le )
import System.OsString.Encoding ( encodeWithBaseWindows, decodeWithBaseWindows )
import qualified System.OsString.Windows as PF
#else
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
import System.OsString.Encoding ( encodeWithBasePosix, decodeWithBasePosix )
import qualified System.OsString.Posix as PF
#endif
import GHC.Stack (HasCallStack)
import Data.Coerce (coerce)
import Data.Type.Coercion (coerceWith)
encodeUtf :: MonadThrow m => String -> m OsString
encodeUtf :: forall (m :: * -> *). MonadThrow m => String -> m OsString
encodeUtf = (WindowsString -> OsString) -> m WindowsString -> m OsString
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap WindowsString -> OsString
OsString (m WindowsString -> m OsString)
-> (String -> m WindowsString) -> String -> m OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m WindowsString
forall (m :: * -> *). MonadThrow m => String -> m WindowsString
PF.encodeUtf
unsafeEncodeUtf :: HasCallStack => String -> OsString
unsafeEncodeUtf :: HasCallStack => String -> OsString
unsafeEncodeUtf = WindowsString -> OsString
OsString (WindowsString -> OsString)
-> (String -> WindowsString) -> String -> OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => String -> WindowsString
String -> WindowsString
PF.unsafeEncodeUtf
encodeWith :: TextEncoding
-> TextEncoding
-> String
-> Either EncodingException OsString
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
encodeWith :: TextEncoding
-> TextEncoding -> String -> Either EncodingException OsString
encodeWith TextEncoding
_ TextEncoding
winEnc String
str = WindowsString -> OsString
OsString (WindowsString -> OsString)
-> Either EncodingException WindowsString
-> Either EncodingException OsString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TextEncoding -> String -> Either EncodingException WindowsString
PF.encodeWith TextEncoding
winEnc String
str
#else
encodeWith unixEnc _ str = OsString <$> PF.encodeWith unixEnc str
#endif
encodeFS :: String -> IO OsString
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
encodeFS :: String -> IO OsString
encodeFS = (ShortByteString -> OsString) -> IO ShortByteString -> IO OsString
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (WindowsString -> OsString
OsString (WindowsString -> OsString)
-> (ShortByteString -> WindowsString)
-> ShortByteString
-> OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShortByteString -> WindowsString
WindowsString) (IO ShortByteString -> IO OsString)
-> (String -> IO ShortByteString) -> String -> IO OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO ShortByteString
encodeWithBaseWindows
#else
encodeFS = fmap (OsString . PosixString) . encodeWithBasePosix
#endif
encodeLE :: String -> IO OsString
encodeLE :: String -> IO OsString
encodeLE = (WindowsString -> OsString) -> IO WindowsString -> IO OsString
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap WindowsString -> OsString
OsString (IO WindowsString -> IO OsString)
-> (String -> IO WindowsString) -> String -> IO OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO WindowsString
PF.encodeLE
decodeUtf :: MonadThrow m => OsString -> m String
decodeUtf :: forall (m :: * -> *). MonadThrow m => OsString -> m String
decodeUtf (OsString WindowsString
x) = WindowsString -> m String
forall (m :: * -> *). MonadThrow m => WindowsString -> m String
PF.decodeUtf WindowsString
x
decodeWith :: TextEncoding
-> TextEncoding
-> OsString
-> Either EncodingException String
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
decodeWith :: TextEncoding
-> TextEncoding -> OsString -> Either EncodingException String
decodeWith TextEncoding
_ TextEncoding
winEnc (OsString WindowsString
x) = TextEncoding -> WindowsString -> Either EncodingException String
PF.decodeWith TextEncoding
winEnc WindowsString
x
#else
decodeWith unixEnc _ (OsString x) = PF.decodeWith unixEnc x
#endif
decodeFS :: OsString -> IO String
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
decodeFS :: OsString -> IO String
decodeFS (OsString (WindowsString ShortByteString
x)) = ShortByteString -> IO String
decodeWithBaseWindows ShortByteString
x
#else
decodeFS (OsString (PosixString x)) = decodeWithBasePosix x
#endif
decodeLE :: OsString -> IO String
decodeLE :: OsString -> IO String
decodeLE (OsString WindowsString
x) = WindowsString -> IO String
PF.decodeLE WindowsString
x
fromBytes :: MonadThrow m
=> ByteString
-> m OsString
fromBytes :: forall (m :: * -> *). MonadThrow m => ByteString -> m OsString
fromBytes = (WindowsString -> OsString) -> m WindowsString -> m OsString
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap WindowsString -> OsString
OsString (m WindowsString -> m OsString)
-> (ByteString -> m WindowsString) -> ByteString -> m OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> m WindowsString
forall (m :: * -> *). MonadThrow m => ByteString -> m WindowsString
PF.fromBytes
osstr :: QuasiQuoter
osstr :: QuasiQuoter
osstr =
QuasiQuoter
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
{ quoteExp :: String -> Q Exp
quoteExp = \String
s -> do
osp <- (EncodingException -> Q OsString)
-> (WindowsString -> Q OsString)
-> Either EncodingException WindowsString
-> Q OsString
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> Q OsString
forall a. String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q OsString)
-> (EncodingException -> String) -> EncodingException -> Q OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EncodingException -> String
forall a. Show a => a -> String
show) (OsString -> Q OsString
forall a. a -> Q a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OsString -> Q OsString)
-> (WindowsString -> OsString) -> WindowsString -> Q OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowsString -> OsString
OsString) (Either EncodingException WindowsString -> Q OsString)
-> (String -> Either EncodingException WindowsString)
-> String
-> Q OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> String -> Either EncodingException WindowsString
PF.encodeWith (CodingFailureMode -> TextEncoding
mkUTF16le CodingFailureMode
ErrorOnCodingFailure) (String -> Q OsString) -> String -> Q OsString
forall a b. (a -> b) -> a -> b
$ String
s
lift osp
, quotePat :: String -> Q Pat
quotePat = \String
s -> do
osp' <- (EncodingException -> Q OsString)
-> (WindowsString -> Q OsString)
-> Either EncodingException WindowsString
-> Q OsString
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> Q OsString
forall a. String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q OsString)
-> (EncodingException -> String) -> EncodingException -> Q OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EncodingException -> String
forall a. Show a => a -> String
show) (OsString -> Q OsString
forall a. a -> Q a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OsString -> Q OsString)
-> (WindowsString -> OsString) -> WindowsString -> Q OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowsString -> OsString
OsString) (Either EncodingException WindowsString -> Q OsString)
-> (String -> Either EncodingException WindowsString)
-> String
-> Q OsString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> String -> Either EncodingException WindowsString
PF.encodeWith (CodingFailureMode -> TextEncoding
mkUTF16le CodingFailureMode
ErrorOnCodingFailure) (String -> Q OsString) -> String -> Q OsString
forall a b. (a -> b) -> a -> b
$ String
s
[p|((==) osp' -> True)|]
, quoteType :: String -> Q Type
quoteType = \String
_ ->
String -> Q Type
forall a. String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"illegal QuasiQuote (allowed as expression or pattern only, used as a type)"
, quoteDec :: String -> Q [Dec]
quoteDec = \String
_ ->
String -> Q [Dec]
forall a. String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"illegal QuasiQuote (allowed as expression or pattern only, used as a declaration)"
}
#else
{ quoteExp = \s -> do
osp <- either (fail . show) (pure . OsString) . PF.encodeWith (mkUTF8 ErrorOnCodingFailure) $ s
lift osp
, quotePat = \s -> do
osp' <- either (fail . show) (pure . OsString) . PF.encodeWith (mkUTF8 ErrorOnCodingFailure) $ s
[p|((==) osp' -> True)|]
, quoteType = \_ ->
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a type)"
, quoteDec = \_ ->
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a declaration)"
}
#endif
unpack :: OsString -> [OsChar]
unpack :: OsString -> [OsChar]
unpack = (WindowsString -> [WindowsChar]) -> OsString -> [OsChar]
forall a b. Coercible a b => a -> b
coerce WindowsString -> [WindowsChar]
PF.unpack
pack :: [OsChar] -> OsString
pack :: [OsChar] -> OsString
pack = ([WindowsChar] -> WindowsString) -> [OsChar] -> OsString
forall a b. Coercible a b => a -> b
coerce [WindowsChar] -> WindowsString
PF.pack
empty :: OsString
empty :: OsString
empty = OsString
forall a. Monoid a => a
mempty
singleton :: OsChar -> OsString
singleton :: OsChar -> OsString
singleton = (WindowsChar -> WindowsString) -> OsChar -> OsString
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString
PF.singleton
unsafeFromChar :: Char -> OsChar
unsafeFromChar :: Char -> OsChar
unsafeFromChar = (Char -> WindowsChar) -> Char -> OsChar
forall a b. Coercible a b => a -> b
coerce Char -> WindowsChar
PF.unsafeFromChar
toChar :: OsChar -> Char
toChar :: OsChar -> Char
toChar = case Either
(Coercion OsChar WindowsChar, Coercion OsString WindowsString)
(Coercion OsChar PosixChar, Coercion OsString PosixString)
coercionToPlatformTypes of
Left (Coercion OsChar WindowsChar
co, Coercion OsString WindowsString
_) -> Int -> Char
chr (Int -> Char) -> (OsChar -> Int) -> OsChar -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word16 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Int) -> (OsChar -> Word16) -> OsChar -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowsChar -> Word16
getWindowsChar (WindowsChar -> Word16)
-> (OsChar -> WindowsChar) -> OsChar -> Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Coercion OsChar WindowsChar -> OsChar -> WindowsChar
forall a b. Coercion a b -> a -> b
coerceWith Coercion OsChar WindowsChar
co
Right (Coercion OsChar PosixChar
co, Coercion OsString PosixString
_) -> Int -> Char
chr (Int -> Char) -> (OsChar -> Int) -> OsChar -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word8 -> Int) -> (OsChar -> Word8) -> OsChar -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PosixChar -> Word8
getPosixChar (PosixChar -> Word8) -> (OsChar -> PosixChar) -> OsChar -> Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Coercion OsChar PosixChar -> OsChar -> PosixChar
forall a b. Coercion a b -> a -> b
coerceWith Coercion OsChar PosixChar
co
snoc :: OsString -> OsChar -> OsString
snoc :: OsString -> OsChar -> OsString
snoc = (WindowsString -> WindowsChar -> WindowsString)
-> OsString -> OsChar -> OsString
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsChar -> WindowsString
PF.snoc
cons :: OsChar -> OsString -> OsString
cons :: OsChar -> OsString -> OsString
cons = (WindowsChar -> WindowsString -> WindowsString)
-> OsChar -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString -> WindowsString
PF.cons
last :: HasCallStack => OsString -> OsChar
last :: HasCallStack => OsString -> OsChar
last = (WindowsString -> WindowsChar) -> OsString -> OsChar
forall a b. Coercible a b => a -> b
coerce HasCallStack => WindowsString -> WindowsChar
WindowsString -> WindowsChar
PF.last
tail :: HasCallStack => OsString -> OsString
tail :: HasCallStack => OsString -> OsString
tail = (WindowsString -> WindowsString) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce HasCallStack => WindowsString -> WindowsString
WindowsString -> WindowsString
PF.tail
uncons :: OsString -> Maybe (OsChar, OsString)
uncons :: OsString -> Maybe (OsChar, OsString)
uncons = (WindowsString -> Maybe (WindowsChar, WindowsString))
-> OsString -> Maybe (OsChar, OsString)
forall a b. Coercible a b => a -> b
coerce WindowsString -> Maybe (WindowsChar, WindowsString)
PF.uncons
head :: HasCallStack => OsString -> OsChar
head :: HasCallStack => OsString -> OsChar
head = (WindowsString -> WindowsChar) -> OsString -> OsChar
forall a b. Coercible a b => a -> b
coerce HasCallStack => WindowsString -> WindowsChar
WindowsString -> WindowsChar
PF.head
init :: HasCallStack => OsString -> OsString
init :: HasCallStack => OsString -> OsString
init = (WindowsString -> WindowsString) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce HasCallStack => WindowsString -> WindowsString
WindowsString -> WindowsString
PF.init
unsnoc :: OsString -> Maybe (OsString, OsChar)
unsnoc :: OsString -> Maybe (OsString, OsChar)
unsnoc = (WindowsString -> Maybe (WindowsString, WindowsChar))
-> OsString -> Maybe (OsString, OsChar)
forall a b. Coercible a b => a -> b
coerce WindowsString -> Maybe (WindowsString, WindowsChar)
PF.unsnoc
null :: OsString -> Bool
null :: OsString -> Bool
null = (WindowsString -> Bool) -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce WindowsString -> Bool
PF.null
length :: OsString -> Int
length :: OsString -> Int
length = (WindowsString -> Int) -> OsString -> Int
forall a b. Coercible a b => a -> b
coerce WindowsString -> Int
PF.length
map :: (OsChar -> OsChar) -> OsString -> OsString
map :: (OsChar -> OsChar) -> OsString -> OsString
map = ((WindowsChar -> WindowsChar) -> WindowsString -> WindowsString)
-> (OsChar -> OsChar) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> WindowsChar) -> WindowsString -> WindowsString
PF.map
reverse :: OsString -> OsString
reverse :: OsString -> OsString
reverse = (WindowsString -> WindowsString) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString
PF.reverse
intercalate :: OsString -> [OsString] -> OsString
intercalate :: OsString -> [OsString] -> OsString
intercalate = (WindowsString -> [WindowsString] -> WindowsString)
-> OsString -> [OsString] -> OsString
forall a b. Coercible a b => a -> b
coerce WindowsString -> [WindowsString] -> WindowsString
PF.intercalate
foldl :: forall a. (a -> OsChar -> a) -> a -> OsString -> a
foldl :: forall a. (a -> OsChar -> a) -> a -> OsString -> a
foldl = ((a -> WindowsChar -> a) -> a -> WindowsString -> a)
-> (a -> OsChar -> a) -> a -> OsString -> a
forall a b. Coercible a b => a -> b
coerce (forall a. (a -> WindowsChar -> a) -> a -> WindowsString -> a
PF.foldl @a)
foldl' :: forall a. (a -> OsChar -> a) -> a -> OsString -> a
foldl' :: forall a. (a -> OsChar -> a) -> a -> OsString -> a
foldl' = ((a -> WindowsChar -> a) -> a -> WindowsString -> a)
-> (a -> OsChar -> a) -> a -> OsString -> a
forall a b. Coercible a b => a -> b
coerce (forall a. (a -> WindowsChar -> a) -> a -> WindowsString -> a
PF.foldl' @a)
foldl1 :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldl1 :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldl1 = ((WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar)
-> (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar
PF.foldl1
foldl1' :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldl1' :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldl1' = ((WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar)
-> (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar
PF.foldl1'
foldr :: forall a. (OsChar -> a -> a) -> a -> OsString -> a
foldr :: forall a. (OsChar -> a -> a) -> a -> OsString -> a
foldr = ((WindowsChar -> a -> a) -> a -> WindowsString -> a)
-> (OsChar -> a -> a) -> a -> OsString -> a
forall a b. Coercible a b => a -> b
coerce (forall a. (WindowsChar -> a -> a) -> a -> WindowsString -> a
PF.foldr @a)
foldr' :: forall a. (OsChar -> a -> a) -> a -> OsString -> a
foldr' :: forall a. (OsChar -> a -> a) -> a -> OsString -> a
foldr' = ((WindowsChar -> a -> a) -> a -> WindowsString -> a)
-> (OsChar -> a -> a) -> a -> OsString -> a
forall a b. Coercible a b => a -> b
coerce (forall a. (WindowsChar -> a -> a) -> a -> WindowsString -> a
PF.foldr' @a)
foldr1 :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldr1 :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldr1 = ((WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar)
-> (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar
PF.foldr1
foldr1' :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldr1' :: (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
foldr1' = ((WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar)
-> (OsChar -> OsChar -> OsChar) -> OsString -> OsChar
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> WindowsChar -> WindowsChar)
-> WindowsString -> WindowsChar
PF.foldr1'
all :: (OsChar -> Bool) -> OsString -> Bool
all :: (OsChar -> Bool) -> OsString -> Bool
all = ((WindowsChar -> Bool) -> WindowsString -> Bool)
-> (OsChar -> Bool) -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> Bool
PF.all
any :: (OsChar -> Bool) -> OsString -> Bool
any :: (OsChar -> Bool) -> OsString -> Bool
any = ((WindowsChar -> Bool) -> WindowsString -> Bool)
-> (OsChar -> Bool) -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> Bool
PF.any
concat :: [OsString] -> OsString
concat :: [OsString] -> OsString
concat = [OsString] -> OsString
forall a. Monoid a => [a] -> a
mconcat
replicate :: Int -> OsChar -> OsString
replicate :: Int -> OsChar -> OsString
replicate = (Int -> WindowsChar -> WindowsString) -> Int -> OsChar -> OsString
forall a b. Coercible a b => a -> b
coerce Int -> WindowsChar -> WindowsString
PF.replicate
unfoldr :: forall a. (a -> Maybe (OsChar, a)) -> a -> OsString
unfoldr :: forall a. (a -> Maybe (OsChar, a)) -> a -> OsString
unfoldr = ((a -> Maybe (WindowsChar, a)) -> a -> WindowsString)
-> (a -> Maybe (OsChar, a)) -> a -> OsString
forall a b. Coercible a b => a -> b
coerce (forall a. (a -> Maybe (WindowsChar, a)) -> a -> WindowsString
PF.unfoldr @a)
unfoldrN :: forall a. Int -> (a -> Maybe (OsChar, a)) -> a -> (OsString, Maybe a)
unfoldrN :: forall a.
Int -> (a -> Maybe (OsChar, a)) -> a -> (OsString, Maybe a)
unfoldrN = (Int
-> (a -> Maybe (WindowsChar, a)) -> a -> (WindowsString, Maybe a))
-> Int -> (a -> Maybe (OsChar, a)) -> a -> (OsString, Maybe a)
forall a b. Coercible a b => a -> b
coerce (forall a.
Int
-> (a -> Maybe (WindowsChar, a)) -> a -> (WindowsString, Maybe a)
PF.unfoldrN @a)
take :: Int -> OsString -> OsString
take :: Int -> OsString -> OsString
take = (Int -> WindowsString -> WindowsString)
-> Int -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce Int -> WindowsString -> WindowsString
PF.take
takeEnd :: Int -> OsString -> OsString
takeEnd :: Int -> OsString -> OsString
takeEnd = (Int -> WindowsString -> WindowsString)
-> Int -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce Int -> WindowsString -> WindowsString
PF.takeEnd
takeWhileEnd :: (OsChar -> Bool) -> OsString -> OsString
takeWhileEnd :: (OsChar -> Bool) -> OsString -> OsString
takeWhileEnd = ((WindowsChar -> Bool) -> WindowsString -> WindowsString)
-> (OsChar -> Bool) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> WindowsString
PF.takeWhileEnd
takeWhile :: (OsChar -> Bool) -> OsString -> OsString
takeWhile :: (OsChar -> Bool) -> OsString -> OsString
takeWhile = ((WindowsChar -> Bool) -> WindowsString -> WindowsString)
-> (OsChar -> Bool) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> WindowsString
PF.takeWhile
drop :: Int -> OsString -> OsString
drop :: Int -> OsString -> OsString
drop = (Int -> WindowsString -> WindowsString)
-> Int -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce Int -> WindowsString -> WindowsString
PF.drop
dropEnd :: Int -> OsString -> OsString
dropEnd :: Int -> OsString -> OsString
dropEnd = (Int -> WindowsString -> WindowsString)
-> Int -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce Int -> WindowsString -> WindowsString
PF.dropEnd
dropWhile :: (OsChar -> Bool) -> OsString -> OsString
dropWhile :: (OsChar -> Bool) -> OsString -> OsString
dropWhile = ((WindowsChar -> Bool) -> WindowsString -> WindowsString)
-> (OsChar -> Bool) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> WindowsString
PF.dropWhile
dropWhileEnd :: (OsChar -> Bool) -> OsString -> OsString
dropWhileEnd :: (OsChar -> Bool) -> OsString -> OsString
dropWhileEnd = ((WindowsChar -> Bool) -> WindowsString -> WindowsString)
-> (OsChar -> Bool) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> WindowsString
PF.dropWhileEnd
breakEnd :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
breakEnd :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
breakEnd = ((WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString))
-> (OsChar -> Bool) -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString)
PF.breakEnd
break :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
break :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
break = ((WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString))
-> (OsChar -> Bool) -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString)
PF.break
span :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
span :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
span = ((WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString))
-> (OsChar -> Bool) -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString)
PF.span
spanEnd :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
spanEnd :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
spanEnd = ((WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString))
-> (OsChar -> Bool) -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString)
PF.spanEnd
splitAt :: Int -> OsString -> (OsString, OsString)
splitAt :: Int -> OsString -> (OsString, OsString)
splitAt = (Int -> WindowsString -> (WindowsString, WindowsString))
-> Int -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce Int -> WindowsString -> (WindowsString, WindowsString)
PF.splitAt
split :: OsChar -> OsString -> [OsString]
split :: OsChar -> OsString -> [OsString]
split = (WindowsChar -> WindowsString -> [WindowsString])
-> OsChar -> OsString -> [OsString]
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString -> [WindowsString]
PF.split
splitWith :: (OsChar -> Bool) -> OsString -> [OsString]
splitWith :: (OsChar -> Bool) -> OsString -> [OsString]
splitWith = ((WindowsChar -> Bool) -> WindowsString -> [WindowsString])
-> (OsChar -> Bool) -> OsString -> [OsString]
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> [WindowsString]
PF.splitWith
stripSuffix :: OsString -> OsString -> Maybe OsString
stripSuffix :: OsString -> OsString -> Maybe OsString
stripSuffix = (WindowsString -> WindowsString -> Maybe WindowsString)
-> OsString -> OsString -> Maybe OsString
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString -> Maybe WindowsString
PF.stripSuffix
stripPrefix :: OsString -> OsString -> Maybe OsString
stripPrefix :: OsString -> OsString -> Maybe OsString
stripPrefix = (WindowsString -> WindowsString -> Maybe WindowsString)
-> OsString -> OsString -> Maybe OsString
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString -> Maybe WindowsString
PF.stripPrefix
isInfixOf :: OsString -> OsString -> Bool
isInfixOf :: OsString -> OsString -> Bool
isInfixOf = (WindowsString -> WindowsString -> Bool)
-> OsString -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString -> Bool
PF.isInfixOf
isPrefixOf :: OsString -> OsString -> Bool
isPrefixOf :: OsString -> OsString -> Bool
isPrefixOf = (WindowsString -> WindowsString -> Bool)
-> OsString -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString -> Bool
PF.isPrefixOf
isSuffixOf :: OsString -> OsString -> Bool
isSuffixOf :: OsString -> OsString -> Bool
isSuffixOf = (WindowsString -> WindowsString -> Bool)
-> OsString -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString -> Bool
PF.isSuffixOf
breakSubstring :: OsString -> OsString -> (OsString, OsString)
breakSubstring :: OsString -> OsString -> (OsString, OsString)
breakSubstring = (WindowsString -> WindowsString -> (WindowsString, WindowsString))
-> OsString -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce WindowsString -> WindowsString -> (WindowsString, WindowsString)
PF.breakSubstring
elem :: OsChar -> OsString -> Bool
elem :: OsChar -> OsString -> Bool
elem = (WindowsChar -> WindowsString -> Bool)
-> OsChar -> OsString -> Bool
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString -> Bool
PF.elem
find :: (OsChar -> Bool) -> OsString -> Maybe OsChar
find :: (OsChar -> Bool) -> OsString -> Maybe OsChar
find = ((WindowsChar -> Bool) -> WindowsString -> Maybe WindowsChar)
-> (OsChar -> Bool) -> OsString -> Maybe OsChar
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> Maybe WindowsChar
PF.find
filter :: (OsChar -> Bool) -> OsString -> OsString
filter :: (OsChar -> Bool) -> OsString -> OsString
filter = ((WindowsChar -> Bool) -> WindowsString -> WindowsString)
-> (OsChar -> Bool) -> OsString -> OsString
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> WindowsString
PF.filter
partition :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
partition :: (OsChar -> Bool) -> OsString -> (OsString, OsString)
partition = ((WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString))
-> (OsChar -> Bool) -> OsString -> (OsString, OsString)
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool)
-> WindowsString -> (WindowsString, WindowsString)
PF.partition
index :: HasCallStack => OsString -> Int -> OsChar
index :: HasCallStack => OsString -> Int -> OsChar
index = (WindowsString -> Int -> WindowsChar) -> OsString -> Int -> OsChar
forall a b. Coercible a b => a -> b
coerce HasCallStack => WindowsString -> Int -> WindowsChar
WindowsString -> Int -> WindowsChar
PF.index
indexMaybe :: OsString -> Int -> Maybe OsChar
indexMaybe :: OsString -> Int -> Maybe OsChar
indexMaybe = (WindowsString -> Int -> Maybe WindowsChar)
-> OsString -> Int -> Maybe OsChar
forall a b. Coercible a b => a -> b
coerce WindowsString -> Int -> Maybe WindowsChar
PF.indexMaybe
(!?) :: OsString -> Int -> Maybe OsChar
!? :: OsString -> Int -> Maybe OsChar
(!?) = OsString -> Int -> Maybe OsChar
indexMaybe
elemIndex :: OsChar -> OsString -> Maybe Int
elemIndex :: OsChar -> OsString -> Maybe Int
elemIndex = (WindowsChar -> WindowsString -> Maybe Int)
-> OsChar -> OsString -> Maybe Int
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString -> Maybe Int
PF.elemIndex
elemIndices :: OsChar -> OsString -> [Int]
elemIndices :: OsChar -> OsString -> [Int]
elemIndices = (WindowsChar -> WindowsString -> [Int])
-> OsChar -> OsString -> [Int]
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString -> [Int]
PF.elemIndices
count :: OsChar -> OsString -> Int
count :: OsChar -> OsString -> Int
count = (WindowsChar -> WindowsString -> Int) -> OsChar -> OsString -> Int
forall a b. Coercible a b => a -> b
coerce WindowsChar -> WindowsString -> Int
PF.count
findIndex :: (OsChar -> Bool) -> OsString -> Maybe Int
findIndex :: (OsChar -> Bool) -> OsString -> Maybe Int
findIndex = ((WindowsChar -> Bool) -> WindowsString -> Maybe Int)
-> (OsChar -> Bool) -> OsString -> Maybe Int
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> Maybe Int
PF.findIndex
findIndices :: (OsChar -> Bool) -> OsString -> [Int]
findIndices :: (OsChar -> Bool) -> OsString -> [Int]
findIndices = ((WindowsChar -> Bool) -> WindowsString -> [Int])
-> (OsChar -> Bool) -> OsString -> [Int]
forall a b. Coercible a b => a -> b
coerce (WindowsChar -> Bool) -> WindowsString -> [Int]
PF.findIndices