Reputation: 4561
Within Haskell I have a program that scrapes the html off a page and stores it in a variable called 'html' which is type IO (). I then want to generate a list of type String that holds all the matches by a pattern from that web page.
These two lines below generate a list of matches from the pattern
let pattern = "..." --note, regex is omited
html =~ pattern :: String -> IO String
I get the error:
What I want to do is something like:
let pattern = "..."
let matches_list = html =~ pattern :: String -> IO String
Where matches_list of type String is a list of matches.
EDIT
The actual scraper which I got from here works simply like this:
Imagine 'src' is my 'html' variable
Upvotes: 0
Views: 271
Reputation: 36375
You are trying to cast the result of the regular expression matcher into a function that takes a string and returns an IO String
, but based on your description, it sounds like you'd rather just cast it into a list of strings, and although you haven't specified what regular expression library you are using, your fix is probably as simple as changing this:
let matches_list = html =~ pattern :: String -> IO String
into this:
let matches_list = html =~ pattern :: [String]
Upvotes: 1