packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SpeechRecognitionErrorEventInit.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from speech-api (webref). Do not edit.
module JSDOM.Generated.SpeechRecognitionErrorEventInit
       (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 Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://webaudio.github.io/web-speech-api/#dictdef-speechrecognitionerroreventinit SpeechRecognitionErrorEventInit specification>
newSpeechRecognitionErrorEventInit :: (MonadDOM m) => SpeechRecognitionErrorCode -> m SpeechRecognitionErrorEventInit
newSpeechRecognitionErrorEventInit error = liftDOM ((((new (jsg "Object") () >>= \o -> (o ^. jss "error" (toJSVal error)) P.>> P.return o)) >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-error SpeechRecognitionErrorEventInit.error specification>
setError :: (MonadDOM m) => SpeechRecognitionErrorEventInit -> SpeechRecognitionErrorCode -> m ()
setError self val = liftDOM (void (self ^. jss "error" (toJSVal val)))

-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitionerroreventinit-error SpeechRecognitionErrorEventInit.error specification>
getError :: (MonadDOM m) => SpeechRecognitionErrorEventInit -> m SpeechRecognitionErrorCode
getError self = liftDOM (((self ^. js "error") >>= fromJSValUnchecked))

-- | <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 (self ^. jss "message" (toJSVal val)))

-- | <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 (((self ^. js "message") >>= fromMaybeJSString))

-- | <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 ((((self ^. js "message") >>= fromMaybeJSString) >>= 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 (((self ^. js "message") >>= fromJSValUnchecked))