| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.String.Class
Synopsis
- class (StringCells s, StringRWIO s) => Stringy s
- class (Eq s, Monoid s, IsString s, Typeable s, StringCell (StringCellChar s), StringCell (StringCellAltChar s), ConvGenString s, ConvString s, ConvStrictByteString s, ConvLazyByteString s, ConvText s, ConvLazyText s) => StringCells s where
- type StringCellChar s
- type StringCellAltChar s
- class StringCell c where
- class StringRWIO s where
- class ConvGenString s where
- class ConvString s where
- class ConvStrictByteString s where
- class ConvLazyByteString s where
- class ConvText s where
- data GenString = Stringy s => GenString {
- gen_string :: s
- type GenStringDefault = ByteString
Documentation
class (StringCells s, StringRWIO s) => Stringy s #
String super class
Instances
| (StringCells s, StringRWIO s) => Stringy s # | |
Defined in Data.String.Class | |
class (Eq s, Monoid s, IsString s, Typeable s, StringCell (StringCellChar s), StringCell (StringCellAltChar s), ConvGenString s, ConvString s, ConvStrictByteString s, ConvLazyByteString s, ConvText s, ConvLazyText s) => StringCells s where #
Minimal complete definition: StringCellChar; StringCellAltChar; toStringCells; fromStringCells; toMainChar; toAltChar; cons; snoc; either all of head, tail, last, and init, or all of uncons and unsnoc; take, take64 or genericTake; drop, drop64, or genericDrop; and length, length64, or genericLength
Minimal complete definition
toStringCells, fromStringCells, cons, snoc, toMainChar, toAltChar
Methods
toStringCells :: StringCells s2 => s -> s2 #
fromStringCells :: StringCells s2 => s2 -> s #
cons :: StringCellChar s -> s -> s infixr 9 #
uncons :: s -> (StringCellChar s, s) infixr 9 #
snoc :: s -> StringCellChar s -> s #
unsnoc :: s -> (s, StringCellChar s) #
altCons :: StringCellAltChar s -> s -> s infixr 9 #
altUncons :: s -> (StringCellAltChar s, s) infixr 9 #
altSnoc :: s -> StringCellAltChar s -> s #
altUnsnoc :: s -> (s, StringCellAltChar s) #
toMainChar :: StringCell c => c -> Tagged s (StringCellChar s) #
toAltChar :: StringCell c => c -> Tagged s (StringCellAltChar s) #
append :: s -> s -> s infixr 9 #
Append two strings
head :: s -> StringCellChar s #
last :: s -> StringCellChar s #
altHead :: s -> StringCellAltChar s #
altLast :: s -> StringCellAltChar s #
unfoldr :: (a -> Maybe (StringCellChar s, a)) -> a -> s #
Construction of a string; implementations should behave safely with incorrect lengths
The default implementation of unfoldr is independent from that of altUnfoldr,
as well as unfoldrN as and altUnfoldrN.
altUnfoldr :: (a -> Maybe (StringCellAltChar s, a)) -> a -> s #
unfoldrN :: Int -> (a -> Maybe (StringCellChar s, a)) -> a -> s #
altUnfoldrN :: Int -> (a -> Maybe (StringCellAltChar s, a)) -> a -> s #
unfoldrN64 :: Int64 -> (a -> Maybe (StringCellChar s, a)) -> a -> s #
altUnfoldrN64 :: Int64 -> (a -> Maybe (StringCellAltChar s, a)) -> a -> s #
index :: s -> Int -> StringCellChar s #
Get the character at the given position
Just like drop, drop64, and the variants of those functions, the
default definitions of these three variants are independent of each
other, and are defined in terms of head and tail, which can be
inefficient.
index64 :: s -> Int64 -> StringCellChar s #
genericIndex :: Integral i => s -> i -> StringCellChar s #
Index a string at any location
Just like the other generic functions of this module, this function
can be significantly slower than index, since the function must be
able to support arbitrarily large indices. Consider using index or
index64, even if you need to coerce the index to an Int.
genericTake :: Integral i => i -> s -> s #
genericDrop :: Integral i => i -> s -> s #
genericLength :: Integral i => s -> i #
safeUncons :: s -> Maybe (StringCellChar s, s) #
safeUnsnoc :: s -> Maybe (s, StringCellChar s) #
safeAltUncons :: s -> Maybe (StringCellAltChar s, s) #
safeAltUnsnoc :: s -> Maybe (s, StringCellAltChar s) #
safeHead :: s -> Maybe (StringCellChar s) #
safeLast :: s -> Maybe (StringCellChar s) #
safeAltHead :: s -> Maybe (StringCellAltChar s) #
safeAltLast :: s -> Maybe (StringCellAltChar s) #
safeIndex :: s -> Int -> Maybe (StringCellChar s) #
safeIndex64 :: s -> Int64 -> Maybe (StringCellChar s) #
safeGenericIndex :: Integral i => s -> i -> Maybe (StringCellChar s) #
safeTake :: Int -> s -> Maybe s #
safeTake64 :: Int64 -> s -> Maybe s #
safeGenericTake :: Integral i => i -> s -> Maybe s #
safeDrop :: Int -> s -> Maybe s #
safeDrop64 :: Int64 -> s -> Maybe s #
safeGenericDrop :: Integral i => i -> s -> Maybe s #
safeUncons2 :: s -> Maybe (StringCellChar s, StringCellChar s, s) #
safeUncons3 :: s -> Maybe (StringCellChar s, StringCellChar s, StringCellChar s, s) #
safeUncons4 :: s -> Maybe (StringCellChar s, StringCellChar s, StringCellChar s, StringCellChar s, s) #
cons2 :: StringCellChar s -> StringCellChar s -> s -> s infixr 9 #
cons3 :: StringCellChar s -> StringCellChar s -> StringCellChar s -> s -> s infixr 9 #
cons4 :: StringCellChar s -> StringCellChar s -> StringCellChar s -> StringCellChar s -> s -> s infixr 9 #
uncons2 :: s -> (StringCellChar s, StringCellChar s, s) infixr 9 #
uncons3 :: s -> (StringCellChar s, StringCellChar s, StringCellChar s, s) infixr 9 #
uncons4 :: s -> (StringCellChar s, StringCellChar s, StringCellChar s, StringCellChar s, s) infixr 9 #
Instances
class StringCell c where #
Minimal complete definition
toChar, toWord8, toWord16, toWord32, toWord64, fromChar, fromWord8, fromWord16, fromWord32, fromWord64
Instances
| StringCell Char # | |
Defined in Data.String.Class | |
| StringCell Word8 # | |
Defined in Data.String.Class | |
| StringCell Word16 # | |
| StringCell Word32 # | |
| StringCell Word64 # | |
class StringRWIO s where #
Minimal complete definition: hGetContents, hGetLine, hPutStr, and hPutStrLn
Minimal complete definition
Methods
hGetContents :: Handle -> IO s #
Read n bytes *or* characters, depending on the implementation into a ByteString, directly from the specified Handle
Whether or not this function is lazy depends on the instance; laziness is preferred.
Read a single line from a handle
hPutStr :: Handle -> s -> IO () #
Write a string to a handle
hPutStrLn :: Handle -> s -> IO () #
Write a string to a handle, followed by a newline
N.B.: implementations might not define this atomically. If the state
of being atomic is necessary, one possible solution is to convert a
string to an efficient type for which hPutStrLn is atomic.
interact :: (s -> s) -> IO () #
Take a function of type Text -> Text as its argument
The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.
getContents :: IO s #
Read all user input on stdin as a single string
Read a single line of user input from stdin
Write a string to stdout
Write a string to stdout, followed by a newline
readFile :: FilePath -> IO s #
Read a file and returns the contents of the file as a string
Depending on the instance, this function might expect the file to be
non-binary. The default definition uses openFile to open the file.
writeFile :: FilePath -> s -> IO () #
Write a string to a file
The file is truncated to zero length before writing begins.
The default definition uses withFile to open the file.
appendFile :: FilePath -> s -> IO () #
Write a string to the end of a file
The default definition uses withFile to open the file.
Instances
class ConvGenString s where #
Minimal complete definition
Instances
| ConvGenString String # | |
Defined in Data.String.Class | |
| ConvGenString ByteString # | |
Defined in Data.String.Class | |
| ConvGenString ByteString # | |
Defined in Data.String.Class | |
| ConvGenString Text # | |
Defined in Data.String.Class | |
| ConvGenString Text # | |
Defined in Data.String.Class | |
| ConvGenString GenString # | |
Defined in Data.String.Class | |
class ConvString s where #
Minimal complete definition
Instances
| ConvString String # | |
Defined in Data.String.Class | |
| ConvString ByteString # | |
Defined in Data.String.Class | |
| ConvString ByteString # | |
Defined in Data.String.Class | |
| ConvString Text # | |
Defined in Data.String.Class | |
| ConvString Text # | |
Defined in Data.String.Class | |
| ConvString GenString # | |
Defined in Data.String.Class | |
class ConvStrictByteString s where #
Minimal complete definition
Instances
| ConvStrictByteString String # | |
Defined in Data.String.Class | |
| ConvStrictByteString ByteString # | |
Defined in Data.String.Class Methods | |
| ConvStrictByteString ByteString # | |
Defined in Data.String.Class Methods | |
| ConvStrictByteString Text # | |
Defined in Data.String.Class | |
| ConvStrictByteString Text # | |
Defined in Data.String.Class | |
| ConvStrictByteString GenString # | |
Defined in Data.String.Class Methods | |
class ConvLazyByteString s where #
Minimal complete definition
Instances
| ConvLazyByteString String # | |
Defined in Data.String.Class | |
| ConvLazyByteString ByteString # | |
Defined in Data.String.Class Methods | |
| ConvLazyByteString ByteString # | |
Defined in Data.String.Class Methods | |
| ConvLazyByteString Text # | |
Defined in Data.String.Class | |
| ConvLazyByteString Text # | |
Defined in Data.String.Class | |
| ConvLazyByteString GenString # | |
Defined in Data.String.Class | |
Instances
| ConvText String # | |
| ConvText ByteString # | |
Defined in Data.String.Class | |
| ConvText ByteString # | |
Defined in Data.String.Class | |
| ConvText Text # | |
| ConvText Text # | |
| ConvText GenString # | |
Polymorphic container of a string
When operations take place on multiple GenStrings, they are first
converted to the type GenStringDefault, which are lazy bytestrings,
whenever absolutely necessary (which includes testing for equality,
appending strings, concatenating lists of strings, empty strings with
empty, and unfolding), making them the most efficient type for this
polymorphic container.
Constructors
| Stringy s => GenString | |
Fields
| |
Instances
type GenStringDefault = ByteString #
This type is used by GenString when a concrete string type is needed