| CARVIEW |
Select Language
HTTP/1.1 200 OK
Connection: keep-alive
Server: nginx/1.24.0 (Ubuntu)
Content-Type: text/html; charset=utf-8
Cache-Control: public, max-age=300
Content-Encoding: gzip
Via: 1.1 varnish, 1.1 varnish
Accept-Ranges: bytes
Age: 0
Date: Sat, 17 Jan 2026 20:09:51 GMT
X-Served-By: cache-dfw-kdfw8210094-DFW, cache-bom-vanm7210092-BOM
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1768680591.803022,VS0,VE864
Vary: Accept, Accept-Encoding
transfer-encoding: chunked
hexml-lens: Lenses for the hexml package
hexml-lens: Lenses for the hexml package
Downloads
- hexml-lens-0.2.2.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1.0.0, 0.1.1, 0.2.0, 0.2.1, 0.2.2 |
|---|---|
| Dependencies | base (>=4.7 && <5), bytestring, contravariant, foundation, hexml, lens, profunctors, text [details] |
| License | BSD-3-Clause |
| Copyright | All Rights Reserved |
| Author | Jose Iborra |
| Maintainer | pepeiborra@gmail.com |
| Uploaded | by PepeIborra at 2022-04-05T06:41:26Z |
| Category | lens |
| Home page | https://github.com/pepeiborra/hexml-lens#readme |
| Distributions | LTSHaskell:0.2.2, Stackage:0.2.2 |
| Reverse Dependencies | 1 direct, 0 indirect [details] |
| Downloads | 3554 total (18 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs available [build log] Last success reported on 2022-04-05 [all 1 reports] |
Readme for hexml-lens-0.2.2
[back to package description]hexml-lens
Folds and getters for the Hexml Node type.
{-# LANGUAGE RecordWildCards #-}
import Control.Lens hiding (children)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy.Char8 as LB
import Network.Wreq
import Text.XML.Hexml
import Text.XML.Hexml.Lens
url :: [Char]
url = "https://aiweb.cs.washington.edu/research/projects/xmltk/xmldata/data/courses/reed.xml"
data Place s = Place { building :: s , room :: Int}
deriving Show
data Course s = Course { title, instructor :: s , place :: Place s}
deriving Show
main :: IO ()
main = do
r <- get url
let stripDocType = LB.unlines . drop 2 . LB.lines
let courses = take 10 $ r ^.. responseBody . to stripDocType . _XML . _children . folded . courseF
print courses
courseF :: Fold Node (Course B.ByteString)
courseF = runFold $ do
title <- Fold $ node "title" . textContents
instructor <- Fold $ node "instructor" . textContents
place <- Fold $ node "place" . placeF
return $ Course{..}
placeF :: Fold Node (Place B.ByteString)
placeF = runFold $ do
building <- Fold $ node "building" . textContents
room <- Fold $ node "room" . textContents . _Show
return (Place building room)