aeson-extra-0.5.1.2: Extra goodies for aeson

Copyright | (C) 2015-2016 Oleg Grenrus
License | BSD3
Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Aeson.Extra.SingObject

Description

Synopsis

- newtype SingObject (s :: Symbol) a = SingObject a
- mkSingObject :: Proxy s -> a -> SingObject s a
- getSingObject :: Proxy s -> SingObject s a -> a

# Documentation

newtype SingObject (s :: Symbol) a Source #

Singleton value object

    λ > decode "{\"value\": 42 }" :: Maybe (SingObject "value" Int)
    Just (SingObject 42)

    λ > encode (SingObject 42 :: SingObject "value" Int)
    "{\"value\":42}"

Available with: base >=4.7

Constructors

SingObject a |

#### Instances

Instances details

KnownSymbol s => FromJSON1 (SingObject s) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (SingObject s a) Source # liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [SingObject s a] Source #
KnownSymbol s => ToJSON1 (SingObject s) Source # |

Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> SingObject s a -> Value Source #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [SingObject s a] -> Value Source #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> SingObject s a -> Encoding Source #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [SingObject s a] -> Encoding Source #

Foldable (SingObject s) Source # |

Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

fold :: Monoid m => SingObject s m -> m Source #

foldMap :: Monoid m => (a -> m) -> SingObject s a -> m Source #

foldMap' :: Monoid m => (a -> m) -> SingObject s a -> m Source #

foldr :: (a -> b -> b) -> b -> SingObject s a -> b Source #

foldr' :: (a -> b -> b) -> b -> SingObject s a -> b Source #

foldl :: (b -> a -> b) -> b -> SingObject s a -> b Source #

foldl' :: (b -> a -> b) -> b -> SingObject s a -> b Source #

foldr1 :: (a -> a -> a) -> SingObject s a -> a Source #

foldl1 :: (a -> a -> a) -> SingObject s a -> a Source #

toList :: SingObject s a -> [a] Source #

null :: SingObject s a -> Bool Source #

length :: SingObject s a -> Int Source #

elem :: Eq a => a -> SingObject s a -> Bool Source #

maximum :: Ord a => SingObject s a -> a Source #

minimum :: Ord a => SingObject s a -> a Source #

sum :: Num a => SingObject s a -> a Source #

product :: Num a => SingObject s a -> a Source #

Traversable (SingObject s) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods traverse :: Applicative f => (a -> f b) -> SingObject s a -> f (SingObject s b) Source # sequenceA :: Applicative f => SingObject s (f a) -> f (SingObject s a) Source # mapM :: Monad m => (a -> m b) -> SingObject s a -> m (SingObject s b) Source # sequence :: Monad m => SingObject s (m a) -> m (SingObject s a) Source #
Functor (SingObject s) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods fmap :: (a -> b) -> SingObject s a -> SingObject s b Source # (<$) :: a -> SingObject s b -> SingObject s a Source #
(KnownSymbol s, FromJSON a) => FromJSON (SingObject s a) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods parseJSON :: Value -> Parser (SingObject s a) Source # parseJSONList :: Value -> Parser [SingObject s a] Source #
(KnownSymbol s, ToJSON a) => ToJSON (SingObject s a) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods toJSON :: SingObject s a -> Value Source # toEncoding :: SingObject s a -> Encoding Source # toJSONList :: [SingObject s a] -> Value Source # toEncodingList :: [SingObject s a] -> Encoding Source #
Read a => Read (SingObject s a) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods readsPrec :: Int -> ReadS (SingObject s a) Source # readList :: ReadS [SingObject s a] Source # readPrec :: ReadPrec (SingObject s a) Source # readListPrec :: ReadPrec [SingObject s a] Source #
Show a => Show (SingObject s a) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods showsPrec :: Int -> SingObject s a -> ShowS Source # show :: SingObject s a -> String Source # showList :: [SingObject s a] -> ShowS Source #
NFData a => NFData (SingObject s a) Source # | Since: 0.4.1.0
Instance details Defined in Data.Aeson.Extra.SingObject Methods rnf :: SingObject s a -> () Source #
Eq a => Eq (SingObject s a) Source # |
Instance details Defined in Data.Aeson.Extra.SingObject Methods (==) :: SingObject s a -> SingObject s a -> Bool Source # (/=) :: SingObject s a -> SingObject s a -> Bool Source #
Ord a => Ord (SingObject s a) Source # |

Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

compare :: SingObject s a -> SingObject s a -> Ordering Source #

(<) :: SingObject s a -> SingObject s a -> Bool Source #

(<=) :: SingObject s a -> SingObject s a -> Bool Source #

(>) :: SingObject s a -> SingObject s a -> Bool Source #

(>=) :: SingObject s a -> SingObject s a -> Bool Source #

max :: SingObject s a -> SingObject s a -> SingObject s a Source #

min :: SingObject s a -> SingObject s a -> SingObject s a Source #

mkSingObject :: Proxy s -> a -> SingObject s a Source #

getSingObject :: Proxy s -> SingObject s a -> a Source #