r^      !"#$%&'()*+,-./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 IRead up to N bytes from handle, block until at least 1 byte is available #Flush written bytes to destination ERead N bytes from hande, blocking until all N bytes are read. Unlike . which only blocks if no bytes are available. 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.       I/A reply is a message received in response to a (   0 = success, non-zero = failure !0 = cursor finished "#$%&'(+A request is a message that is sent with a  returned )*+,-./0-Number of initial matching documents to skip 1The 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. 2[]& = return all documents in collection 3[] = return whole document 456If set, the database will remove only the first matching document in the collection. Otherwise all matching documents will be removed 78sIf set, the database will update all matching objects in the collection. Otherwise only updates first matching doc 9jIf 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 ;<=>?@ABCDEFGH2A fresh request id is generated for every message IBDatabase name and collection name with period (.) in between. Eg. "myDb.myCollection" J=Thread-safe TCP connection to server with pipelined requests K1New thread-safe pipelined connection over handle L_Send notices as a contiguous batch to server with no reply. Raise IOError if connection fails. MSend 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   NO5 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO5JKLMI:FA=;GHBCDE>?@<798564(-)./0123*+,$'&% !"#NO5 !"# !"#$'&%%&'( -)./0123*+,)*+,-./0123456679889:FA=;GHBCDE>?@<;<=>?@ABCDEFGHIJKLMNOPSame as  e but without functional dependency so the same monad can have multiple contexts with different types Q:Get the context in the Reader in the monad stack that has x context type. Analogous to  . R;Push new context in the Reader in the monad stack that has x context type. Analogous to   PQRPQRPQRQR|SAA command is a special query or action against the database. See  ,http://www.mongodb.org/display/DOCS/Commands for details. T(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. U(key, value_array) -> value. The reduce function receives a key and an array of values. To use, reduce the received values, and return a result. 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. V () -> void|. The map function references the variable this to inspect the current object under consideration. A map function must call emit(key,value)O at least once, but may be invoked any number of times, as may be appropriate. W-Maps every document in collection to a (key, value) pair, then for each unique key reduces all its associated values to a result. Therefore, the final output is a list of (key, result) pairs, where every key is unique. This is the basic description. There are additional nuances that may be used. See  -http://www.mongodb.org/display/DOCS/MapReduce for details. XYZ[\ Default is [] ] Default is [] meaning no sort ^Default is 0 meaning no limit _mOutput to given permanent collection, otherwise output to a new temporary collection whose name is returned. `If 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 _. is specified, then the collection permanent. aHFunction to apply to all the results when finished. Default is Nothing. b5Variables (environment) that can be accessed from mapreducefinalize. Default is []. c<Provide statistics on job execution time. Default is False. d,Fields to group by, or function returning a  key object to be used as the grouping key. Use this instead of key to specify a key that is not an existing member of the object (or, to access embedded members). efghijFields to group by kThe reduce function aggregates (reduces) the objects iterated. Typical operations of a reduce function include summing and counting. reduce takes two arguments: the current document being iterated over and the aggregation value. l-Initial aggregation value supplied to reduce m9Condition that must be true for a row to be considered. [] means always true. n 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). CursorId = 0 means cursor is finished. Documents is remaining documents to serve in current batch. Limit is remaining limit for next fetch. 9A cursor state or a promised cursor state which may fail o&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 ut). Reading from a closed cursor raises a ServerFailure exception. 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. pdThe number of document to return in each batch response from the server. 0 means use Mongo default. q<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 rMaximum number of documents to return, i.e. cursor will close after iterating over this number of documents. 0 means no limit. s9Fields 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. tUse M to create a basic query with defaults, then modify if desired. For example, (select sel col) {limit = 10} uv Default = [] wx[] = all fields. Default = [] y:Number of initial matching documents to skip. Default = 0 zAMaximum 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 Error 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. ut 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 ?Connection or Server failure like network problem or disk full YFailure on server, like disk full, which is usually observed using getLastError. Calling ; inside a connected monad raises this failure. Do not call  unless it is a temporary server failure, like disk full. For example, receiving unexpected data from the server is not a server failure, rather it is a programming error (you should call a in this case) because the client and server are incompatible and requires a programming change. /Error during sending or receiving bytes over a J. The connection is not automatically closed when this error happens; the user must close it. Any other IOErrors raised during a Task or Op are not caught. The user is responsible for these other types of errors not related to sending/%receiving bytes over the connection. A monad with access to a J and  and throws a ! on connection or server failure jRun action with access to connection. Return Left Failure if connection or server fails during execution. _Send notices as a contiguous batch to server with no reply. Raise Failure 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 raise Failure if connection fails send, and promise will return Failure if connection fails receive. &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 8? option is supplied then update all documents in selection. If 9X 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 6> option is given then only delete first document in selection Selects 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. BGiven batchSize and limit return P.qBatchSize and remaining limit  ]Translate Query to Protocol.Query. If first arg is true then add special $explain attribute. !+Send query request and return cursor state !Fetch documents satisfying query "USend 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 # Analogous to $ but with Conn monad %Extract current cursor status &?Convert promised cursor state to cursor state or raise Failure '(Convert Reply to CursorState or Failure (:Send notices and request and return promised cursor state )Create 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 *1Translate Group data into expected document form OExecute group query and return resulting aggregate value for each distinct key +5Translate 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). ,4Send 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 f$%&'STUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ftuvwxyz{|}~$'&%srqpoghijklmndfeWXYZ[\]^_`abcVUTS`STUVW XYZ[\]^_`abcXYZ[\]^_`abcdfeefghijklmnhijklmnopqrst uvwxyz{|}~uvwxyz{|}~NAll servers tried in replica set along with reason why each failed to connect 4connect to a slave, or master if no slave available connect to master only -Configuration info of a server in a replica set. Contains all the servers in the replica set plus its role in that set (master, slave, or arbiter) .Reference to a replica set of servers. Ok if really not a replica set and just a stand-alone server, in which case it acts like a replica set of one. /0Server on default MongoDB port Display server as " host:port"  Read string " host:port" as 'Server host port' or "host" as ' server host'> (default port). Fail if string does not match either syntax.  Read string " host:port" as 'Server host port' or "host" as ' server host'? (default port). Error if string does not match either syntax. wCreate a reference to a replica set with servers as the initial seed list (a subset of the servers in the replica set) SReturn current list of known servers in replica set. This list is updated on every . 15Is the replica server described by this info a master/ primary (not slave or arbiter)? 24Is the replica server described by this info a slave/"secondary (not master or arbiter) 3BAll replicas in set according to this replica configuration info. % If server is stand-alone then it won't have "hosts"D in it configuration, in which case we return the server by itself. 4>All replicas in set sorted by distance from this client. TODO 5RGet replica info of the connected server. Return Left IOError if connection fails 6%Get replica info of connected server 7;Does the server (as described by its info) match the master/ slave type @Create a connection to a master or slave in the replica set. Don't forget to close connection when you are done using it even if Failure exception is raised when using it. newConnection returns Left if failed to connect to any server in replica set. E TODO: prefer slave over master when SlaveOk and both are available. 83Connect to first server that succeeds and is masternslave, otherwise return list of failed connections plus info of connections that succeeded but were not masterslave. fCreate a connection to the given server (as opposed to connecting to some server in a replica set via -). Return Left IOError if failed to connect. JJ99:;<=Cache 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. >Create 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 ?iSpec 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 AAinitialize cache and fork thread that clears it every 15 minutes BC%Get index cache for current database D'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 SCopy database from given server 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). MCopy database from given server to the server I am connected to. If username &: password is supplied use them to read from given server. Delete the given database! BAttempt to fix any corrupt records. This operation takes a while. 8See currently running operation on the database, if any ---EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~$%&'JSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     !"#$%&'())*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU$%VWXYZ[\]^__`abcdefghijklmnnopqrstuvwxy77z{|}~         u$% !"#$%&'()*+,-../0123456789:;<=>?@ABCDEFDEGDEHDEIDEJDEKDELDEMDENDEODEPDEQDERDESDETDEUDEVDEWDEXDEYDEZDE[DE\DE]DE^DE_DE`DEaDEbDEcDEdDEeDEfDEgDEhDEiDEjDEkDElDEmDEnDEoDEpDEqDErDEsDEsDEtDEtDEuDEuDEvDEvDEwDEwDExDExDEyDEyDEzDEzDE{DE{DE|DE}DE~DEDED mongoDB-0.6Database.MongoDB.ConnectionDatabase.MongoDB.Internal.UtilControl.Pipeline"Database.MongoDB.Internal.ProtocolControl.Monad.ContextDatabase.MongoDB.QueryDatabase.MongoDB.AdminDatabase.MongoDBnetwork-2.2.1.7NetworkService PortNumber UnixSocketPortIDSecsignoresnocbitOr<.>looptrue1PipeStreamputgetFlushflushResourcecloseisClosedLengthlengthSizegetNnewPipesendcallNoncePasswordUsernameReply rResponseFlag rCursorId rStartingFrom rDocuments QueryOptionNoCursorTimeoutSlaveOKTailableCursorRequestGetMoregFullCollection gBatchSize gCursorIdQueryqOptionsqFullCollectionqSkip qBatchSize qSelector qProjectorCursorId DeleteOption SingleRemove UpdateOption MultiUpdateUpsertNotice KillCursors kCursorIdsDeletedFullCollectiondOptions dSelectorUpdateuFullCollectionuOptions uSelectoruUpdaterInsertiFullCollection iDocumentsFullCollection Connection mkConnectionpwHashpwKeyContextcontextpushCommand FinalizeFun ReduceFunMapFun MapReducerCollrMaprReducerSelectrSortrLimitrOut rKeepTemp rFinalizerScoperVerboseGroupKeyKeyFKeyGroupgCollgKeygReducegInitialgCond gFinalizeCursor BatchSizeOrderLimit Projectoroptions selectionprojectskiplimitsortsnapshot batchSizehintModifier WriteModeSafeUnsafeSelectselectSelector Selectionselectorcoll CollectionDbConnDatabase ConnectedFailure ServerFailureConnectionFailureConnrunConn allDatabasesuseDb thisDatabaseauthallCollectionswhereJS writeModeinsertinsert_ insertMany insertMany_savereplacerepsertmodifydelete deleteOnefindfindOneexplaincountdistinctnextnextNrestgroup mapReducerunMRrunMR' runCommand runCommand1evalFailedToConnect MasterOrSlaveSlaveOkMaster ReplicaSetServerserver showHostPort readHostPortF readHostPort replicaSetreplicaServers newConnectionconnectOpNumMilliSecProfilingLevelIndexiColliKeyiNameiUnique 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 replyOpcodegetReply mtl-1.1.1.0Control.Monad.Reader.Class MonadReaderasklocal CursorStateCS CursorState'Delayed ErrorCodebaseGHC.BasefailGHC.Errerror getLastErrorassignIdupdatedelete'querybatchSizeRemainingLimit queryRequestrunQueryfindOne'modifyCursorState'Control.Concurrent.MVar modifyMVargetCursorState cursorState fromReplycall' newCursor groupDocument mrDocument runCommand' ReplicaInfo defaultPortisMasterisSlave allReplicassortedReplicasgetReplicaInfogetReplicaInfoDocisMS connectFirstAllSlowOff IndexCache DbIndexCachecoptElem idxDocumentgenName dbIndexCacheclearDbIndexCachefetchIndexCacheresetIndexCache bson-0.0.3 Data.Bson genObjectId timestamp typeOfValtypedcastfval=?=:mergeexcludeincludeatvalueAtlookuplookDocumentvaluelabel:=FieldLabelFloatStringDocArrayBinFunUuidMd5UserDefObjIdBoolUTCNullRegExJavaScrSymInt32Int64StampMinMaxValuecast'valValBinaryFunctionUUIDMD5 UserDefinedRegex JavascriptSymbol MongoStampMinKeyMaxKey MinMaxKeyOidObjectId Data.UStringUString