{-# OPTIONS_HADDOCK hide #-}
module Text.HTML.Scalpel.Internal.Scrape.StringLike (
    scrapeStringLike
,   scrapeStringLikeT
) where

import Data.Functor.Identity
import Text.HTML.Scalpel.Internal.Scrape

import qualified Text.HTML.TagSoup as TagSoup
import qualified Text.StringLike as TagSoup

-- | The 'scrapeStringLike' function parses a 'StringLike' value into a list of
-- tags and executes a 'Scraper' on it.
scrapeStringLike :: (TagSoup.StringLike str)
                 => str -> Scraper str a -> Maybe a
scrapeStringLike :: forall str a. StringLike str => str -> Scraper str a -> Maybe a
scrapeStringLike = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Identity a -> a
runIdentity forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall str (m :: * -> *) a.
(StringLike str, Monad m) =>
str -> ScraperT str m a -> m (Maybe a)
scrapeStringLikeT

-- | The 'scrapeStringLikeT' function parses a 'StringLike' value into a list of
-- tags and executes a 'ScraperT' on it. Since 'ScraperT' is a monad
-- transformer, the result is monadic.
scrapeStringLikeT :: (TagSoup.StringLike str, Monad m)
                  => str -> ScraperT str m a -> m (Maybe a)
scrapeStringLikeT :: forall str (m :: * -> *) a.
(StringLike str, Monad m) =>
str -> ScraperT str m a -> m (Maybe a)
scrapeStringLikeT str
tags ScraperT str m a
scraper = forall str (m :: * -> *) a.
StringLike str =>
ScraperT str m a -> [Tag str] -> m (Maybe a)
scrapeT ScraperT str m a
scraper
    (forall str. StringLike str => ParseOptions str -> str -> [Tag str]
TagSoup.parseTagsOptions forall str. StringLike str => ParseOptions str
TagSoup.parseOptionsFast str
tags)