Hoogle Search

Within LTS Haskell 24.6 (ghc-9.10.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. isInfixOf :: Text -> Text -> Bool

    text Data.Text

    O(n+m) The isInfixOf function takes two Texts and returns True if and only if the first is contained, wholly and intact, anywhere within the second. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).

  2. isPrefixOf :: Text -> Text -> Bool

    text Data.Text

    O(n) The isPrefixOf function takes two Texts and returns True if and only if the first is a prefix of the second.

  3. isSuffixOf :: Text -> Text -> Bool

    text Data.Text

    O(n) The isSuffixOf function takes two Texts and returns True if and only if the first is a suffix of the second.

  4. stripPrefix :: Text -> Text -> Maybe Text

    text Data.Text

    O(n) Return the suffix of the second string if its prefix matches the entire first string. Examples:

    >>> stripPrefix "foo" "foobar"
    Just "bar"
    
    >>> stripPrefix ""    "baz"
    Just "baz"
    
    >>> stripPrefix "foo" "quux"
    Nothing
    
    This is particularly useful with the ViewPatterns extension to GHC, as follows:
    {-# LANGUAGE ViewPatterns #-}
    import Data.Text as T
    
    fnordLength :: Text -> Int
    fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf
    fnordLength _                                 = -1
    

  5. stripSuffix :: Text -> Text -> Maybe Text

    text Data.Text

    O(n) Return the prefix of the second string if its suffix matches the entire first string. Examples:

    >>> stripSuffix "bar" "foobar"
    Just "foo"
    
    >>> stripSuffix ""    "baz"
    Just "baz"
    
    >>> stripSuffix "foo" "quux"
    Nothing
    
    This is particularly useful with the ViewPatterns extension to GHC, as follows:
    {-# LANGUAGE ViewPatterns #-}
    import Data.Text as T
    
    quuxLength :: Text -> Int
    quuxLength (stripSuffix "quux" -> Just pre) = T.length pre
    quuxLength _                                = -1
    

  6. decodeASCIIPrefix :: ByteString -> (Text, ByteString)

    text Data.Text.Encoding

    Decode a ByteString containing ASCII text. This is a total function which returns a pair of the longest ASCII prefix as Text, and the remaining suffix as ByteString. Important note: the pair is lazy. This lets you check for errors by testing whether the second component is empty, without forcing the first component (which does a copy). To drop references to the input bytestring, force the prefix (using seq or BangPatterns) and drop references to the suffix.

    Properties

    • If (prefix, suffix) = decodeAsciiPrefix s, then encodeUtf8 prefix <> suffix = s.
    • Either suffix is empty, or head suffix > 127.

  7. isPrefixOf :: Eq a => Stream a -> Stream a -> Bool

    text Data.Text.Internal.Fusion.Common

    O(n) The isPrefixOf function takes two Streams and returns True if and only if the first is a prefix of the second. Properties

    isPrefixOf (stream t1) (stream t2) = isPrefixOf t1 t2
    

  8. commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)

    text Data.Text.Lazy

    O(n) Find the longest non-empty common prefix of two strings and return it, along with the suffixes of each string at which they no longer match. If the strings do not have a common prefix or either one is empty, this function returns Nothing. Examples:

    commonPrefixes "foobar" "fooquux" == Just ("foo","bar","quux")
    commonPrefixes "veeble" "fetzer"  == Nothing
    commonPrefixes "" "baz"           == Nothing
    

  9. isInfixOf :: Text -> Text -> Bool

    text Data.Text.Lazy

    O(n+m) The isInfixOf function takes two Texts and returns True if and only if the first is contained, wholly and intact, anywhere within the second. This function is strict in its first argument, and lazy in its second. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).

  10. isPrefixOf :: Text -> Text -> Bool

    text Data.Text.Lazy

    O(n) The isPrefixOf function takes two Texts and returns True if and only if the first is a prefix of the second.

Page 31 of many | Previous | Next