aeson-decode-0.1.0.1: Easy functions for converting from Aeson.Value
Safe HaskellSafe-Inferred
LanguageGHC2021

AesonDecode

Synopsis

Decoder

newtype Decoder a Source #

Some way of interpreting a JSON value, with the possibility of failure for some values

Constructors

Decoder 

Fields

Instances

Instances details
Alternative Decoder Source #

empty = failDecoder, <|> = orElse

Instance details

Defined in AesonDecode

Methods

empty :: Decoder a #

(<|>) :: Decoder a -> Decoder a -> Decoder a #

some :: Decoder a -> Decoder [a] #

many :: Decoder a -> Decoder [a] #

Applicative Decoder Source #

pure = constSuccessDecoder, <*> = apDecoder

Instance details

Defined in AesonDecode

Methods

pure :: a -> Decoder a #

(<*>) :: Decoder (a -> b) -> Decoder a -> Decoder b #

liftA2 :: (a -> b -> c) -> Decoder a -> Decoder b -> Decoder c #

(*>) :: Decoder a -> Decoder b -> Decoder b #

(<*) :: Decoder a -> Decoder b -> Decoder a #

Functor Decoder Source #
fmap = mapDecoder
Instance details

Defined in AesonDecode

Methods

fmap :: (a -> b) -> Decoder a -> Decoder b #

(<$) :: a -> Decoder b -> Decoder a #

Monad Decoder Source #
>=> = composeDecoderFunctions
Instance details

Defined in AesonDecode

Methods

(>>=) :: Decoder a -> (a -> Decoder b) -> Decoder b #

(>>) :: Decoder a -> Decoder b -> Decoder b #

return :: a -> Decoder a #

FromJSON a => Default (Decoder a) Source #
def = defaultDecoder
Instance details

Defined in AesonDecode

Methods

def :: Decoder a #

constDecoder Source #

Arguments

:: Maybe a

The result that the decoder always produces

-> Decoder a

A decoder that always produces the given result

Always produces the same result

constSuccessDecoder :: a -> Decoder a Source #

Always succeeds and produces the same result

failDecoder :: Decoder a Source #

Always fails

This is the identity of the Alternative for Decoder.

mapDecoder :: (a -> b) -> Decoder a -> Decoder b Source #

apDecoder :: Decoder (a -> b) -> Decoder a -> Decoder b Source #

composeDecoderFunctions :: (b -> Decoder c) -> (a -> Decoder b) -> a -> Decoder c Source #

Compose two decoder-producing functions

is :: (Eq a, FromJSON a) => a -> Decoder () Source #

is x produces Just () if the JSON value decodes to x, or Nothing otherwise

(^?) :: Value -> Decoder a -> Maybe a infixl 8 Source #

Path

newtype Path Source #

Constructors

Path 

Fields

Instances

Instances details
IsString Path Source #
fromString = stringPath
Instance details

Defined in AesonDecode

Methods

fromString :: String -> Path #

Monoid Path Source #
mempty = here
Instance details

Defined in AesonDecode

Methods

mempty :: Path #

mappend :: Path -> Path -> Path #

mconcat :: [Path] -> Path #

Semigroup Path Source #

<> = pathConcat@

Instance details

Defined in AesonDecode

Methods

(<>) :: Path -> Path -> Path #

sconcat :: NonEmpty Path -> Path #

stimes :: Integral b => b -> Path -> Path #

here :: Path Source #

The empty path

This is the identity of the Monoid for Path.

at :: Path -> Decoder a -> Decoder a Source #

only :: Path Source #

Selects the only element from an array of length 1

Text

text :: Decoder Text Source #

Decodes a JSON string as Text

textIs :: Text -> Decoder () Source #

Just () if the JSON value is the given string, Nothing otherwise

Integer

integer :: Decoder Integer Source #

Decodes a JSON number as an Integer

integerIs :: Integer -> Decoder () Source #

Just () if the JSON value is the given integer, Nothing otherwise

Boolean

bool :: Decoder Bool Source #

Decodes a JSON boolean as a Bool

boolIs :: Bool -> Decoder () Source #

Just () if the JSON value is the given boolean, Nothing otherwise

true :: Decoder () Source #

Just () if the JSON value is true, Nothing otherwise

false :: Decoder () Source #

Just () if the JSON value is false, Nothing otherwise

List

Vector

Ord map

Hash map

Null

null :: Decoder () Source #

Just () if the JSON value is the value null, Nothing otherwise

nullable :: Decoder a -> Decoder (Maybe a) Source #

Succeeds with Just x if the decoder d succeeds with value x, succeeds with Nothing if the JSON value is null, fails otherwise