-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Cherry picking in JSON objects -- -- Simple single record picking out of nested JSON objects @package jsop @version 0.2.0.1 module Trie data Trie k m Trie :: m -> MonoidalMap k (Trie k m) -> Trie k m [load] :: Trie k m -> m [down] :: Trie k m -> MonoidalMap k (Trie k m) instance (GHC.Show.Show m, GHC.Show.Show k) => GHC.Show.Show (Trie.Trie k m) instance (GHC.Classes.Eq m, GHC.Classes.Eq k) => GHC.Classes.Eq (Trie.Trie k m) instance (GHC.Classes.Ord k, GHC.Base.Semigroup m) => GHC.Base.Semigroup (Trie.Trie k m) instance (GHC.Classes.Ord k, GHC.Base.Monoid m) => GHC.Base.Monoid (Trie.Trie k m) -- | Read and write a record into JSON tree module Data.JSOP -- | prism for a Value type ValuePrism a = APrism' Value a -- | A record field operation specification data JSOP p a JSOP :: p -> Maybe a -> ValuePrism a -> JSOP p a -- | custom path encoding [jsop_path] :: JSOP p a -> p -- | a default value , Nothing means value is required [jsop_default] :: JSOP p a -> Maybe a -- | the prism to read and write the record field [jsop_prism] :: JSOP p a -> ValuePrism a -- | shortcut for a parser that handle missing values required :: p -> ValuePrism a -> JSOP p a -- | shortcut for parsers that have a default if value is missing optional :: p -> a -> ValuePrism a -> JSOP p a -- | parsing problems data JSOPIssue -- | the index of the field in the record that failed, with the Value if -- reacheable and the requested type JSOPIssue :: (Int, Maybe Value, TypeRep) -> JSOPIssue -- | paths are not enough or too many JSOPWrongNumberOfPaths :: JSOPIssue -- | get a record out of the json tree jread :: (All Typeable xs, IsProductType a xs) => (path -> [Text]) -> NP (JSOP path) xs -> Value -> Either JSOPIssue a paths :: All Top xs => NP (JSOP p) xs -> [p] parseSField :: forall a p. Typeable a => JSOP p a -> K (Int, Maybe Value) a -> Either JSOPIssue a type QPaths = Trie Text (First Int, [Int]) mkPath :: Int -> [Text] -> QPaths mkPaths :: [[Text]] -> QPaths treequery :: QPaths -> Value -> ([(Int, Value)], [Int]) -- | you should close over paths argument to get an efficient Value -> -- [Maybe Value] getValues :: (p -> [Text]) -> [p] -> Value -> [Maybe Value] type TPaths = Trie Text (First Int, Any) mkTPath :: Int -> (Bool, [Text]) -> TPaths mkTPaths :: [(Bool, [Text])] -> TPaths treechange :: Bool -> TPaths -> Value -> Map Int Value -> Value -- | you should close over paths argument to get an efficient Value -> -- Value setValues :: (p -> (Bool, [Text])) -> [(p, Value)] -> Value -> Value -- | not very well defined write at path operation jwrite :: (All Typeable xs, IsProductType a xs, All Top xs, Show path, Ord path) => (path -> [Text]) -> NP (JSOP path) xs -> Value -> a -> Value instance GHC.Show.Show Data.JSOP.JSOPIssue instance GHC.Classes.Eq Data.JSOP.JSOPIssue module Data.JSOP.Example data ABC ABC :: Text -> Int -> Int -> ABC cherryPickABC :: NP (JSOP Text) '[Text, Int, Int] jsonWithABC :: Value abc :: ABC jsonABC :: Value instance Generics.SOP.Universe.Generic Data.JSOP.Example.ABC instance Generics.SOP.Universe.HasDatatypeInfo Data.JSOP.Example.ABC instance GHC.Classes.Eq Data.JSOP.Example.ABC instance GHC.Show.Show Data.JSOP.Example.ABC