Copyright | (c) Mateusz Kowalczyk 2014 |
---|---|
License | GPL-3 |
Maintainer | fuuzetsu@fuuzetsu.co.uk |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
A collection of arrow parsers for known fields. We can use these (and write new ones) by composing these parsers together for each site we want to parse. As we carry the field information with us, this can later be used when trying to extract the parsed information from the sites into a homogenous list. Currently this moduel only deals with parsing out XML attributes.
- newtype E = E String
- type ParseArrow cat = (Functor (cat XmlTree), ArrowXml cat)
- type Field cat s = cat XmlTree (Parse (R `[s]`))
- readAttr :: (ArrowXml cat, Read (App ElF s), Functor (cat XmlTree)) => String -> sing s -> Field cat s
- readAttrWith :: (ArrowXml cat, Functor (cat XmlTree)) => String -> sing s -> (String -> Maybe (App ElF s)) -> Field cat s
- readCustom :: (ArrowXml cat, Functor (cat XmlTree)) => String -> sing s -> (String -> Parse (App ElF s)) -> Field cat s
- readNormalAttr :: (ArrowXml cat, App ElF s ~ String, Functor (cat XmlTree)) => String -> sing s -> Field cat s
- heightA :: ParseArrow cat => Field cat "height"
- scoreA :: ParseArrow cat => Field cat "score"
- file_urlA :: ParseArrow cat => Field cat "file_url"
- parent_idA :: ParseArrow cat => Field cat "parent_id"
- sample_urlA :: ParseArrow cat => Field cat "sample_url"
- sample_widthA :: ParseArrow cat => Field cat "sample_width"
- sample_heightA :: ParseArrow cat => Field cat "sample_height"
- preview_urlA :: ParseArrow cat => Field cat "preview_url"
- ratingA :: ParseArrow cat => Field cat "rating"
- tagsA :: ParseArrow cat => Field cat "tags"
- idA :: ParseArrow cat => Field cat "id"
- widthA :: ParseArrow cat => Field cat "width"
- changeA :: ParseArrow cat => Field cat "change"
- md5A :: ParseArrow cat => Field cat "md5"
- creator_idA :: ParseArrow cat => Field cat "creator_id"
- has_childrenA :: ParseArrow cat => Field cat "has_children"
- created_atA :: ParseArrow cat => Field cat "created_at"
- statusA :: ParseArrow cat => Field cat "status"
- sourceA :: ParseArrow cat => Field cat "source"
- has_notesA :: ParseArrow cat => Field cat "has_notes"
- has_commentsA :: ParseArrow cat => Field cat "has_comments"
- preview_widthA :: ParseArrow cat => Field cat "preview_width"
- preview_heightA :: ParseArrow cat => Field cat "preview_height"
- authorA :: ParseArrow cat => Field cat "author"
- actual_preview_heightA :: ParseArrow cat => Field cat "actual_preview_height"
- actual_preview_widthA :: ParseArrow cat => Field cat "actual_preview_width"
- framesA :: ParseArrow cat => Field cat "frames"
- frames_pendingA :: ParseArrow cat => Field cat "frames_pending"
- frames_pending_stringA :: ParseArrow cat => Field cat "frames_pending_string"
- frames_stringA :: ParseArrow cat => Field cat "frames_string"
- is_heldA :: ParseArrow cat => Field cat "is_held"
- is_shown_in_indexA :: ParseArrow cat => Field cat "is_shown_in_index"
- jpeg_file_sizeA :: ParseArrow cat => Field cat "jpeg_file_size"
- jpeg_heightA :: ParseArrow cat => Field cat "jpeg_height"
- jpeg_urlA :: ParseArrow cat => Field cat "jpeg_url"
- jpeg_widthA :: ParseArrow cat => Field cat "jpeg_width"
- sample_file_sizeA :: ParseArrow cat => Field cat "sample_file_size"
- file_sizeA :: ParseArrow cat => Field cat "file_size"
- parseRating :: String -> Maybe Rating
- parseTags :: String -> [Tag]
- parseBool :: String -> Maybe Bool
- (<:+>) :: Arrow cat => cat b (Parse (R as)) -> cat b (Parse (R bs)) -> cat b (Parse (R (as ++ bs)))
Documentation
type ParseArrow cat = (Functor (cat XmlTree), ArrowXml cat) Source
Alias for the common constraint blob
readAttr :: (ArrowXml cat, Read (App ElF s), Functor (cat XmlTree)) => String -> sing s -> Field cat s Source
Helper that provides better error messages when a read
fails.
readAttrWith :: (ArrowXml cat, Functor (cat XmlTree)) => String -> sing s -> (String -> Maybe (App ElF s)) -> Field cat s Source
readCustom :: (ArrowXml cat, Functor (cat XmlTree)) => String -> sing s -> (String -> Parse (App ElF s)) -> Field cat s Source
readNormalAttr :: (ArrowXml cat, App ElF s ~ String, Functor (cat XmlTree)) => String -> sing s -> Field cat s Source
Individual attribute parsers
heightA :: ParseArrow cat => Field cat "height" Source
Parser arrow for a "height" XML attribute.
scoreA :: ParseArrow cat => Field cat "score" Source
Parser arrow for a "score" XML attribute.
file_urlA :: ParseArrow cat => Field cat "file_url" Source
Parser arrow for a "file_url" XML attribute.
parent_idA :: ParseArrow cat => Field cat "parent_id" Source
Parser arrow for a "parent_id" XML attribute.
sample_urlA :: ParseArrow cat => Field cat "sample_url" Source
Parser arrow for a "sample_url" XML attribute.
sample_widthA :: ParseArrow cat => Field cat "sample_width" Source
Parser arrow for a "sample_width" XML attribute.
sample_heightA :: ParseArrow cat => Field cat "sample_height" Source
Parser arrow for a "sample_height" XML attribute.
preview_urlA :: ParseArrow cat => Field cat "preview_url" Source
Parser arrow for a "preview_url" XML attribute.
ratingA :: ParseArrow cat => Field cat "rating" Source
Parser arrow for a "rating" XML attribute.
tagsA :: ParseArrow cat => Field cat "tags" Source
Parser arrow for a "tags" XML attribute.
idA :: ParseArrow cat => Field cat "id" Source
Parser arrow for a "id" XML attribute.
widthA :: ParseArrow cat => Field cat "width" Source
Parser arrow for a "width" XML attribute.
changeA :: ParseArrow cat => Field cat "change" Source
Parser arrow for a "change" XML attribute.
md5A :: ParseArrow cat => Field cat "md5" Source
Parser arrow for a "md5" XML attribute.
creator_idA :: ParseArrow cat => Field cat "creator_id" Source
Parser arrow for a "creator_id" XML attribute.
has_childrenA :: ParseArrow cat => Field cat "has_children" Source
Parser arrow for a "has_children" XML attribute.
created_atA :: ParseArrow cat => Field cat "created_at" Source
Parser arrow for a "created_at" XML attribute.
statusA :: ParseArrow cat => Field cat "status" Source
Parser arrow for a "status" XML attribute.
sourceA :: ParseArrow cat => Field cat "source" Source
Parser arrow for a "source" XML attribute.
has_notesA :: ParseArrow cat => Field cat "has_notes" Source
Parser arrow for a "has_notes" XML attribute.
has_commentsA :: ParseArrow cat => Field cat "has_comments" Source
Parser arrow for a "has_comments" XML attribute.
preview_widthA :: ParseArrow cat => Field cat "preview_width" Source
Parser arrow for a "preview_width" XML attribute.
preview_heightA :: ParseArrow cat => Field cat "preview_height" Source
Parser arrow for a "preview_height" XML attribute.
authorA :: ParseArrow cat => Field cat "author" Source
Parser arrow for a "author" XML attribute.
actual_preview_heightA :: ParseArrow cat => Field cat "actual_preview_height" Source
Parser arrow for a "actual_preview_height" XML attribute.
actual_preview_widthA :: ParseArrow cat => Field cat "actual_preview_width" Source
Parser arrow for a "actual_preview_width" XML attribute.
framesA :: ParseArrow cat => Field cat "frames" Source
Parser arrow for a "frames" XML attribute.
frames_pendingA :: ParseArrow cat => Field cat "frames_pending" Source
Parser arrow for a "frames_pending" XML attribute.
frames_pending_stringA :: ParseArrow cat => Field cat "frames_pending_string" Source
Parser arrow for a "frames_pending_string" XML attribute.
frames_stringA :: ParseArrow cat => Field cat "frames_string" Source
Parser arrow for a "frames_string" XML attribute.
is_heldA :: ParseArrow cat => Field cat "is_held" Source
Parser arrow for a "is_held" XML attribute.
is_shown_in_indexA :: ParseArrow cat => Field cat "is_shown_in_index" Source
Parser arrow for a "is_shown_in_index" XML attribute.
jpeg_file_sizeA :: ParseArrow cat => Field cat "jpeg_file_size" Source
Parser arrow for a "jpeg_file_size" XML attribute.
jpeg_heightA :: ParseArrow cat => Field cat "jpeg_height" Source
Parser arrow for a "jpeg_height" XML attribute.
jpeg_urlA :: ParseArrow cat => Field cat "jpeg_url" Source
Parser arrow for a "jpeg_url" XML attribute.
jpeg_widthA :: ParseArrow cat => Field cat "jpeg_width" Source
Parser arrow for a "jpeg_width" XML attribute.
sample_file_sizeA :: ParseArrow cat => Field cat "sample_file_size" Source
Parser arrow for a "sample_file_size" XML attribute.
file_sizeA :: ParseArrow cat => Field cat "file_size" Source
Parser arrow for a "file_size" XML attribute.
Parsing helpers
parseRating :: String -> Maybe Rating Source
Parses a string returned from a Gelbooru-like site into
one of the commonly used Rating
s. Note that this is a partial function
so you should make sure that the site in question only ever returns the
values in a format specified in the function
parseTags :: String -> [Tag] Source
Splits returned tag string into separate Tag
s. For Gelbooru-like
sites, this is just the question of splitting on whitespace.