MicrosoftTranslator-0.1.0.1: Interface for Microsoft Translator

Safe HaskellNone
LanguageHaskell2010

Language.Bing

Synopsis

Documentation

data BingLanguage Source

The languages available for Microsoft Translatorj

Constructors

English 
German 
Norwegian 
Spanish 

checkToken :: MonadIO m => BingContext -> ExceptT BingError m BingContext Source

Check if the access token of the running BingAction is still valid. If the token has expired, renews the token automatically

evalBing :: MonadIO m => ClientId -> ClientSecret -> BingMonad m a -> m (Either BingError a) Source

Helper function that evaluates a BingMonad action. It simply requests and access token and uses the token for evaluation.

execBing :: MonadIO m => BingContext -> BingMonad m a -> m (Either BingError (a, BingContext)) Source

getAccessToken :: MonadIO m => ByteString -> ByteString -> ExceptT BingError m BingContext Source

Request a new access token from Azure using the specified client id and client secret

getBingCtx :: Monad m => BingMonad m BingContext Source

runBing :: BingMonad m a -> BingContext -> ExceptT BingError m a Source

runExceptT :: ExceptT e m a -> m (Either e a)

The inverse of ExceptT.

translate :: ClientId -> ClientSecret -> Text -> BingLanguage -> BingLanguage -> IO (Either BingError Text) Source

Toplevel wrapper that translates a text. It is only recommended if translation is invoked less often than every 10 minutes since it always requests a new access token. For better performance use translateM, runBing and getAccessToken

translateM :: MonadIO m => Text -> BingLanguage -> BingLanguage -> BingMonad m Text Source

Action that translates text inside a BingMonad context.