)S      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~None !"03457>L*Types which can be converted to or from a .Objects are maps from  to . Like Aeson, we're using a strict .Arrays are vectors of .UA sumtype covering all the primitive types which can appear in queries or responses.It is similar to the aeson 9 type, except that RethinkDB has a few more types (like )), which have a special encoding in JSON.We can't automatically derive  because  does not have an instance of  . See the eqTime' function for why we can compare times.; ! !2 !D(c) 2011, 2012 Bryan O'Sullivan (c) 2011 MailRank, Inc.Apache experimentalportableNone35"Generates both  and 0 instance declarations for the given data type.EThis is a convienience function which is equivalent to calling both # and %.# Generates a . instance declaration for the given data type.$IGenerates a lambda expression which encodes the given data type as Datum.Helper function used by both # and ${. Generates code to generate the Datum encoding of a number of constructors. All constructors must be from the same type.If constructor is nullary.FGenerates code to generate the Datum encoding of a single constructor.% Generates a . instance declaration for the given data type.&VGenerates a lambda expression which parses the Datum encoding of the given data type.Helper function used by both % and &x. Generates code to parse the Datum encoding of a number of constructors. All constructors must be from the same type.CGenerates code to parse the Datum encoding of a single constructor.DGenerates code to parse the Datum encoding of an n-ary constructor."Boilerplate for top level splices. The given  must be from a type constructor. Furthermore, the type constructor must be either a data type or a newtype. Any other value will result in an exception.%Extracts the name from a constructor..Extracts the name from a type variable binder.<Makes a string literal expression from a constructor's name.>Creates a string literal expression from a record field label.The name of the outermost Value constructor.,"Encoding options.'Name of the type for which to generate  and  instances.#Encoding options.)Name of the type for which to generate a  instance declaration.$Encoding options.Name of the type to encode.Encoding options.9Constructors for which to generate Datum generating code.%Encoding options.)Name of the type for which to generate a  instance declaration.&Encoding options.Name of the encoded type.2Name of the type to which the constructors belong.Encoding options6Constructors for which to generate Datum parsing code.2Name of the type to which the constructor belongs.Encoding options.5Constructor for which to generate Datum parsing code.0Left (valFieldName, objName) or Right valName2Name of the type to which the constructor belongs.structor name.structor arity.Function that generates the actual code. Will be applied to the type variable binders and constructors extracted from the given .Resulting value in the  uasi monad.Encoding options "#$%&  "#%$&+"#$%&None !"03457>L%YThis appears to be a UUID, but I don't want to add a dependency just for this one field.+Errors include a plain-text description which includes further details. The RethinkDB protocol also includes a backtrace which we currently don't parse.,An error on the protocol level. Perhaps the socket was closed unexpectedly, or the server sent a message which the driver could not parse.-Means the client is buggy. An example is if the client sends a malformed protobuf, or tries to send [CONTINUE] for an unknown token..sMeans the query failed during parsing or type checking. For example, if you pass too many arguments to a function./Means the query failed at runtime. An example is if you add together two values from a table, but they turn out at runtime to be booleans rather than numbers.6zA token is used to refer to queries and the corresponding responses. This driver uses a monotonically increasing counter.7&A value which can be converted from a 0. All types which are defined as being a 'Result a' should have a 'FromResponse a'. Because, uhm.. you really want to be able to extract the result from the response.There are two parsers defined here, one for atoms and the other for sequences. These are the only two implementations of parseResponse which should be used.8The result of a query. It is either an error or a result (which depends on the type of the query expression). This type is named to be symmetrical to =, so we get this nice type for run. $run :: Handle -> Exp a -> IO (Res a)9=The type of result you get when executing a query of 'Exp a'.:tBecause the arguments to functions are polymorphic (the individual arguments can, and often have, different types).fThe class of types e which can be lifted into c. All basic Haskell types which can be represented as =R are instances of this, as well as certain types of functions (unary and binary).1Type-level function which simplifies the type of e once it is lifted into ca. This is used for functions where we strip the signature so that we don't have to define dummy  instances for those.|Sequences are a bounded list of items. The server may split the sequence into multiple chunks when sending it to the client. When the response is a partial sequence, the client may request additional chunks until it gets a }.Used in i.ConflictResolutionStrategy!How conflicts should be resolved.YDo not insert the new document and record the conflict as an error. This is the default.:Replace the old document in its entirety with the new one.?Update fields of the old document with fields from the new one.Bounds are used in g.A ? is something which contains tables. It is a server-only type.( is essentially a 'Maybe Object', where  is represented with  in the network protocol.1Tables are something you can select objects from.qThis type is not exported, and merely serves as a sort of phantom type. On the client tables are converted to a |.Objects are maps from  to . Like Aeson, we're using .lBuilding a RethinkDB query from an expression is a stateful process, and is done using this as the context. How many ls have been allocated. See .+The default database for the case that the ! expression doesn't specify one.A Term is a JSON expression which can be sent to the server. Building a term is a stateful operation, so the whole process happens inside a  monad.*Allocate a new var index from the context./Call an unary function with the given argument.1Call an binary function with the given arguments..Convenience to for automatically converting a  to a constant expression.0Time in RethinkDB is represented similar to the b type. Except that the JSON representation on the wire looks different from the default used by Aeson. Therefore we have a custom FromRSON and ToRSON instances.Arrays are vectors of .%For strings, we're using the Haskell  type. Numbers are  (unlike Aeson , which uses  Scientific). No particular reason.7For a boolean type, we're reusing the standard Haskell  type.'()*   +,-./012345  6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop'()*   +,-./012345  6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()s'()*   +,-./012345  6789:;<==>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopNoneqiReceive the next message from the socket. If it fails, a (hopefully) descriptive error will be returned.rstquvwxrstquvwxrstquvwxNone4yAny thread can write to the socket. In theory. But I don't think Haskell allows atomic writes to a socket, so it is protected inside an z.When too many threads write to the socket, this may cause resource contention. Users are encouraged to use a resource pool to alleviate that.{,This is used to allocate new tokens. We use |% to efficiently allocate new tokens.fRethinkDB seems to expect the token to never be zero. So we need to start with one and then count up.}If there was a fatal error while reading from the socket, it will be stored here. If this is set then no further replies will be processed. The user needs to close and re-open the handle to recover.~dResponses to queries. A thread reads the responses from the socket and pushes them into the queues.LThread which reads from the socket and copies responses into the queues in ~.+The database which should be used when the ! expression doesn't specify one.CThe default port where RethinkDB accepts client driver connections.,Create a new handle to the RethinkDB server.The E which some expressions will use when not explicitly given one (eg. ).?Close the given handle. You MUST NOT use the handle after this.VStart a new query and wait for its (first) result. If the result is an single value (v), then there will be no further results. If it is a sequence, then you must consume results until the sequence ends.gGet the next chunk of a sequence. It is an error to request the next chunk if the sequence is already },NCollect all the values in a sequence and make them available as a 'Vector a'.Start a new query. Returns the 6* which can be used to track its progress.YLet the server know that it can send the next response corresponding to the given token.Stop (abort?) a query.8Wait until a previous query (which was started with the noreply option) finishes.This function blocks until there is a response ready for the query with the given token. It may block indefinitely if the token refers to a query which has already finished or does not exist yet!y{}~ !'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~6+,-./012345'()* !=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz:;|}~897<{y{}~      !"#$%&'()*+,,-./01234456789:;<==>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy/z{|}~OPR      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~rethi_6F33N1e1hsMDocqeUY7oDHDatabase.RethinkDB.THDatabase.RethinkDBDatabase.RethinkDB.Types.DatumDatabase.RethinkDB.TypesDatabase.RethinkDB.Messagesaeson_8pJ8mDJSo9R8dbdfpRUa0fData.Aeson.Types.InternaldefaultTaggedObjectdefaultOptionsunwrapUnaryRecords sumEncodingomitNothingFieldsallNullaryToStringTagconstructorTagModifierfieldLabelModifierOptions TwoElemArrayObjectWithSingleFieldcontentsFieldName tagFieldName TaggedObject SumEncoding FromDatum parseDatumToDatumtoDatumObjectArrayDatumNullBoolNumberStringTime.=.:.:?object deriveDatum deriveToDatum mkToDatumderiveFromDatum mkParseDatumChangeNotification cnOldValue cnNewValueError ProtocolError ClientError CompileError RuntimeErrorResponse responseToken responseTyperesponseResult responseNotesToken FromResponseResResultSomeExpliftExpConstantMkArray ListDatabasesCreateDatabase DropDatabase WaitDatabase ListTables CreateTable DropTable WaitTable ListIndices CreateIndex DropIndex IndexStatus WaitIndexDatabaseTableCoerceEqNeNotMatchGetGetAll GetAllIndexedAddSubMultiplyAllAnyGetField HasFieldsTakeAppendPrependIsEmptyDelete InsertObjectInsertSequenceFilterMapBetweenBetweenIndexedOrderByOrderByIndexedKeysVarFunctionCallLimitNthUUIDNowTimezone RandomInteger RandomFloatInfoDefaultSequenceChangesSingleSelectionChanges IsSequenceSequenceDonePartialOrder Ascending DescendingConflictResolutionStrategyCRError CRReplaceCRUpdateBoundOpenClosedSingleSelectionIsObjectIsDatumcall1call2 emptyOptionsHandle defaultPort newHandlehandleDatabaseclose serverInforun nextChunkcollectstartcontinuestopwait nextResulttext_BKzOMwCPkuv5n8xwLM3CQGData.Text.InternalTextunord_LFy5OM3asdWIga7FrU8690Data.HashMap.BaseHashMapValue $fEqDatumghc-prim GHC.Classestime_AXTdBF9VRQoBOqJT6qtmVHData.Time.LocalTime.LocalTime ZonedTime parseWirezonedTimeParser$fFromDatumValue$fToDatumValue$fFromDatumMaybe$fToDatumMaybe $fFromDatum[] $fToDatum[]$fFromDatumUTCTime$fToDatumUTCTime$fFromDatumZonedTime$fToDatumZonedTime$fFromDatumHashMap$fToDatumHashMap$fFromDatumVector$fToDatumVector$fFromDatumText $fToDatumText$fFromDatum[]0 $fToDatum[]0$fFromDatumChar $fToDatumChar$fFromDatumInt $fToDatumInt$fFromDatumFloat$fToDatumFloat$fFromDatumDouble$fToDatumDouble$fFromDatumBool $fToDatumBool$fFromDatum(,,) $fToDatum(,,)$fFromDatum(,) $fToDatum(,) $fFromDatum() $fToDatum()$fFromDatumDatum$fToDatumDatum$fFromJSONDatum $fToJSONDatum consToDatum isNullary encodeArgs consFromDatum parseArgs parseProductwithTypetemplate-haskellLanguage.Haskell.TH.SyntaxName getConNametvbName conNameExp fieldLabelExp valueConName LookupField lookupFieldconStrconTxt conStringE encodeSumparseNullaryMatchesparseUnaryMatches parseRecord getValFieldCon matchFailedparseTypeMismatchunknownFieldFail noArrayFail noObjectFailfirstElemNoStringFailwrongPairCountFail noStringFail noMatchFail not2ElemArrayconNotFoundFail2ElemArray conNotFoundFailObjectSingleFieldconNotFoundFailTaggedObjectparseTypeMismatch'QapplyCon$fLookupFieldMaybe$fLookupFieldasiIdLift SimplifiedTermbaseGHC.BaseNothingContext varCounternewVardefaultDatabasetrans_3eG64VdP2vzGjP6wJiCp5XControl.Monad.Trans.State.LazyState $fIsStringExp$fIsDatumZonedTime$fIsDatumVector $fIsDatumText$fIsDatumDouble GHC.TypesDouble $fIsDatumBool ServerInfosiName ResponseNote SequenceFeedAtomFeedOrderByLimitFeed UnionedFeedIncludesStates ResponseType SuccessAtomSuccessSequenceSuccessPartial WaitComplete RTServerInfoClientErrorTypeCompileErrorTypeRuntimeErrorType parseResponse MkDatabaseMkTabletoTerm compileTerm boundDatum boundString noargTerm simpleTermtermWithOptionsresponseAtomParserresponseSequenceParserresponseParser$fFromDatumChangeNotification$fFromResponseServerInfo$fFromJSONResponseNote$fFromJSONResponseTypeTFCo:R:ResultSequenceTFCo:R:ResultSingleSelectionTFCo:R:ResultVectorTFCo:R:ResultHashMapTFCo:R:ResultDatumTFCo:R:ResultTableTFCo:R:ResultZonedTimeTFCo:R:ResultBoolTFCo:R:Result[]TFCo:R:ResultCharTFCo:R:ResultIntTFCo:R:ResultDoubleTFCo:R:ResultText $fTermSomeExp $fLiftExp(->)$fLiftExp(->)0 $fLiftExp[]$fLiftExpVector$fLiftExpUTCTime$fLiftExpZonedTime$fLiftExpDatum$fLiftExpHashMap $fLiftExpText $fLiftExp[]0 $fLiftExpChar$fLiftExpDouble $fLiftExpInt $fLiftExpBool$fNumExp $fTermExp$fFromDatumSequence$fIsSequenceSequence$fFromResponseSequence$fShowSequence $fTermOrder#$fToDatumConflictResolutionStrategy$fIsObjectSingleSelection$fIsDatumSingleSelection$fIsSequenceTable $fTermUTCTime$fFromResponseUTCTime$fIsObjectUTCTime$fIsDatumUTCTime$fTermZonedTime$fFromResponseZonedTime$fIsObjectZonedTime $fTermHashMap$fFromResponseHashMap$fIsObjectHashMap$fIsDatumHashMap $fTermVector$fFromResponseVector$fIsSequenceVector $fTermText$fFromResponseText$fFromResponse[]$fFromResponseChar$fFromResponseInt $fTermDouble$fFromResponseDouble $fTermBool$fFromResponseBool$fFromResponseMaybe$fFromResponseDatum $fTermDatum$fIsDatumDatum $fTermValue recvMessage createSocket closeSocket sendMessagehandshakeMessagehandshakeReplyParser queryMessageresponseMessageParserhSocketGHC.MVarMVar hTokenRef Data.IORefatomicModifyIORefhError hResponseshReader hDatabaseresponseForTokensingleElementArray parseMessagemkError