Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data BingLanguage
- data BingError = BingError ByteString
- type ClientId = ByteString
- type ClientSecret = ByteString
- checkToken :: BingContext -> ExceptT BingError IO BingContext
- evalBing :: ClientId -> ClientSecret -> BingMonad a -> IO (Either BingError a)
- getAccessToken :: ByteString -> ByteString -> ExceptT BingError IO BingContext
- runBing :: BingMonad a -> BingContext -> ExceptT BingError IO a
- translate :: ClientId -> ClientSecret -> Text -> BingLanguage -> BingLanguage -> IO (Either BingError Text)
- translateM :: Text -> BingLanguage -> BingLanguage -> BingMonad Text
Documentation
data BingLanguage Source
The languages available for Microsoft Translatorj
type ClientId = ByteString Source
type ClientSecret = ByteString Source
checkToken :: BingContext -> ExceptT BingError IO BingContext Source
Check if the access token of the running BingAction is still valid. If the token has expired, renews the token automatically
evalBing :: ClientId -> ClientSecret -> BingMonad a -> IO (Either BingError a) Source
Helper function that evaluates a BingMonad action. It simply requests and access token and uses the token for evaluation.
getAccessToken :: ByteString -> ByteString -> ExceptT BingError IO BingContext Source
Request a new access token from Azure using the specified client id and client secret
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 :: Text -> BingLanguage -> BingLanguage -> BingMonad Text Source
Action that translates text inside a BingMonad context.