-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Represent hierachichal structures, called objects in JSON. (deprecated) -- -- These objects show up in different places, eg JSON, Yaml. By providing -- a representation in a separate repository, other libraries can share a -- single representation of these structures. @package data-object @version 0.3.1.9 -- | The core of this package is the Object data type, which is used -- for handling scalars, sequences and mappings in a nested manner. This -- is the same structure used in JSON or Yaml data. -- -- The Object data type is polymorphic in its keys and values. -- Submodules within this package provide more concrete datatypes, such -- as a String Object and a specialized scalar type. -- -- Besides the Object data type, there are utility functions and -- type classes for converting objects around. Care has been taken to -- avoid any overloaded instances for these type classes. module Data.Object -- | Can represent nested values as scalars, sequences and mappings. A -- sequence is synonymous with a list, while a mapping is synonymous with -- a list of pairs. -- -- Note that instances of standard library type classes for this data -- type leave the key untouched while altering the value. For example, -- the Functor instance defines fmap to be synonymous with -- mapValues. data Object key val Mapping :: [(key, Object key val)] -> Object key val Sequence :: [Object key val] -> Object key val Scalar :: val -> Object key val type StringObject = Object String String -- | Objects with keys and values of strict Text. type TextObject = Object Text Text data Scalar Numeric :: Rational -> Scalar Text :: Text -> Scalar Binary :: ByteString -> Scalar Bool :: Bool -> Scalar Timestamp :: UTCTime -> Scalar Null :: Scalar type ScalarObject = Object String Scalar -- | Apply some conversion to the keys of an Object, leaving the -- values unchanged. mapKeys :: (keyIn -> keyOut) -> Object keyIn val -> Object keyOut val -- | Apply some conversion to the values of an Object, leaving the -- keys unchanged. This is equivalent to fmap. mapValues :: (valIn -> valOut) -> Object key valIn -> Object key valOut -- | Apply a conversion to both the keys and values of an Object. mapKeysValues :: (keyIn -> keyOut) -> (valIn -> valOut) -> Object keyIn valIn -> Object keyOut valOut -- | Apply an Applicative conversion to both the keys and values of -- an Object. mapKeysValuesA :: Applicative f => (keyIn -> f keyOut) -> (valIn -> f valOut) -> Object keyIn valIn -> f (Object keyOut valOut) -- | The same as mapKeysValuesA, but using a Monad since some -- people are more comfortable with Monads and not all -- Monads are Applicative. mapKeysValuesM :: Monad m => (keyIn -> m keyOut) -> (valIn -> m valOut) -> Object keyIn valIn -> m (Object keyOut valOut) -- | An error value returned when an unexpected node is encountered, eg you -- were expecting a Scalar and found a Mapping. data ObjectExtractError ExpectedScalar :: ObjectExtractError ExpectedSequence :: ObjectExtractError ExpectedMapping :: ObjectExtractError MissingKey :: String -> ObjectExtractError -- | Extract a scalar from the input, failing if the input is a sequence or -- mapping. fromScalar :: Failure ObjectExtractError m => Object k v -> m v -- | Extract a sequence from the input, failing if the input is a scalar or -- mapping. fromSequence :: Failure ObjectExtractError m => Object k v -> m [Object k v] -- | Extract a mapping from the input, failing if the input is a scalar or -- sequence. fromMapping :: Failure ObjectExtractError m => Object k v -> m [(k, Object k v)] lookupObject :: (Show k, Eq k, Failure ObjectExtractError m) => k -> [(k, Object k v)] -> m (Object k v) lookupScalar :: (Show k, Eq k, Failure ObjectExtractError m) => k -> [(k, Object k v)] -> m v lookupSequence :: (Show k, Eq k, Failure ObjectExtractError m) => k -> [(k, Object k v)] -> m [Object k v] lookupMapping :: (Show k, Eq k, Failure ObjectExtractError m) => k -> [(k, Object k v)] -> m [(k, Object k v)] instance Typeable2 Object instance Typeable ObjectExtractError instance (Show key, Show val) => Show (Object key val) instance (Eq key, Eq val) => Eq (Object key val) instance (Data key, Data val) => Data (Object key val) instance Show ObjectExtractError instance Exception ObjectExtractError instance Applicative (Object key) instance Monad (Object key) instance Traversable (Object key) instance Foldable (Object key) instance Functor (Object key)