Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select should accept [Tag] #4

Open
domenkozar opened this issue Oct 15, 2016 · 4 comments
Open

select should accept [Tag] #4

domenkozar opened this issue Oct 15, 2016 · 4 comments

Comments

@domenkozar
Copy link
Contributor

domenkozar commented Oct 15, 2016

I'd propose to give a following example of using Haquery in ghci, which is one of the common usages of fetching a website and parsing it.

import Haquery (select, parseHtml)
import Network.Wreq (get, responseBody)
import Control.Lens (^.)
import Data.Text (pack)

r <- get "http://nixos.org/channels/"
Prelude.concatMap (select (pack "a")) $ parseHtml $ pack $ show (r ^. responseBody)

Which motivates me to say that select should accept a list of Tags, since that's what parseHtml returns.

PS: I'm fairly new to Haskell ecosystem, so excuse my ignorance :)

@domenkozar
Copy link
Contributor Author

domenkozar commented Oct 15, 2016

Another strong reason is that the returned [Tag] can be then chained to subsequent select calls.

@domenkozar domenkozar changed the title select may get a list of Tags select should accept [Tag] Oct 15, 2016
@Wizek
Copy link

Wizek commented Mar 9, 2017

Yes, I think I'd also like this change. Any reason to the contrary, @crufter?

@Wizek
Copy link

Wizek commented Mar 9, 2017

Just occured to me that we could also define

selects :: Text -> [Tag] -> [Tag]
selects sel tags = concat $ map (select sel) tags

@crufter
Copy link
Owner

crufter commented Mar 9, 2017

@Wizek I will implement that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants