parse :: Int -> [SearchPattern] -> URI -> PageType -> CharlotteResponse -> [Result PageType Match]
parse maxDepth patterns crawlHostURI (ScrapedPage depth ref) resp = let
  nextDepth = succ depth
  tagTree = parseTagTree resp
  links = parseLinks crawlHostURI tagTree
  responsePath = resp ^. uri & URI.uriPath & pack
  reqs = catMaybes $ mkRequest <$> map (pack . show) links
  results = map (\r->Request (ScrapedPage nextDepth responsePath, r)) reqs
  items = map Item $ mapMaybe (performPatternMatch resp responsePath depth ref) patterns
  in if depth < maxDepth then results <> items else items
parse :: Int -> [SearchPattern] -> URI -> PageType -> CharlotteResponse -> [Result PageType Match]
parse maxDepth patterns crawlHostURI (ScrapedPage depth ref) resp = let
  nextDepth = succ depth
  tagTree = parseTagTree resp
  links = parseLinks crawlHostURI tagTree
  responsePath = resp ^. uri & URI.uriPath & pack
  reqs = catMaybes $ mkRequest <$> map (pack . show) links
  results = map (\r->Request (ScrapedPage nextDepth responsePath, r)) reqs
  items = map Item $ mapMaybe (performPatternMatch resp responsePath depth ref) patterns
  in if depth < maxDepth then results <> items else items
parse maxDepth patterns crawlHostURI (ScrapedPage depth ref) resp = let
  nextDepth = succ depth
  tagTree = parseTagTree resp
  links = parseLinks crawlHostURI tagTree
  responsePath = resp ^. uri & URI.uriPath & pack
  reqs = catMaybes $ mkRequest <$> map (pack . show) links
  results = map (\r->Request (ScrapedPage nextDepth responsePath, r)) reqs
  items = map Item $ mapMaybe (performPatternMatch resp responsePath depth ref) patterns
  in if depth < maxDepth then results <> items else items