-- 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 1.0.0.4


module Data.Aeson.Lens
class AsNumber t where _Number = _Primitive . _Number _Double = _Number . iso toRealFloat realToFrac _Integer = _Number . iso floor fromIntegral
_Number :: AsNumber t => Prism' t Scientific
_Double :: AsNumber t => Prism' t Double
_Integer :: AsNumber t => Prism' t Integer

-- | Access Integer <a>Value</a>s as Integrals.
--   
--   <pre>
--   &gt;&gt;&gt; "[10]" ^? nth 0 . _Integral
--   Just 10
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "[10.5]" ^? nth 0 . _Integral
--   Just 10
--   </pre>
_Integral :: (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 :: !Scientific -> 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.0)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "[1,2,3]" ^? key "a"
--   Nothing
--   </pre>
key :: AsValue t => Text -> Traversal' t Value

-- | An indexed Traversal into Object properties
--   
--   <pre>
--   &gt;&gt;&gt; "{\"a\": 4, \"b\": 7}" ^@.. members
--   [("a",Number 4.0),("b",Number 7.0)]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "{\"a\": 4, \"b\": 7}" &amp; members . _Number *~ 10
--   "{\"a\":40,\"b\":70}"
--   </pre>
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.0)
--   </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

-- | An indexed Traversal into Array elements
--   
--   <pre>
--   &gt;&gt;&gt; "[1,2,3]" ^.. values
--   [Number 1.0,Number 2.0,Number 3.0]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; "[1,2,3]" &amp; values . _Number *~ 10
--   "[10,20,30]"
--   </pre>
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 Ixed Value
instance AsJSON Value
instance AsJSON Text
instance AsJSON Text
instance AsJSON String
instance AsJSON ByteString
instance AsJSON ByteString
instance AsValue Text
instance AsValue Text
instance AsValue String
instance AsValue ByteString
instance AsValue ByteString
instance AsValue Value
instance AsPrimitive Primitive
instance AsPrimitive String
instance AsPrimitive Text
instance AsPrimitive Text
instance AsPrimitive ByteString
instance AsPrimitive ByteString
instance AsPrimitive Value
instance AsNumber Primitive
instance AsNumber String
instance AsNumber Text
instance AsNumber Text
instance AsNumber ByteString
instance AsNumber ByteString
instance AsNumber Scientific
instance AsNumber Value
