module Argo.Decode where import qualified Argo.Class.FromValue as FromValue import qualified Argo.Decoder as Decoder import qualified Argo.Result as Result import qualified Argo.Type.Value as Value import qualified Data.ByteString as ByteString decode :: FromValue.FromValue a => ByteString.ByteString -> Result.Result a decode :: ByteString -> Result a decode = (Value -> Result a) -> ByteString -> Result a forall a. (Value -> Result a) -> ByteString -> Result a decodeWith Value -> Result a forall a. FromValue a => Value -> Result a FromValue.fromValue decodeWith :: (Value.Value -> Result.Result a) -> ByteString.ByteString -> Result.Result a decodeWith :: (Value -> Result a) -> ByteString -> Result a decodeWith Value -> Result a f ByteString x = case Decoder Value -> ByteString -> Result (ByteString, Value) forall a. Decoder a -> ByteString -> Result (ByteString, a) Decoder.run (Decoder () Decoder.spaces Decoder () -> Decoder Value -> Decoder Value forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b *> Decoder Value Value.decode Decoder Value -> Decoder () -> Decoder Value forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a <* Decoder () Decoder.eof) ByteString x of Result.Failure String e -> String -> Result a forall a. String -> Result a Result.Failure String e Result.Success (ByteString _, Value y) -> Value -> Result a f Value y