tagsoup-0.14.8: Parsing and extracting information from (possibly malformed) HTML/XML documents

Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.StringLike

Description

WARNING: This module is not intended for use outside the TagSoup library.

This module provides an abstraction for String's as used inside TagSoup. It allows TagSoup to work with String (list of Char), ByteString.Char8, ByteString.Lazy.Char8, Data.Text and Data.Text.Lazy.

Synopsis

- class (Typeable a, Eq a, IsString a) => StringLike a where
  - empty :: a
  - cons :: Char -> a -> a
  - uncons :: a -> Maybe (Char, a)
  - toString :: a -> String
  - fromChar :: Char -> a
  - strConcat :: [a] -> a
  - strNull :: a -> Bool
  - append :: a -> a -> a
  - strMap :: (Char -> Char) -> a -> a
- fromString :: IsString a => String -> a
- castString :: (StringLike a, StringLike b) => a -> b

# Documentation

class (Typeable a, Eq a, IsString a) => StringLike a where #

A class to generalise TagSoup parsing over many types of string-like types. Examples are given for the String type.

Methods

empty :: a #

    empty = ""

cons :: Char -> a -> a #

    cons = (:)

uncons :: a -> Maybe (Char, a) #

    uncons []     = Nothing
    uncons (x:xs) = Just (x, xs)

toString :: a -> String #

    toString = id

fromChar :: Char -> a #

    fromChar = return

strConcat :: [a] -> a #

    strConcat = concat

strNull :: a -> Bool #

    strNull = null

append :: a -> a -> a #

    append = (++)

strMap :: (Char -> Char) -> a -> a #

    strMap = map

#### Instances

Instances details

StringLike ByteString # |

Instance details

Defined in Text.StringLike

Methods

empty :: ByteString #

cons :: Char -> ByteString -> ByteString #

uncons :: ByteString -> Maybe (Char, ByteString) #

toString :: ByteString -> String #

fromChar :: Char -> ByteString #

strConcat :: [ByteString] -> ByteString #

strNull :: ByteString -> Bool #

append :: ByteString -> ByteString -> ByteString #

strMap :: (Char -> Char) -> ByteString -> ByteString #

StringLike ByteString # |

Instance details

Defined in Text.StringLike

Methods

empty :: ByteString #

cons :: Char -> ByteString -> ByteString #

uncons :: ByteString -> Maybe (Char, ByteString) #

toString :: ByteString -> String #

fromChar :: Char -> ByteString #

strConcat :: [ByteString] -> ByteString #

strNull :: ByteString -> Bool #

append :: ByteString -> ByteString -> ByteString #

strMap :: (Char -> Char) -> ByteString -> ByteString #

StringLike Text # |
Instance details Defined in Text.StringLike Methods empty :: Text # cons :: Char -> Text -> Text # uncons :: Text -> Maybe (Char, Text) # toString :: Text -> String # fromChar :: Char -> Text # strConcat :: [Text] -> Text # strNull :: Text -> Bool # append :: Text -> Text -> Text # strMap :: (Char -> Char) -> Text -> Text #
StringLike Text # |
Instance details Defined in Text.StringLike Methods empty :: Text # cons :: Char -> Text -> Text # uncons :: Text -> Maybe (Char, Text) # toString :: Text -> String # fromChar :: Char -> Text # strConcat :: [Text] -> Text # strNull :: Text -> Bool # append :: Text -> Text -> Text # strMap :: (Char -> Char) -> Text -> Text #
StringLike String # |
Instance details Defined in Text.StringLike Methods empty :: String # cons :: Char -> String -> String # uncons :: String -> Maybe (Char, String) # toString :: String -> String # fromChar :: Char -> String # strConcat :: [String] -> String # strNull :: String -> Bool # append :: String -> String -> String # strMap :: (Char -> Char) -> String -> String #

fromString :: IsString a => String -> a #

castString :: (StringLike a, StringLike b) => a -> b #

Convert a String from one type to another.