Closed xanderdunn closed 8 years ago
Indeed, it was very simple! I simply needed to make use of the empty
MonadPlus
instance of Scraper
as an alternative when something like location can't be found: location <|> empty
.
Thanks for reporting your findings! I was struggling with the same thing, so this was helpful.
Example: Scraping Tweets. Some tweets have location information, and some don't. Some tweets have an extra "card url", and some don't.
If I define a scraper like this:
then it will only return scraped values for those tweets that have both a location and card_url. That is, nothing at all will be returned for a huge majority of tweets, because most tweets are missing either a location or a card_url.
Is it possible to define a
Scraper
as optional, rather than a necessary match that causes theScraper
to return nothing when it isn't matched?Or, is there an "and" operator, as opposed to the
<|>
operator? I could do something like scrape all the locations AND all the card urls AND all the rest of the infos?Or, this would also be easily achievable with a Scraper that returned a fixed value, something like
Scraper ""
, which returns the emptyString
. Then I could use the OR operator:location <|> Scraper ""
.