-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | BSON documents are JSON-like objects with a standard binary -- encoding. -- -- A BSON Document is an untyped (dynamically type-checked) record. I.e. -- it is a list of name-value pairs, where a Value is a single sum type -- with constructors for basic types (Bool, Int, Float, String, and -- Time), compound types (List, and (embedded) Document), and special -- types (Binary, Javascript, ObjectId, RegEx, and a few others). A BSON -- Document is serialized to a standard binary encoding defined at -- http://bsonspec.org. This implements version 1 of that spec. @package bson @version 0.3.2 -- | A BSON document is a JSON-like object with a standard binary encoding -- defined at bsonspec.org. This implements version 1.0 of that spec. -- -- Use the GHC language extension OverloadedStrings to -- automatically convert String literals to Text module Data.Bson -- | A BSON document is a list of Fields type Document = [Field] -- | Recursively lookup a nested field in a Document. (!?) :: Val a => Document -> Label -> Maybe a -- | Value of field in document, or fail (Nothing) if field not found look :: (Monad m) => Label -> Document -> m Value -- | Lookup value of field in document and cast to expected type. Fail -- (Nothing) if field not found or value not of expected type. lookup :: (Val v, Monad m) => Label -> Document -> m v -- | Value of field in document. Error if missing. valueAt :: Label -> Document -> Value -- | Typed value of field in document. Error if missing or wrong type. at :: (Val v) => Label -> Document -> v -- | Only include fields of document in label list include :: [Label] -> Document -> Document -- | Exclude fields from document in label list exclude :: [Label] -> Document -> Document -- | Merge documents with preference given to first one when both have the -- same label. I.e. for every (k := v) in first argument, if k exists in -- second argument then replace its value with v, otherwise add (k := v) -- to second argument. merge :: Document -> Document -> Document -- | A BSON field is a named value, where the name (label) is a string and -- the value is a BSON Value data Field (:=) :: !Label -> Value -> Field [label] :: Field -> !Label [value] :: Field -> Value -- | Field with given label and typed value (=:) :: (Val v) => Label -> v -> Field -- | If Just value then return one field document, otherwise return empty -- document (=?) :: (Val a) => Label -> Maybe a -> Document -- | The name of a BSON field type Label = Text -- | A BSON value is one of the following types of values data Value Float :: Double -> Value String :: Text -> Value Doc :: Document -> Value Array :: [Value] -> Value Bin :: Binary -> Value Fun :: Function -> Value Uuid :: UUID -> Value Md5 :: MD5 -> Value UserDef :: UserDefined -> Value ObjId :: ObjectId -> Value Bool :: Bool -> Value UTC :: UTCTime -> Value Null :: Value RegEx :: Regex -> Value JavaScr :: Javascript -> Value Sym :: Symbol -> Value Int32 :: Int32 -> Value Int64 :: Int64 -> Value Stamp :: MongoStamp -> Value MinMax :: MinMaxKey -> Value -- | Haskell types of this class correspond to BSON value types class (Typeable a, Show a, Eq a) => Val a where valList = Array . map val valMaybe = maybe Null val cast'List (Array x) = mapM cast x cast'List _ = Nothing cast'Maybe Null = Just Nothing cast'Maybe v = fmap Just (cast' v) val :: Val a => a -> Value valList :: Val a => [a] -> Value valMaybe :: Val a => Maybe a -> Value cast' :: Val a => Value -> Maybe a cast'List :: Val a => Value -> Maybe [a] cast'Maybe :: Val a => Value -> Maybe (Maybe a) -- | Apply generic function to typed value fval :: (forall a. (Val a) => a -> b) -> Value -> b -- | Convert Value to expected type, or fail (Nothing) if not of that type cast :: (Val a, Monad m) => Value -> m a -- | Convert Value to expected type. Error if not that type. typed :: (Val a) => Value -> a -- | Type of typed value typeOfVal :: Value -> TypeRep newtype Binary Binary :: ByteString -> Binary newtype Function Function :: ByteString -> Function newtype UUID UUID :: ByteString -> UUID newtype MD5 MD5 :: ByteString -> MD5 newtype UserDefined UserDefined :: ByteString -> UserDefined -- | The first string is the regex pattern, the second is the regex options -- string. Options are identified by characters, which must be listed in -- alphabetical order. Valid options are *i* for case insensitive -- matching, *m* for multiline matching, *x* for verbose mode, *l* to -- make \w, \W, etc. locale dependent, *s* for dotall mode ("." matches -- everything), and *u* to make \w, \W, etc. match unicode. data Regex Regex :: Text -> Text -> Regex -- | Javascript code with possibly empty environment mapping variables to -- values that the code may reference data Javascript Javascript :: Document -> Text -> Javascript newtype Symbol Symbol :: Text -> Symbol newtype MongoStamp MongoStamp :: Int64 -> MongoStamp data MinMaxKey MinKey :: MinMaxKey MaxKey :: MinMaxKey -- | A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp -- (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a -- 3-byte counter. Note that the timestamp and counter fields must be -- stored big endian unlike the rest of BSON. This is because they are -- compared byte-by-byte and we want to ensure a mostly increasing order. data ObjectId Oid :: Word32 -> Word64 -> ObjectId -- | Time when objectId was created timestamp :: ObjectId -> UTCTime -- | Create a fresh ObjectId genObjectId :: IO ObjectId -- | showHex of n padded with leading zeros if necessary to fill d digits showHexLen :: (Show n, Integral n) => Int -> n -> ShowS instance GHC.Classes.Ord Data.Bson.Field instance GHC.Classes.Eq Data.Bson.Field instance GHC.Classes.Ord Data.Bson.Javascript instance GHC.Classes.Eq Data.Bson.Javascript instance GHC.Show.Show Data.Bson.Javascript instance GHC.Classes.Ord Data.Bson.Value instance GHC.Classes.Eq Data.Bson.Value instance GHC.Classes.Ord Data.Bson.ObjectId instance GHC.Classes.Eq Data.Bson.ObjectId instance GHC.Classes.Ord Data.Bson.MinMaxKey instance GHC.Classes.Eq Data.Bson.MinMaxKey instance GHC.Read.Read Data.Bson.MinMaxKey instance GHC.Show.Show Data.Bson.MinMaxKey instance GHC.Classes.Ord Data.Bson.MongoStamp instance GHC.Classes.Eq Data.Bson.MongoStamp instance GHC.Read.Read Data.Bson.MongoStamp instance GHC.Show.Show Data.Bson.MongoStamp instance GHC.Classes.Ord Data.Bson.Symbol instance GHC.Classes.Eq Data.Bson.Symbol instance GHC.Read.Read Data.Bson.Symbol instance GHC.Show.Show Data.Bson.Symbol instance GHC.Classes.Ord Data.Bson.Regex instance GHC.Classes.Eq Data.Bson.Regex instance GHC.Read.Read Data.Bson.Regex instance GHC.Show.Show Data.Bson.Regex instance GHC.Classes.Ord Data.Bson.UserDefined instance GHC.Classes.Eq Data.Bson.UserDefined instance GHC.Read.Read Data.Bson.UserDefined instance GHC.Show.Show Data.Bson.UserDefined instance GHC.Classes.Ord Data.Bson.MD5 instance GHC.Classes.Eq Data.Bson.MD5 instance GHC.Read.Read Data.Bson.MD5 instance GHC.Show.Show Data.Bson.MD5 instance GHC.Classes.Ord Data.Bson.UUID instance GHC.Classes.Eq Data.Bson.UUID instance GHC.Read.Read Data.Bson.UUID instance GHC.Show.Show Data.Bson.UUID instance GHC.Classes.Ord Data.Bson.Function instance GHC.Classes.Eq Data.Bson.Function instance GHC.Read.Read Data.Bson.Function instance GHC.Show.Show Data.Bson.Function instance GHC.Classes.Ord Data.Bson.Binary instance GHC.Classes.Eq Data.Bson.Binary instance GHC.Read.Read Data.Bson.Binary instance GHC.Show.Show Data.Bson.Binary instance GHC.Show.Show Data.Bson.Field instance GHC.Show.Show Data.Bson.Value instance Data.Bson.Val GHC.Types.Double instance Data.Bson.Val GHC.Types.Float instance Data.Bson.Val Data.Text.Internal.Text instance Data.Bson.Val GHC.Types.Char instance Data.Bson.Val Data.Bson.Field instance Data.Bson.Val Data.Bson.Value instance Data.Bson.Val a => Data.Bson.Val [a] instance Data.Bson.Val Data.Bson.Binary instance Data.Bson.Val Data.Bson.Function instance Data.Bson.Val Data.Bson.UUID instance Data.Bson.Val Data.Bson.MD5 instance Data.Bson.Val Data.Bson.UserDefined instance Data.Bson.Val Data.Bson.ObjectId instance Data.Bson.Val GHC.Types.Bool instance Data.Bson.Val Data.Time.Clock.UTC.UTCTime instance Data.Bson.Val Data.Time.Clock.POSIX.POSIXTime instance Data.Bson.Val a => Data.Bson.Val (GHC.Base.Maybe a) instance Data.Bson.Val Data.Bson.Regex instance Data.Bson.Val Data.Bson.Javascript instance Data.Bson.Val Data.Bson.Symbol instance Data.Bson.Val GHC.Int.Int32 instance Data.Bson.Val GHC.Int.Int64 instance Data.Bson.Val GHC.Types.Int instance Data.Bson.Val GHC.Integer.Type.Integer instance Data.Bson.Val Data.Bson.MongoStamp instance Data.Bson.Val Data.Bson.MinMaxKey instance GHC.Show.Show Data.Bson.ObjectId instance GHC.Read.Read Data.Bson.ObjectId -- | Standard binary encoding of BSON documents, version 1.0. See -- bsonspec.org module Data.Bson.Binary putDocument :: Document -> Put getDocument :: Get Document putDouble :: Double -> Put getDouble :: Get Double putInt32 :: Int32 -> Put getInt32 :: Get Int32 putInt64 :: Int64 -> Put getInt64 :: Get Int64 putCString :: Text -> Put getCString :: Get Text