ocramz / xeno

Fast Haskell XML parser
Other
120 stars 33 forks source link

First example in README doesn't work #46

Closed 1chb closed 3 years ago

1chb commented 3 years ago

DOM Example

Easy as running the parse function:

> stack ghci
λ> parse "<p key='val' x=\"foo\" k=\"\"><a><hr/>hi</a><b>sup</b>hi</p>"

<interactive>:1:1: error:
    Variable not in scope: parse :: [Char] -> t
λ>
λ>
λ> import Xeno.DOM
λ> parse "<p key='val' x=\"foo\" k=\"\"><a><hr/>hi</a><b>sup</b>hi</p>"

<interactive>:3:7: error:
    • Couldn't match expected type ‘Data.ByteString.Internal.ByteString’
                  with actual type ‘[Char]’
    • In the first argument of ‘parse’, namely
        ‘"<p key='val' x=\"foo\" k=\"\"><a><hr/>hi</a><b>sup</b>hi</p>"’
      In the expression:
        parse
          "<p key='val' x=\"foo\" k=\"\"><a><hr/>hi</a><b>sup</b>hi</p>"
      In an equation for ‘it’:
          it
            = parse
                "<p key='val' x=\"foo\" k=\"\"><a><hr/>hi</a><b>sup</b>hi</p>"
pkamenarsky commented 3 years ago

Type :set -XOverloadedStrings in the REPL first in order to automatically convert the supplied string to a ByteString.

1chb commented 3 years ago

Yeah, I figured it out myself, but I just hate documentation that first claims it is easy but despite that fails to explain it correctly. It is sadly too common. Maybe it is just me, but I think it scares away others too.

pkamenarsky commented 3 years ago

PRs are always welcome!