Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated 3 hours ago

total matches: more than 1000

aeson-1.4.6.0
30 matches
Data/Aeson/Types/FromJSON.hs
instance GFromJSON One Par1 where
    -- Direct occurrences of the last type parameter are decoded with the
    -- function passed in as an argument:
    gParseJSON _opts (From1Args pj _) = fmap Par1 . pj

instance (FromJSON1 f) => GFromJSON One (Rec1 f) where
    -- Recursive occurrences of the last type parameter are decoded using their
    -- FromJSON1 instance:
    gParseJSON _opts (From1Args pj pjl) = fmap Rec1 . liftParseJSON pj pjl

            
Data/Aeson/Types/FromJSON.hs
instance (FromJSON1 f) => GFromJSON One (Rec1 f) where
    -- Recursive occurrences of the last type parameter are decoded using their
    -- FromJSON1 instance:
    gParseJSON _opts (From1Args pj pjl) = fmap Rec1 . liftParseJSON pj pjl

instance (FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) where
    -- If an occurrence of the last type parameter is nested inside two
    -- composed types, it is decoded by using the outermost type's FromJSON1
    -- instance to generically decode the innermost type:

            
Data/Aeson/Types/FromJSON.hs
    -- instance to generically decode the innermost type:
    gParseJSON opts fargs =
        let gpj = gParseJSON opts fargs in
        fmap Comp1 . liftParseJSON gpj (listParser gpj)

--------------------------------------------------------------------------------

instance (GFromJSON' arity a, Datatype d) => GFromJSON arity (D1 d a) where
    -- Meta-information, which is not handled elsewhere, is just added to the

            
Data/Aeson/Types/FromJSON.hs
instance (GFromJSON' arity a, Datatype d) => GFromJSON arity (D1 d a) where
    -- Meta-information, which is not handled elsewhere, is just added to the
    -- parsed value:
    gParseJSON opts fargs = fmap M1 . gParseJSON' (tname :* opts :* fargs)
      where
        tname = moduleName proxy ++ "." ++ datatypeName proxy
        proxy = undefined :: M1 _i d _f _p

-- | 'GFromJSON', after unwrapping the 'D1' constructor, now carrying the data

            
Data/Aeson/Types/FromJSON.hs
        | tagSingleConstructors opts
            = (unTagged :: Tagged allNullary (Parser (C1 c a p)) -> Parser (C1 c a p))
            . parseSum p
        | otherwise = fmap M1 . consParseJSON (cname :* p)
      where
        cname = conName (undefined :: M1 _i c _f _p)

-- | Multiple constructors.
instance ( AllNullary          (a :+: b) allNullary

            
Data/Aeson/Types/FromJSON.hs
-- | List of all constructor tags.
constructorTags :: ConstructorNames a => (String -> t) -> Tagged2 a [t]
constructorTags modifier =
    fmap DList.toList (constructorNames' modifier)

-- | List of all constructor names of an ADT, after a given conversion
-- function. (Better inlining.)
class ConstructorNames a where
    constructorNames' :: (String -> t) -> Tagged2 a (DList.DList t)

            
Data/Aeson/Types/FromJSON.hs
instance ( FromTaggedObject arity a, FromTaggedObject arity b) =>
    FromTaggedObject arity (a :+: b) where
        parseFromTaggedObject p obj =
            (fmap L1 <$> parseFromTaggedObject p obj) <|>
            (fmap R1 <$> parseFromTaggedObject p obj)

instance ( IsRecord                f isRecord
         , FromTaggedObject' arity f isRecord
         , Constructor c
         ) => FromTaggedObject arity (C1 c f) where

            
Data/Aeson/Types/FromJSON.hs
         ) => FromTaggedObject arity (C1 c f) where
    parseFromTaggedObject (tag :* contentsFieldName :* p@(_ :* opts :* _))
        | tag == tag'
        = Just . fmap M1 .
            (unTagged :: Tagged isRecord (Parser (f a)) -> Parser (f a)) .
            parseFromTaggedObject' (contentsFieldName :* cname :* p)
        | otherwise = const Nothing
      where
        tag' = pack $ constructorTagModifier opts cname

            
Data/Aeson/Types/FromJSON.hs
         ( GFromJSON arity a, RecordFromJSON arity (S1 s a)
         ) => ConsFromJSON' arity (S1 s a) True where
    consParseJSON' p@(cname :* tname :* opts :* fargs)
        | unwrapUnaryRecords opts = Tagged . fmap M1 . gParseJSON opts fargs
        | otherwise = Tagged . withObject (showCons cname tname) (recordParseJSON p)

instance RecordFromJSON arity f => ConsFromJSON' arity f True where
    consParseJSON' p@(cname :* tname :* _) =
        Tagged . withObject (showCons cname tname) (recordParseJSON p)

            
Data/Aeson/Types/FromJSON.hs
instance OVERLAPPING_
         GFromJSON arity f => ConsFromJSON' arity (S1 s f) False where
    consParseJSON' (_ :* _ :* opts :* fargs) =
        Tagged . fmap M1 . gParseJSON opts fargs

instance (ProductFromJSON arity f, ProductSize f
         ) => ConsFromJSON' arity f False where
    consParseJSON' p = Tagged . productParseJSON0 p


            
Data/Aeson/Types/FromJSON.hs
         , FromPair arity b
         ) => FromPair arity (a :+: b) where
    parsePair p pair =
        (fmap L1 <$> parsePair p pair) <|>
        (fmap R1 <$> parsePair p pair)

instance ( Constructor c
         , ConsFromJSON arity a
         ) => FromPair arity (C1 c a) where
    parsePair (tag :* p@(_ :* opts :* _)) v

            
Data/Aeson/Types/FromJSON.hs
    , Constructor c
    ) => FromUntaggedValue arity (C1 c a)
  where
    parseUntaggedValue p = fmap M1 . consParseJSON (cname :* p)
      where
        cname = conName (undefined :: M1 _i c _f _p)

instance OVERLAPPING_
    ( Constructor c )

            
Data/Aeson/Types/FromJSON.hs


instance FromJSON2 Const where
    liftParseJSON2 p _ _ _ = fmap Const . p
    {-# INLINE liftParseJSON2 #-}

instance FromJSON a => FromJSON1 (Const a) where
    liftParseJSON _ _ = fmap Const . parseJSON
    {-# INLINE liftParseJSON #-}

instance FromJSON a => FromJSON (Const a b) where
    {-# INLINE parseJSON #-}
    parseJSON = fmap Const . parseJSON

            
Data/Aeson/Types/FromJSON.hs

instance FromJSON a => FromJSON (Const a b) where
    {-# INLINE parseJSON #-}
    parseJSON = fmap Const . parseJSON


instance FromJSON1 Maybe where
    liftParseJSON _ _ Null = pure Nothing
    liftParseJSON p _ a    = Just <$> p a

            
Data/Aeson/Types/FromJSON.hs
    fromJSONKey = FromJSONKeyTextParser $ parseBoundedIntegralText "Word64"

instance FromJSON CTime where
    parseJSON = fmap CTime . parseJSON
    {-# INLINE parseJSON #-}

instance FromJSON Text where
    parseJSON = withText "Text" pure
    {-# INLINE parseJSON #-}

            
Data/Aeson/Types/FromJSON.hs

instance FromJSON1 DList.DList where
    liftParseJSON p _ = withArray "DList" $
      fmap DList.fromList .
      Tr.sequence . zipWith (parseIndexedJSON p) [0..] . V.toList
    {-# INLINE liftParseJSON #-}

instance (FromJSON a) => FromJSON (DList.DList a) where
    parseJSON = parseJSON1

            
Data/Aeson/Types/FromJSON.hs
    liftParseJSON p _ a = Identity <$> p a
    {-# INLINE liftParseJSON #-}

    liftParseJSONList _ p a = fmap Identity <$> p a
    {-# INLINE liftParseJSONList #-}

instance (FromJSON a) => FromJSON (Identity a) where
    parseJSON = parseJSON1
    {-# INLINE parseJSON #-}

            
Data/Aeson/Types/FromJSON.hs
        gl = liftParseJSONList p pl
    {-# INLINE liftParseJSON #-}

    liftParseJSONList p pl a = map Compose <$> liftParseJSONList g gl a
      where
        g  = liftParseJSON p pl
        gl = liftParseJSONList p pl
    {-# INLINE liftParseJSONList #-}


            
Data/Aeson/Types/FromJSON.hs

instance FromJSON1 Seq.Seq where
    liftParseJSON p _ = withArray "Seq" $
      fmap Seq.fromList .
      Tr.sequence . zipWith (parseIndexedJSON p) [0..] . V.toList
    {-# INLINE liftParseJSON #-}

instance (FromJSON a) => FromJSON (Seq.Seq a) where
    parseJSON = parseJSON1

            
Data/Aeson/Types/FromJSON.hs


instance (Ord a, FromJSON a) => FromJSON (Set.Set a) where
    parseJSON = fmap Set.fromList . parseJSON
    {-# INLINE parseJSON #-}


instance FromJSON IntSet.IntSet where
    parseJSON = fmap IntSet.fromList . parseJSON

            
Data/Aeson/Types/FromJSON.hs


instance FromJSON IntSet.IntSet where
    parseJSON = fmap IntSet.fromList . parseJSON
    {-# INLINE parseJSON #-}


instance FromJSON1 IntMap.IntMap where
    liftParseJSON p pl = fmap IntMap.fromList . liftParseJSON p' pl'

            
Data/Aeson/Types/FromJSON.hs


instance FromJSON1 IntMap.IntMap where
    liftParseJSON p pl = fmap IntMap.fromList . liftParseJSON p' pl'
      where
        p'  = liftParseJSON2     parseJSON parseJSONList p pl
        pl' = liftParseJSONList2 parseJSON parseJSONList p pl
    {-# INLINE liftParseJSON #-}


            
Data/Aeson/Types/FromJSON.hs
    {-# INLINE liftParseJSON #-}

instance FromJSON a => FromJSON (IntMap.IntMap a) where
    parseJSON = fmap IntMap.fromList . parseJSON
    {-# INLINE parseJSON #-}


instance (FromJSONKey k, Ord k) => FromJSON1 (M.Map k) where
    liftParseJSON p _ = case fromJSONKey of

            
Data/Aeson/Types/FromJSON.hs
instance (FromJSONKey k, Ord k) => FromJSON1 (M.Map k) where
    liftParseJSON p _ = case fromJSONKey of
        FromJSONKeyCoerce _ -> withObject "Map" $
            fmap (H.foldrWithKey (M.insert . unsafeCoerce) M.empty) . H.traverseWithKey (\k v -> p v <?> Key k)
        FromJSONKeyText f -> withObject "Map" $
            fmap (H.foldrWithKey (M.insert . f) M.empty) . H.traverseWithKey (\k v -> p v <?> Key k)
        FromJSONKeyTextParser f -> withObject "Map" $
            H.foldrWithKey (\k v m -> M.insert <$> f k <?> Key k <*> p v <?> Key k <*> m) (pure M.empty)
        FromJSONKeyValue f -> withArray "Map" $ \arr ->
            fmap M.fromList . Tr.sequence .
                zipWith (parseIndexedJSONPair f p) [0..] . V.toList $ arr
    {-# INLINE liftParseJSON #-}

instance (FromJSONKey k, Ord k, FromJSON v) => FromJSON (M.Map k v) where
    parseJSON = parseJSON1

            
Data/Aeson/Types/FromJSON.hs

instance FromJSON1 Vector where
    liftParseJSON p _ = withArray "Vector" $
        V.mapM (uncurry $ parseIndexedJSON p) . V.indexed
    {-# INLINE liftParseJSON #-}

instance (FromJSON a) => FromJSON (Vector a) where
    parseJSON = parseJSON1
    {-# INLINE parseJSON #-}

            
Data/Aeson/Types/FromJSON.hs


vectorParseJSON :: (FromJSON a, VG.Vector w a) => String -> Value -> Parser (w a)
vectorParseJSON s = withArray s $ fmap V.convert . V.mapM (uncurry $ parseIndexedJSON parseJSON) . V.indexed
{-# INLINE vectorParseJSON #-}

instance (Storable a, FromJSON a) => FromJSON (VS.Vector a) where
    parseJSON = vectorParseJSON "Data.Vector.Storable.Vector"


            
Data/Aeson/Types/FromJSON.hs
-------------------------------------------------------------------------------

instance (Eq a, Hashable a, FromJSON a) => FromJSON (HashSet.HashSet a) where
    parseJSON = fmap HashSet.fromList . parseJSON
    {-# INLINE parseJSON #-}


instance (FromJSONKey k, Eq k, Hashable k) => FromJSON1 (H.HashMap k) where
    liftParseJSON p _ = case fromJSONKey of

            
Data/Aeson/Types/FromJSON.hs
        FromJSONKeyCoerce _ -> withObject "HashMap ~Text" $
            uc . H.traverseWithKey (\k v -> p v <?> Key k)
        FromJSONKeyText f -> withObject "HashMap" $
            fmap (mapKey f) . H.traverseWithKey (\k v -> p v <?> Key k)
        FromJSONKeyTextParser f -> withObject "HashMap" $
            H.foldrWithKey (\k v m -> H.insert <$> f k <?> Key k <*> p v <?> Key k <*> m) (pure H.empty)
        FromJSONKeyValue f -> withArray "Map" $ \arr ->
            fmap H.fromList . Tr.sequence .
                zipWith (parseIndexedJSONPair f p) [0..] . V.toList $ arr
      where
        uc :: Parser (H.HashMap Text v) -> Parser (H.HashMap k v)
        uc = unsafeCoerce


            
Data/Aeson/Types/FromJSON.hs
instance FromJSON a => FromJSON (PM.Array a) where
  -- note: we could do better than this if vector exposed the data
  -- constructor in Data.Vector.
  parseJSON = fmap Exts.fromList . parseJSON

instance FromJSON a => FromJSON (PM.SmallArray a) where
  parseJSON = fmap Exts.fromList . parseJSON

#if MIN_VERSION_primitive(0,6,4)
instance (PM.Prim a,FromJSON a) => FromJSON (PM.PrimArray a) where
  parseJSON = fmap Exts.fromList . parseJSON

#if !MIN_VERSION_primitive(0,7,0)
instance (PM.PrimUnlifted a,FromJSON a) => FromJSON (PM.UnliftedArray a) where
  parseJSON = fmap Exts.fromList . parseJSON
#endif
#endif
#endif

-------------------------------------------------------------------------------

            
Data/Aeson/Types/FromJSON.hs
-------------------------------------------------------------------------------

instance FromJSON1 Monoid.Dual where
    liftParseJSON p _ = fmap Monoid.Dual . p
    {-# INLINE liftParseJSON #-}

instance FromJSON a => FromJSON (Monoid.Dual a) where
    parseJSON = parseJSON1
    {-# INLINE parseJSON #-}