Add type signatures and extension in code

Fixes #71
This commit is contained in:
Sibi Prabakaran 2016-11-07 21:13:56 +05:30
parent 6e6c591065
commit 7fcebcbb0a
No known key found for this signature in database
GPG key ID: D19E3E0EBB557613

View file

@ -1,42 +1,54 @@
{- | -- |
Client interface to MongoDB database management system. -- Client interface to MongoDB database management system.
--
Simple example below. Use with language extensions /OverloadedStrings/ & /ExtendedDefaultRules/. -- Simple example below.
--
-- @
> import Database.MongoDB -- {\-\# LANGUAGE OverloadedStrings \#\-}
> import Control.Monad.Trans (liftIO) -- {\-\# LANGUAGE ExtendedDefaultRules \#\-}
> --
> main = do -- import Database.MongoDB
> pipe <- connect (host "127.0.0.1") -- import Control.Monad.Trans (liftIO)
> e <- access pipe master "baseball" run --
> close pipe -- main :: IO ()
> print e -- main = do
> -- pipe <- connect (host \"127.0.0.1\")
> run = do -- e <- access pipe master \"baseball\" run
> clearTeams -- close pipe
> insertTeams -- print e
> allTeams >>= printDocs "All Teams" --
> nationalLeagueTeams >>= printDocs "National League Teams" -- run :: Action IO ()
> newYorkTeams >>= printDocs "New York Teams" -- run = do
> -- clearTeams
> clearTeams = delete (select [] "team") -- insertTeams
> -- allTeams >>= printDocs \"All Teams\"
> insertTeams = insertMany "team" [ -- nationalLeagueTeams >>= printDocs \"National League Teams\"
> ["name" =: "Yankees", "home" =: ["city" =: "New York", "state" =: "NY"], "league" =: "American"], -- newYorkTeams >>= printDocs \"New York Teams\"
> ["name" =: "Mets", "home" =: ["city" =: "New York", "state" =: "NY"], "league" =: "National"], --
> ["name" =: "Phillies", "home" =: ["city" =: "Philadelphia", "state" =: "PA"], "league" =: "National"], -- clearTeams :: Action IO ()
> ["name" =: "Red Sox", "home" =: ["city" =: "Boston", "state" =: "MA"], "league" =: "American"] ] -- clearTeams = delete (select [] \"team\")
> --
> allTeams = rest =<< find (select [] "team") {sort = ["home.city" =: 1]} -- insertTeams :: Action IO [Value]
> -- insertTeams = insertMany \"team\" [
> nationalLeagueTeams = rest =<< find (select ["league" =: "National"] "team") -- [\"name\" =: \"Yankees\", \"home\" =: [\"city\" =: \"New York\", \"state\" =: \"NY\"], \"league\" =: \"American\"],
> -- [\"name\" =: \"Mets\", \"home\" =: [\"city\" =: \"New York\", \"state\" =: \"NY\"], \"league\" =: \"National\"],
> newYorkTeams = rest =<< find (select ["home.state" =: "NY"] "team") {project = ["name" =: 1, "league" =: 1]} -- [\"name\" =: \"Phillies\", \"home\" =: [\"city\" =: \"Philadelphia\", \"state\" =: \"PA\"], \"league\" =: \"National\"],
> -- [\"name\" =: \"Red Sox\", \"home\" =: [\"city\" =: \"Boston\", \"state\" =: \"MA\"], \"league\" =: \"American\"] ]
> printDocs title docs = liftIO $ putStrLn title >> mapM_ (print . exclude ["_id"]) docs --
> -- allTeams :: Action IO [Document]
-} -- allTeams = rest =<< find (select [] \"team\") {sort = [\"home.city\" =: 1]}
--
-- nationalLeagueTeams :: Action IO [Document]
-- nationalLeagueTeams = rest =<< find (select [\"league\" =: \"National\"] \"team\")
--
-- newYorkTeams :: Action IO [Document]
-- newYorkTeams = rest =<< find (select [\"home.state\" =: \"NY\"] \"team\") {project = [\"name\" =: 1, \"league\" =: 1]}
--
-- printDocs :: String -> [Document] -> Action IO ()
-- printDocs title docs = liftIO $ putStrLn title >> mapM_ (print . exclude [\"_id\"]) docs
--
-- @
--
module Database.MongoDB ( module Database.MongoDB (
module Data.Bson, module Data.Bson,