Last active
August 29, 2015 14:03
-
-
Save spion/2872e5e793315b1ee1e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map.Strict as M | |
data Node = Text String | Element (M.Map String AttributeValue) | |
data AttributeValue = Value String | Content [Node] | |
extractContent :: Node -> [String] | |
extractContent (Text s) = [s] | |
extractContent (Element e) = | |
case M.lookup "content" e of | |
Just (Content list) -> list >>= extractContent | |
_ -> [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map.Strict as M | |
type Attributes = M.Map String String | |
data Node = Text String | Element Attributes [Node] | |
extractContent :: Node -> [String] | |
extractContent (Text s) = [s] | |
extractContent (Element _ nodes) = nodes >>= extractContent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment