Skip to content

Text.XML.Stream.Parse.choose seems to be awkward to use. #72

@seanparsons

Description

@seanparsons

The choose method seems to be quite troublesome to use:

getTagContent :: Name -> Consumer Event IO (Maybe (Name, Text))
getTagContent tag = fmap (\content -> fmap (\c -> (tag, c)) content) $ tagIgnoreAttrs tag content

getTagsContent :: [Name] -> Consumer Event IO (Maybe (Name, Text))
getTagsContent tags = choose $ (fmap getTagContent tags)

The compile fails with:

    Couldn't match type ‘ConduitM Event o0 IO (Maybe (Name, Text))’
                   with ‘forall o1. ConduitM Event o1 IO (Maybe (Name, Text))’
    Expected type: Name -> Consumer Event IO (Maybe (Name, Text))
      Actual type: Name -> ConduitM Event o0 IO (Maybe (Name, Text))
    In the first argument of ‘fmap’, namely ‘getTagContent’
    In the second argument of ‘($)’, namely ‘(fmap getTagContent tags)’

See also (someone else having this issue): http://stackoverflow.com/questions/33606038/xml-conduit-combining-tagparsers

Asking in #haskell-beginners on Freenode there was a suggestion that the forall in the expansion of Consumer was at the root of this, which seems to make sense, but I've been unable to determine why. Removing the type definition has no material effect on the error either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions