2 | import public Cheerio.Data
4 | import public Cheerio.Css
5 | import public Cheerio.Forms
6 | import public Cheerio.Traversing
7 | import public Cheerio.Attributes
8 | import public Cheerio.Manipulation
13 | %foreign "node:lambda: html => require('cheerio').load(html)"
14 | prim_load : String -> PrimIO CheerioApi
17 | load : HasIO io => String -> io CheerioApi
18 | load n = primIO $
prim_load n
21 | %foreign "node:lambda: (selector, $) => $(selector)"
22 | prim_query : String -> CheerioApi -> PrimIO Cheerio
25 | query : HasIO io => String -> CheerioApi -> io Cheerio
26 | query selector cheerioapi = primIO $
prim_query selector cheerioapi
29 | %foreign "node:lambda: (any, $) => $(any)"
30 | prim_wrap : AnyNode -> CheerioApi -> PrimIO Cheerio
33 | wrap : HasIO io => AnyNode -> CheerioApi -> io Cheerio
34 | wrap any cheerioapi = primIO $
prim_wrap any cheerioapi
38 | che <- load "<h2 class=\"title\"><p id=\"world\">Hello world22</p><span>span123</span></h2>"
39 | h2 <- query "h2" che
42 | putStrLn $
fromMaybe "nothing" t