packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/SpeechRecognitionErrorEventInit.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from speech-api (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.SpeechRecognitionErrorEventInit
       (js_newSpeechRecognitionErrorEventInit, js_setError, js_getError, js_setMessage, js_getMessage, newSpeechRecognitionErrorEventInit, setError, getError, setMessage, getMessage, getMessageUnsafe, getMessageUnchecked, SpeechRecognitionErrorEventInit(..), gTypeSpeechRecognitionErrorEventInit)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums

foreign import javascript safe "(($1) => { return ({\"error\": $1}); })"
        js_newSpeechRecognitionErrorEventInit :: JSVal -> IO SpeechRecognitionErrorEventInit
-- | <https://webaudio.github.io/web-speech-api/#dictdef-speechrecognitionerroreventinit SpeechRecognitionErrorEventInit specification>
newSpeechRecognitionErrorEventInit :: (MonadDOM m) => SpeechRecognitionErrorCode -> m SpeechRecognitionErrorEventInit
newSpeechRecognitionErrorEventInit error = liftDOM (((toJSVal error) >>= \a1' -> js_newSpeechRecognitionErrorEventInit a1'))

foreign import javascript safe "(($1, $2) => { $1[\"error\"] = $2; })"
        js_setError :: SpeechRecognitionErrorEventInit -> JSVal -> IO ()
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-error SpeechRecognitionErrorEventInit.error specification>
setError :: (MonadDOM m) => SpeechRecognitionErrorEventInit -> SpeechRecognitionErrorCode -> m ()
setError self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setError (self) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"error\"]; })"
        js_getError :: SpeechRecognitionErrorEventInit -> IO JSVal
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-error SpeechRecognitionErrorEventInit.error specification>
getError :: (MonadDOM m) => SpeechRecognitionErrorEventInit -> m SpeechRecognitionErrorCode
getError self = liftDOM (((js_getError (self)) >>= fromJSValUnchecked))

foreign import javascript safe "(($1, $2) => { $1[\"message\"] = $2; })"
        js_setMessage :: SpeechRecognitionErrorEventInit -> JSString -> IO ()
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-message SpeechRecognitionErrorEventInit.message specification>
setMessage :: (MonadDOM m, ToJSString val) => SpeechRecognitionErrorEventInit -> val -> m ()
setMessage self val = liftDOM (void ((js_setMessage (self) (toJSString val))))

foreign import javascript unsafe "(($1) => { return $1[\"message\"]; })"
        js_getMessage :: SpeechRecognitionErrorEventInit -> IO JSVal
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-message SpeechRecognitionErrorEventInit.message specification>
getMessage :: (MonadDOM m, FromJSString result) => SpeechRecognitionErrorEventInit -> m (Maybe result)
getMessage self = liftDOM (((fromMaybeJSString . Nullable) <$> (js_getMessage (self))))

-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-message SpeechRecognitionErrorEventInit.message specification>
getMessageUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => SpeechRecognitionErrorEventInit -> m result
getMessageUnsafe self = liftDOM ((((fromMaybeJSString . Nullable) <$> (js_getMessage (self))) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-message SpeechRecognitionErrorEventInit.message specification>
getMessageUnchecked :: (MonadDOM m, FromJSString result) => SpeechRecognitionErrorEventInit -> m result
getMessageUnchecked self = liftDOM ((pFromJSVal <$> (js_getMessage (self))))