module Waargonaut.Attoparsec
(
decodeAttoparsecText
, decodeAttoparsecByteString
, pureDecodeAttoparsecText
, pureDecodeAttoparsecByteString
) where
import Data.Functor.Identity (Identity)
import Data.ByteString (ByteString)
import Data.Text (Text)
import qualified Data.Attoparsec.ByteString as AB
import qualified Data.Attoparsec.Text as AT
import Waargonaut.Decode (CursorHistory, Decoder)
import Waargonaut.Decode.Error (DecodeError)
import qualified Waargonaut.Decode as D
decodeAttoparsecText
:: Monad f
=> Decoder f a
-> Text
-> f (Either (DecodeError, CursorHistory) a)
decodeAttoparsecText decoder =
D.decodeFromText AT.parseOnly decoder
decodeAttoparsecByteString
:: Monad f
=> Decoder f a
-> ByteString
-> f (Either (DecodeError, CursorHistory) a)
decodeAttoparsecByteString decoder =
D.decodeFromByteString AB.parseOnly decoder
pureDecodeAttoparsecText
:: Decoder Identity a
-> Text
-> Either (DecodeError, CursorHistory) a
pureDecodeAttoparsecText decoder =
D.pureDecodeFromText AT.parseOnly decoder
pureDecodeAttoparsecByteString
:: Decoder Identity a
-> ByteString
-> Either (DecodeError, CursorHistory) a
pureDecodeAttoparsecByteString decoder =
D.pureDecodeFromByteString AB.parseOnly decoder