aeson-extra-0.4.0.0: Extra goodies for aeson

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

Data.Aeson.Extra.SingObject

Description

Synopsis

- newtype SingObject s a = SingObject a
- mkSingObject :: Proxy s -> a -> SingObject s a
- getSingObject :: Proxy s -> SingObject s a -> a

# Documentation

newtype SingObject s 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

Functor (SingObject s) Source # |
Methods fmap :: (a -> b) -> SingObject s a -> SingObject s b # (<$) :: a -> SingObject s b -> SingObject s a #
Foldable (SingObject s) Source # |

Methods

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

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

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

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

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

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

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

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

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

null :: SingObject s a -> Bool #

length :: SingObject s a -> Int #

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

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

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

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

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

Traversable (SingObject s) Source # |
Methods traverse :: Applicative f => (a -> f b) -> SingObject s a -> f (SingObject s b) # sequenceA :: Applicative f => SingObject s (f a) -> f (SingObject s a) # mapM :: Monad m => (a -> m b) -> SingObject s a -> m (SingObject s b) # sequence :: Monad m => SingObject s (m a) -> m (SingObject s a) #
KnownSymbol s => ToJSON1 (SingObject s) Source # |
Methods liftToJSON :: (a -> Value) -> ([a] -> Value) -> SingObject s a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [SingObject s a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> SingObject s a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [SingObject s a] -> Encoding #
KnownSymbol s => FromJSON1 (SingObject s) Source # |
Methods liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (SingObject s a) # liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [SingObject s a] #
Eq a => Eq (SingObject s a) Source # |
Methods (==) :: SingObject s a -> SingObject s a -> Bool # (/=) :: SingObject s a -> SingObject s a -> Bool #
Ord a => Ord (SingObject s a) Source # |
Methods compare :: SingObject s a -> SingObject s a -> Ordering # (<) :: SingObject s a -> SingObject s a -> Bool # (<=) :: SingObject s a -> SingObject s a -> Bool # (>) :: SingObject s a -> SingObject s a -> Bool # (>=) :: SingObject s a -> SingObject s a -> Bool # max :: SingObject s a -> SingObject s a -> SingObject s a # min :: SingObject s a -> SingObject s a -> SingObject s a #
Read a => Read (SingObject s a) Source # |
Methods readsPrec :: Int -> ReadS (SingObject s a) # readList :: ReadS [SingObject s a] # readPrec :: ReadPrec (SingObject s a) # readListPrec :: ReadPrec [SingObject s a] #
Show a => Show (SingObject s a) Source # |
Methods showsPrec :: Int -> SingObject s a -> ShowS # show :: SingObject s a -> String # showList :: [SingObject s a] -> ShowS #
(KnownSymbol s, ToJSON a) => ToJSON (SingObject s a) Source # |
Methods toJSON :: SingObject s a -> Value # toEncoding :: SingObject s a -> Encoding # toJSONList :: [SingObject s a] -> Value # toEncodingList :: [SingObject s a] -> Encoding #
(KnownSymbol s, FromJSON a) => FromJSON (SingObject s a) Source # |
Methods parseJSON :: Value -> Parser (SingObject s a) # parseJSONList :: Value -> Parser [SingObject s a] #

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

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