-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Law-abiding lenses for aeson
--   
--   Law-abiding lenses for aeson
@package lens-aeson
@version 0.1.2


module Control.Lens.Aeson
class AsNumber t where _Number = _Primitive . _Number _Double = _Number . prism D (\ v -> case v of { D d -> Right d _ -> Left v }) _Integer = _Number . prism I (\ v -> case v of { I i -> Right i _ -> Left v })
_Number :: AsNumber t => Prism' t Number
_Double :: AsNumber t => Prism' t Double
_Integer :: AsNumber t => Prism' t Integer

-- | Access Integer <a>Value</a>s as Integrals.
--   
--   defined as `integer . <a>integral'</a>
--   
--   <pre>
--   &gt;&gt;&gt; "[10]" ^? nth 0 . integralValue
--   Just 10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "[10.5]" ^? nth 0 . integralValue
--   Nothing
--   </pre>
integralValue :: (AsNumber t, Integral a) => Prism' t a

-- | Prism into non-<a>Null</a> values
--   
--   <pre>
--   &gt;&gt;&gt; "{\"a\": \"xyz\", \"b\": null}" ^? key "a" . nonNull
--   Just (String "xyz")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "{\"a\": {}, \"b\": null}" ^? key "a" . nonNull
--   Just (Object fromList [])
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "{\"a\": \"xyz\", \"b\": null}" ^? key "b" . nonNull
--   Nothing
--   </pre>
nonNull :: Prism' Value Value

-- | Primitives of <a>Value</a>
data Primitive
StringPrim :: !Text -> Primitive
NumberPrim :: !Number -> Primitive
BoolPrim :: !Bool -> Primitive
NullPrim :: Primitive
class AsNumber t => AsPrimitive t where _Primitive = _Value . _Primitive _String = _Primitive . prism StringPrim (\ v -> case v of { StringPrim s -> Right s _ -> Left v }) _Bool = _Primitive . prism BoolPrim (\ v -> case v of { BoolPrim b -> Right b _ -> Left v }) _Null = _Primitive . prism (const NullPrim) (\ v -> case v of { NullPrim -> Right () _ -> Left v })
_Primitive :: AsPrimitive t => Prism' t Primitive
_String :: AsPrimitive t => Prism' t Text
_Bool :: AsPrimitive t => Prism' t Bool
_Null :: AsPrimitive t => Prism' t ()
class AsPrimitive t => AsValue t where _Object = _Value . prism Object (\ v -> case v of { Object o -> Right o _ -> Left v }) _Array = _Value . prism Array (\ v -> case v of { Array a -> Right a _ -> Left v })
_Value :: AsValue t => Prism' t Value
_Object :: AsValue t => Prism' t (HashMap Text Value)
_Array :: AsValue t => Prism' t (Vector Value)

-- | Like <a>ix</a>, but for <a>Object</a> with Text indices. This often
--   has better inference than <a>ix</a> when used with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; "{\"a\": 100, \"b\": 200}" ^? key "a"
--   Just (Number 100)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "[1,2,3]" ^? key "a"
--   Nothing
--   </pre>
key :: AsValue t => Text -> Traversal' t Value
members :: AsValue t => IndexedTraversal' Text t Value

-- | Like <a>ix</a>, but for Arrays with Int indexes
--   
--   <pre>
--   &gt;&gt;&gt; "[1,2,3]" ^? nth 1
--   Just (Number 2)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "\"a\": 100, \"b\": 200}" ^? nth 1
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "[1,2,3]" &amp; nth 1 .~ (Number 20)
--   "[1,20,3]"
--   </pre>
nth :: AsValue t => Int -> Traversal' t Value
values :: AsValue t => IndexedTraversal' Int t Value
class AsJSON t
_JSON :: (AsJSON t, FromJSON a, ToJSON a) => Prism' t a
instance Typeable Primitive
instance Eq Primitive
instance Ord Primitive
instance Show Primitive
instance Data Primitive
instance Plated Value
instance (Applicative f, Gettable f) => Contains f Value
instance Applicative f => Ixed f Value
instance AsJSON String
instance AsJSON ByteString
instance AsValue String
instance AsValue ByteString
instance AsValue Value
instance AsPrimitive Primitive
instance AsPrimitive String
instance AsPrimitive ByteString
instance AsPrimitive Value
instance AsNumber Primitive
instance AsNumber String
instance AsNumber ByteString
instance AsNumber Number
instance AsNumber Value
