textocat-api-0.1.0.0: Unofficial Haskell SDK for Textocat API -- http://textocat.com

Copyright(c) Mansur Ziatdinov, 2014--2015
LicenseApache-2.0
Maintainermz+textocat-api@fosslabs.ru
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Network.Textocat.Monadic

Contents

Description

There are two kind of functions in this module. Functions that have apostrophe in their names send data to server every time you call them. Functions without them call server only if necessary (e.g. you requested it)

This monadic interface is experimental. If you know how to improve it, please contact author

Synopsis

Monad wrappers

General monad transformer

data TextocatM m a

TextocatM is a monad transformer to use Textocat API over some monad m and return result a

Instances

MonadTrans TextocatM 
(Functor m, MonadIO m) => Monad (TextocatM m) 
Functor m => Functor (TextocatM m) 
(Functor m, Monad m) => Applicative (TextocatM m) 
(Functor m, MonadIO m) => MonadIO (TextocatM m) 

runTextocatM

Arguments

:: (Functor m, MonadIO m) 
=> ByteString

API key

-> TextocatM m a

TextocatM action

-> m a 

Executes TextocatM actions with given API key

Monad over IO

runTextocat

Arguments

:: ByteString

API key

-> Textocat a

Textocat action

-> IO a 

Executes Textocat actions with given API key

API operations with explicit calls

queue' :: (Functor m, MonadIO m) => [Document] -> TextocatM m [Either ErrorMsg BatchStatus]

Queues documents. Actually, makes call to entityQueue with collections divided by 50 documents at most

request'

Arguments

:: (Functor m, MonadIO m) 
=> BatchID

Batch

-> TextocatM m (Either ErrorMsg BatchStatus) 

Requests batch status

retrieve'

Arguments

:: (Functor m, MonadIO m) 
=> [BatchID]

Batches

-> TextocatM m (Either ErrorMsg Batch) 

Retrieves batches

search'

Arguments

:: (Functor m, MonadIO m) 
=> Text

Search query

-> TextocatM m (Either ErrorMsg SearchResult) 

Search all collections

status :: (Functor m, MonadIO m) => TextocatM m ServiceStatus

Check service status

Helpers

wait' :: (Functor m, MonadIO m) => BatchID -> TextocatM m ()

Waits while batch processing is finished

API operations with implicit calls

queue

Arguments

:: (Functor m, MonadIO m) 
=> [Document]

Documents to queue

-> TextocatM m () 

Queues given documents. No requests go to server until force, request of retrieve is called

queue1

Arguments

:: (Functor m, MonadIO m) 
=> Document

Document to queue

-> TextocatM m () 

Queues single document. No requests go to server until force, request of retrieve is called

force :: (Functor m, MonadIO m) => TextocatM m [Either ErrorMsg BatchStatus]

Actually sends documents that were added by queue and queue1 calls to the API server. If there are more than 50 documents, they will be sent in several calls, each call will have 50 document at most (API limitation)

request :: (Functor m, MonadIO m) => TextocatM m [Either ErrorMsg BatchStatus]

Request all documents that were added by queue and queue1 calls. Can create several batches, if there are more than 50 documents

retrieve :: (Functor m, MonadIO m) => TextocatM m [Either ErrorMsg Batch]

Retrieve all documents that were added by queue and queue1 calls. Can create several batches, if there are more than 50 documents. Blocks until processing of all batches is finished