=      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ add element to end of list (snoc is reverse of cons, which adds to front of list) bit-or all numbers together =Concat first and second together with period in between. Eg. "hello" <.> "world" = " hello.world" GRepeatedy execute action, collecting results, until it returns Nothing Is field's value a 1 or True (MongoDB use both Int and Bools for truth values). Error if field not in document or field not a Num or Bool.     !Thread-safe and pipelined socket >Mutex on handle, so only one thread at a time can write to it vQueue of threads waiting for responses. Every time a response arrive we pop the next thread and give it the response.  Write bytes to handle nRead up to N bytes from handle; if EOF return empty bytes, otherwise block until at least 1 byte is available #Flush written bytes to destination Close resource Is resource closed yRead N bytes from hande, blocking until all N bytes are read. If EOF is reached before N bytes then throw EOF exception. HCreate new Pipe with given encodeInt, decodeInt, and handle. You should  pipe when finished, which will also close handle. If pipe is not closed but eventually garbage collected, it will be closed along with handle. YConvert Size to bytes of fixed length. Every Int must translate to same number of bytes. LConvert bytes of fixed length to Size. Must be exact inverse of encodeSize. .Underlying socket (handle) this pipe will read/ write from AListen for responses and supply them to waiting threads in order Send messages all together to destination (no messages will be interleaved between them). None of the messages can induce a response, i.e. the destination must not reply to any of these messages (otherwise future 2s will get these responses instead of their own). A Each message is preceeded by its length when written to socket. eSend messages all together to destination (no messages will be interleaved between them), and return promise of response from one message only. One and only one message in the list must induce a response, i.e. the destination must reply to exactly one message only (otherwise promises will have the wrong responses in them). y Each message is preceeded by its length when written to socket. Likewise, the response must be preceeded by its length.     P `For backward compatability: Set when the server supports the AwaitData query option. if it doesn'?t, a replica slave client should sleep a little between getMore's !6Query error. Returned with one document containing an $err" field holding the error message. "eSet when getMore is called but the cursor id is not valid at the server. Returned with zero results. #/A reply is a message received in response to a . $%&0 = cursor finished '()*Use with TailableCursor. If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal. = | Exhaust -- ^ Stream the data down full blast in multiple more packages, on the assumption that the client will fully read all data queried. Faster when you are pulling a lot of data and know you want to pull it all down. Note: the client is not allowed to not read all the data unless it closes the connection. +,RAllow query of replica slave. Normally these return an error except for namespace local. -nTailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object'ss position. You can resume using the cursor later, from where it was located, if more data were received. Like any  latent cursor, the cursor may become invalid at some point  for example if the final object it references were deleted. Thus, you should be prepared to requery on CursorNotFound exception. .+A request is a message that is sent with a $# returned /0123456-Number of initial matching documents to skip 7The number of document to return in each batch response from the server. 0 means use Mongo default. Negative means close cursor after first batch and use absolute value as batch size. 8[]& = return all documents in collection 9[] = return whole document :;<If set, the database will remove only the first matching document in the collection. Otherwise all matching documents will be removed =>sIf set, the database will update all matching objects in the collection. Otherwise only updates first matching doc ?jIf set, the database will insert the supplied object into the collection if no matching document is found @1A notice is a message that is sent with no reply ABCDEFGHIJKLMN2A fresh request id is generated for every message  OBDatabase name and collection name with period (.) in between. Eg. "myDb.myCollection" P=Thread-safe TCP connection to server with pipelined requests Q1New thread-safe pipelined connection over handle R_Send notices as a contiguous batch to server with no reply. Raise IOError if connection fails. SSend notices and request as a contiguous batch to server and return reply promise, which will block when invoked until reply arrives. This call and resulting promise will raise IOError if connection fails.    Generate fresh request id  PNote, does not write message length (first int32), assumes caller will write it NNote, does not read message length (first int32), assumes it was already read TU: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU:PQRSO@LGCAMNHIJKDEFB=?>;<:.3/456789012)-,+*#$%&'("! TU:"! !"#$%&'($%&'()-,+**+,-. 3/456789012/0123456789:;<<=?>>?@LGCAMNHIJKDEFBABCDEFGHIJKLMNOPQRSTUVSame as c but without functional dependency so the same monad can have multiple errors with different types W4Abort action and throw give exception. Analogous to . XOIf first action aborts with exception then execute second action. Analogous to  YXExecute action and throw exception if result is Left, otherwise return the Right result VWXYVWXYVWXWXYZ[4connect to a slave, or master if no slave available \connect to master only  Configuration info of a host in a replica set. Contains all the hosts in the replica set plus its role in that set (master, slave, or arbiter) !]Reference to a replica set of hosts. Ok if really not a replica set and just a stand-alone server, in which case it acts like a replica set of one. "^_`{Execute action that raises IOError only on network problem. Other IOErrors like file access errors are not caught by this. #Convert command to request $eExtract first document from reply. Error if query error, using given string as prefix error message. %aHost on default MongoDB port bDisplay host as " host:port" c Read string " hostname:port" as Host hosthame port or "hostname" as  host hostname> (default port). Fail if string does not match either syntax. d Read string " hostname:port" as Host hostname port or "hostname" as  host hostname? (default port). Error if string does not match either syntax. eyCreate a reference to a replica set with given hosts as the initial seed list (a subset of the hosts in the replica set) fQReturn current list of known hosts in replica set. This list is updated on every g. &.Is the replica described by this info a master/ primary (not slave or arbiter)? '-Is the replica described by this info a slave/"secondary (not master or arbiter) (BAll replicas in set according to this replica configuration info. # If host is stand-alone then it won't have "hosts"C in its configuration, in which case we return the host by itself. )>All replicas in set sorted by distance from this client. TODO *KGet replica info of the connected host. Throw IOError if connection fails. +ADoes the host (as described by its replica-info) match the master/ slave type gCreate a connection to a master or slave in the replica set. Throw IOError if failed to connect to any host in replica set that is the right master/ slave type.  connection when you are done using it even if a failure is raised. Garbage collected connections will be closed automatically (but don'0t rely on this when creating many connections). E TODO: prefer slave over master when SlaveOk and both are available. ,1Connect to first host that succeeds and is masternslave, otherwise return list of failed connections plus info of connections that succeeded but were not masterslave. hbCreate a connection to the given host (as opposed to connecting to some host in a replica set via g). Throw IOError if can' t connect. PZ[\]^_`abcdefgh`^_abdc]efgZ\[PhZ\[[\]^__`abcdefghiSame as -e but without functional dependency so the same monad can have multiple contexts with different types j:Get the context in the Reader in the monad stack that has x context type. Analogous to .. k;Push new context in the Reader in the monad stack that has x context type. Analogous to / ijkijkijkjklAA command is a special query or action against the database. See  ,http://www.mongodb.org/display/DOCS/Commands for details. m(key, value) -> final_valuep. A finalize function may be run after reduction. Such a function is optional and is not necessary for many map/]reduce cases. The finalize function takes a key and a value, and returns a finalized value. n(key, value_array) -> value. The reduce function receives a key and an array of values and returns an aggregate result value. The MapReduce engine may invoke reduce functions iteratively; thus, these functions must be idempotent. That is, the following must hold for your reduce function: +for all k, vals : reduce(k, [reduce(k,vals)]) == reduce(k,vals). If you need to perform an operation only once, use a finalize function. The output of emit (the 2nd param) and reduce should be the same format to make iterative reduce possible. o () -> void+. The map function references the variable thisK to inspect the current object under consideration. The function must call emit(key,value)O at least once, but may be invoked any number of times, as may be appropriate. pMaps every document in collection to a list of (key, value) pairs, then for each unique key reduces all its associated values from all lists to a single result. There are additional parameters that may be set to tweak this basic operation. qrstu6Operate on only those documents selected. Default is [] meaning all documents. v Default is [] meaning no sort wDefault is 0 meaning no limit xmOutput to given permanent collection, otherwise output to a new temporary collection whose name is returned. yIf True, the temporary output collection is made permanent. If False, the temporary output collection persists for the life of the current connection only, however, other connections may read from it while the original one is still alive. Note, reading from a temporary collection after its original connection dies returns an empty result (not an error). The default for this attribute is False, unless x. is specified, then the collection permanent. zHFunction to apply to all the results when finished. Default is Nothing. {5Variables (environment) that can be accessed from mapreducefinalize. Default is []. |<Provide statistics on job execution time. Default is False. }!Fields to group by, or function ( doc -> key) returning a  key object to be used as the grouping key. Use KeyF instead of Key to specify a key that is not an existing member of the object (or, to access embedded members). ~KGroups documents in collection by key then reduces (aggregates) each group Fields to group by (doc, agg) -> (). The reduce function reduces (aggregates) the objects iterated. Typical operations of a reduce function include summing and counting. It takes two arguments, the current document being iterated over and the aggregation value, and updates the aggregate value. agg/. Initial aggregation value supplied to reduce 9Condition that must be true for a row to be considered. [] means always true. agg -> () | result. An optional function to be run on each item in the result set just before the item is returned. Can either modify the item (e.g., add an average field given a count and a total) or return a replacement object (returning a new object with just _id and average fields). 0CursorId = 0 means cursor is finished. Documents is remaining documents to serve in current batch. Limit is remaining limit for next fetch. 129A cursor state or a promised cursor state which may fail 34&Iterator over results of a query. Use  to iterate or  to get all results. A cursor is closed when it is explicitly closed, all results have been read from it, garbage collected, or not used for over 10 minutes (unless  option was specified in )). Reading from a closed cursor raises a . Note, a cursor is not closed when the connection is closed, so you can open another connection to the same server and continue using the cursor. 5dThe number of document to return in each batch response from the server. 0 means use Mongo default. <Fields to sort by. Each one is associated with 1 or -1. Eg. [x =: 1, y =: -1] means sort by x ascending then y descending Maximum number of documents to return, i.e. cursor will close after iterating over this number of documents. 0 means no limit. 9Fields to return, analogous to the select clause in SQL. []6 means return whole document (analogous to * in SQL). [x =: 1, y =: 1] means return only x and y fields of each document. [x =: 0] means return all fields except x. Use with TailableCursor. If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal. nTailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object'ss position. You can resume using the cursor later, from where it was located, if more data were received. Like any  latent cursor, the cursor may become invalid at some point  for example if the final object it references were deleted. Thus, you should be prepared to requery on CursorNotFound exception. Use M to create a basic query with defaults, then modify if desired. For example, (select sel col) {limit = 10}  Default = [] [] = all fields. Default = [] :Number of initial matching documents to skip. Default = 0 AMaximum number of documents to return, 0 = no limit. Default = 0 Sort results by this order, [] = no sort. Default = [] xIf true assures no duplicates are returned, or objects missed, which were present at both the start and end of the query's execution (even if the object were updated). If an object is new during the query, or deleted during the query, it may or may not be returned, even with snapshot mode. Note that short query responses (less than 1MB) are always effectively snapshotted. Default = False pThe number of document to return in each batch response from the server. 0 means use Mongo default. Default = 0 "Force MongoDB to use this index, [] = no hint. Default = [] /Update operations on fields in a document. See  Hhttp://www.mongodb.org/display/DOCS/Updating#Updating-ModifierOperations 6Error code from getLastError Default write-mode is  _Receive an acknowledgment after every write, and raise exception if one says the write failed. hSubmit writes without receiving acknowledgments. Fast. Assumes writes succeed even though they may not.  or n that selects documents in collection that match selector. The choice of type depends on use, for example, in find (select sel col) it is a Query, and in delete (select sel col) it is a Selection. :Filter for a query, analogous to the where clause in SQL. []& matches all documents in collection. [x =: a, y =: b] is analogous to where x = a and y = b in SQL. See  ,http://www.mongodb.org/display/DOCS/Querying for full selector syntax. 4Selects documents in collection that match selector -Collection name (not prefixed with database) A  monad with access to a  Database name JRead or write exception like cursor expired or inserting a duplicate key. k Note, unexpected data from the server is not a Failure, rather it is a programming error (you should call 7a in this case) because the client and server are incompatible and requires a programming change. MError observed by getLastError after a write, error description is in string 8Query failed for some reason as described in the string Cursor expired because it wasn't accessed for over 10 minutes, or this cursor came from a different server that the one you are currently connected to (perhaps a fail over happen between servers in a replica set) A monad with access to a P, Z, and  , and throws  on read/write failure and 8 on connection failure Monad with access to a P, Z, and , and throws a  on read/0write failure and IOError on connection failure 9:_Send notices as a contiguous batch to server with no reply. Throw IOError if connection fails. ;Send notices and request as a contiguous batch to server and return reply promise, which will block when invoked until reply arrives. This call will throw IOError if connection fails on send, and promise will throw IOError if connection fails on receive. RRun action with access to connection. It starts out assuming it is master (invoke . inside it to change that) and that writes don't need to be check (invoke r to change that). Return Left Failure if error in execution. Throws IOError if connection fails during execution. &List all databases residing on server %Run Db action against given database Current database in use Authenticate with the database (if server is running in secure mode). Return whether authentication was successful or not. Reauthentication is required for every new connection. &List all collections in this database fAdd Javascript predicate to selector, in which case a document must match both selector and predicate Run action with given  <+Send write to server, and if write-mode is - then include getLastError request and raise  if it reports an error. =QSend notices (writes) then fetch what the last error was, Nothing means no error /Insert document into collection and return its "_id"7 value, which is created automatically if not supplied Same as  except don' t return _id 2Insert documents into collection and return their "_id"9 values, which are created automatically if not supplied Same as  except don't return _ids >.Assign a unique value to _id field if missing BSave document to collection, meaning insert it if its new (has no "_id") field) or update it if its not new (has "_id" field) 8Replace first document in selection with given document bReplace first document in selection with given document, or insert document if selection is empty 7Update all documents in selection using given modifier ?BUpdate first document in selection using updater document, unless >? option is supplied then update all documents in selection. If ?X option is supplied then treat updater as document and insert it if selection is empty. "Delete all documents in selection #Delete first document in selection @)Delete all documents in selection unless <> option is given then only delete first document in selection JOk to execute given action against slave, ie. eventually consistent reads AB!Convert to protocol query option CSelects documents in collection that match selector. It uses no query options, projects all fields, does not skip any documents, does not limit result size, uses default batch size, does not sort, does not hint, and does not snapshot. DBGiven batchSize and limit return P.qBatchSize and remaining limit E]Translate Query to Protocol.Query. If first arg is true then add special $explain attribute. F+Send query request and return cursor state !Fetch documents satisfying query GUSend notices and fetch first document satisfying query or Nothing if none satisfy it DFetch first document satisfying query or Nothing if none satisfy it ,Return performance stats of query execution HFetch number of documents satisfying query (including effect of skip and/or limit if present) 5Fetch distinct values of field in selected documents H Analogous to I but with Conn monad JExtract current cursor status K:Send notices and request and return promised cursor state L9Convert promised cursor state to cursor state or failure M(Convert Reply to CursorState or Failure NCreate new cursor. If you don't read all results then close it. Cursor will be closed automatically when all results are read from it or when eventually garbage collected. >Return next document in query result, or Nothing if finished. 2Return next N documents or less if end is reached +Return remaining documents in query result O1Translate Group data into expected document form OExecute group query and return resulting aggregate value for each distinct key P5Translate MapReduce data into expected document form MapReduce on collection with given map and reduce functions. Remaining attributes are set to their defaults, which are stated in their comments. 8Run MapReduce and return cursor of results. Error if map/)reduce fails (because of bad Javascript) ~ TODO: Delete temp result collection when cursor closes. Until then, it will be deleted by the server when connection closes. 8Run MapReduce and return a result document containing a resultV field holding the output Collection and additional statistic fields. Error if the map/+reduce failed (because of bad Javascript). Q4Send notices then run command and return its result 7Run command against the database and return its result  &runCommand1 foo = runCommand [foo =: 1]Run code on server RS is treated the same as 7. In other words, don' t use it. hlmnopqrstuvwxyz{|}~h}~pqrstuvwxyz{|onmlflmnop qrstuvwxyz{|qrstuvwxyz{|}~~ 9TUVWXCache the indexes we create so repeatedly calling ensureIndex only hits database the first time. Clear cache every once in a while so if someone else deletes index we will recreate it on ensureIndex. YCreate collection with given options. You only need to call this to set options, otherwise a collection is created automatically on first use with no options. -Rename first collection to second collection Delete the given collection! Return True if collection existed (and was deleted); return False if collection did not exist (and no action). This operation takes a while ZiSpec of index of ordered keys on collection. Name is generated from keys. Unique and dropDups are False. [-Create index if we did not already create one. May be called repeatedly with practically no performance hit, because we remember if we already called this for the same index (although this memory gets wiped out every 15 minutes, in case another client drops the index and we want to create it again). ECreate index on the server. This call goes to the server every time. Remove the index #Get all indexes on this collection $Drop all indexes on this collection \Ainitialize cache and fork thread that clears it every 15 minutes ]^%Get index cache for current database _'reset index cache for current database !Fetch all users of this database cAdd user with password with read-only access if bool is True or read-write access if bool is False QCopy database from given host to the server I am connected to. Fails and returns ok = 0 if we don'Mt have permission to read from given server (use copyDatabase in this case). KCopy database from given host to the server I am connected to. If username &8 password is supplied use them to read from given host. Delete the given database! BAttempt to fix any corrupt records. This operation takes a while. 8See currently running operation on the database, if any --- `abcdefghijklmnopqrstuvwxyz{|}~PZ[\]^_`abcdefghlmnopqrstuvwxyz{|}~     !"#$%&'()*+,-.//0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\&']^_`abcdefgghijklmnopqrstuvwxxyz{|}~4568>>     f !"#$%&'()*+*,*-./0.12345367&'89:;<=>?@ABC3DEFGHIJKLMN3OPQRSTUVWXYZ[\]^_]^`]^a]^b]^c]^d]^e]^f]^g]^h]^i]^j]^k]^l]^m]^n]^o]^p]^q]^r]^s]^t]^u]^v]^w]^x]^y]^z]^{]^|]^}]^~]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^]^] mongoDB-0.7.1Database.MongoDB.ConnectionDatabase.MongoDB.Internal.UtilControl.Pipeline"Database.MongoDB.Internal.ProtocolControl.Monad.ThrowControl.Monad.ContextDatabase.MongoDB.QueryDatabase.MongoDB.AdminDatabase.MongoDBnetwork-2.2.1.7NetworkService PortNumber UnixSocketPortIDSecsMonadIO'ignoresnocbitOr<.>looptrue1PipeStreamputgetFlushflushResourcecloseisClosedLengthlengthSizegetNnewPipesendcallNoncePasswordUsername ResponseFlag AwaitCapable QueryErrorCursorNotFoundReplyrResponseFlags rCursorId rStartingFrom rDocuments QueryOption AwaitDataNoCursorTimeoutSlaveOKTailableCursorRequestGetMoregFullCollection gBatchSize gCursorIdQueryqOptionsqFullCollectionqSkip qBatchSize qSelector qProjectorCursorId DeleteOption SingleRemove UpdateOption MultiUpdateUpsertNotice KillCursors kCursorIdsDeletedFullCollectiondOptions dSelectorUpdateuFullCollectionuOptions uSelectoruUpdaterInsertiFullCollection iDocumentsFullCollection Connection mkConnectionpwHashpwKeyThrowthrowcatch throwLeftMasterOrSlaveOkSlaveOkMaster ReplicaSetHostrunNethost showHostPort readHostPortM readHostPort replicaSetreplicas newConnectionconnectContextcontextpushCommand FinalizeFun ReduceFunMapFun MapReducerCollrMaprReducerSelectrSortrLimitrOut rKeepTemp rFinalizerScoperVerboseGroupKeyKeyFKeyGroupgCollgKeygReducegInitialgCond gFinalizeCursor BatchSizeOrderLimit Projectoroptions selectionprojectskiplimitsortsnapshot batchSizehintModifier WriteModeSafeUnsafeSelectselectSelector Selectionselectorcoll CollectionDbConnDatabaseFailure WriteFailure QueryFailureCursorNotFoundFailureConn ConnectedrunConn allDatabasesuseDb thisDatabaseauthallCollectionswhereJS writeModeinsertinsert_ insertMany insertMany_savereplacerepsertmodifydelete deleteOneslaveOkfindfindOneexplaincountdistinctnextnextNrestgroup mapReducerunMRrunMR' runCommand runCommand1evalOpNumMilliSecProfilingLevelIndexiColliKeyiNameiUnique iDropDups IndexNameCollectionOptionMaxItems MaxByteSizeCappedcreateCollectionrenameCollectiondropCollectionvalidateCollectionindex ensureIndex createIndex dropIndex getIndexes dropIndexesallUsersaddUser removeUser cloneDatabase copyDatabase dropDatabaserepairDatabaseserverBuildInfo serverVersioncollectionStatsdataSize storageSizetotalIndexSize totalSizegetProfilingLevelsetProfilingLeveldbStats currentOpkillOp serverStatus encodeSize decodeSizevHandle responseQueue listenThreadlistenwrite ResponseTo RequestIdOpcode noticeBytes bytesReply genRequestId putHeader getHeadernOpcode putNoticeuBituBitsdBitdBitsqOpcode putRequestqBitqBits replyOpcodegetReplyrFlagsrBit mtl-1.1.1.0Control.Monad.Error.Class MonadError throwError catchError ReplicaInfo adminCommand commandReply defaultPortisMasterisSlave allReplicassortedReplicasgetReplicaInfoisMS connectFirstControl.Monad.Reader.Class MonadReaderasklocal CursorStateCS CursorState'Delayed ErrorCodebaseGHC.ErrerrorGHC.IO.ExceptionIOError getLastErrorassignIdupdatedelete'msOptionpOptionquerybatchSizeRemainingLimit queryRequestrunQueryfindOne'modifyCursorState'Control.Concurrent.MVar modifyMVargetCursorStatecall' cursorState fromReply newCursor groupDocument mrDocument runCommand'$fErrorFailureGHC.BasefailAllSlowOff IndexCache DbIndexCachecoptElem idxDocumentgenName dbIndexCacheclearDbIndexCachefetchIndexCacheresetIndexCache bson-0.0.3 Data.Bson genObjectId timestamp typeOfValtypedcastfval=?=:mergeexcludeincludeatvalueAtlookuplookDocumentvaluelabel:=FieldLabelFloatStringDocArrayBinFunUuidMd5UserDefObjIdBoolUTCNullRegExJavaScrSymInt32Int64StampMinMaxValuecast'valValBinaryFunctionUUIDMD5 UserDefinedRegex JavascriptSymbol MongoStampMinKeyMaxKey MinMaxKeyOidObjectId Data.UStringUString