Popularity
4.5
Growing
Activity
0.0
Stable
2
3
3
Monthly Downloads: 14
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
hexml-lens alternatives and similar packages
Based on the "lens" category.
Alternatively, view hexml-lens alternatives based on common mentions on social networks and blogs.
-
lens
Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens -
lens-family-th
Template Haskell to generate lenses for lens-family and lens-family-core -
lens-th-rewrite
GHC plugin to rewrite lens Template Haskell splices into pure functions
TestGPT | Generating meaningful tests for busy devs
Get non-trivial tests (and trivial, too!) suggested right inside your IDE, so you can code smart, create more value, and stay confident when you push.
Promo
codium.ai
Do you think we are missing an alternative of hexml-lens or a related project?
Popular Comparisons
README
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 = "http://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)