jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SpeechRecognitionEventInit.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.SpeechRecognitionEventInit
(newSpeechRecognitionEventInit, setResultIndex, getResultIndex, getResultIndexUnsafe, getResultIndexUnchecked, setResults, getResults, SpeechRecognitionEventInit(..), gTypeSpeechRecognitionEventInit)
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-speechrecognitioneventinit SpeechRecognitionEventInit specification>
newSpeechRecognitionEventInit :: (MonadDOM m) => SpeechRecognitionResultList -> m SpeechRecognitionEventInit
newSpeechRecognitionEventInit results = liftDOM ((((new (jsg "Object") () >>= \o -> (o ^. jss "results" (toJSVal results)) P.>> P.return o)) >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitioneventinit-resultindex SpeechRecognitionEventInit.resultIndex specification>
setResultIndex :: (MonadDOM m) => SpeechRecognitionEventInit -> Word -> m ()
setResultIndex self val = liftDOM (void (self ^. jss "resultIndex" (toJSVal val)))
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitioneventinit-resultindex SpeechRecognitionEventInit.resultIndex specification>
getResultIndex :: (MonadDOM m) => SpeechRecognitionEventInit -> m (Maybe Word)
getResultIndex self = liftDOM (((self ^. js "resultIndex") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitioneventinit-resultindex SpeechRecognitionEventInit.resultIndex specification>
getResultIndexUnsafe :: (MonadDOM m, HasCallStack) => SpeechRecognitionEventInit -> m Word
getResultIndexUnsafe self = liftDOM ((((self ^. js "resultIndex") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitioneventinit-resultindex SpeechRecognitionEventInit.resultIndex specification>
getResultIndexUnchecked :: (MonadDOM m) => SpeechRecognitionEventInit -> m Word
getResultIndexUnchecked self = liftDOM ((P.round <$> ((self ^. js "resultIndex") >>= valToNumber)))
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitioneventinit-results SpeechRecognitionEventInit.results specification>
setResults :: (MonadDOM m) => SpeechRecognitionEventInit -> SpeechRecognitionResultList -> m ()
setResults self val = liftDOM (void (self ^. jss "results" (toJSVal val)))
-- | <https://webaudio.github.io/web-speech-api/#dom-speechrecognitioneventinit-results SpeechRecognitionEventInit.results specification>
getResults :: (MonadDOM m) => SpeechRecognitionEventInit -> m SpeechRecognitionResultList
getResults self = liftDOM (((self ^. js "results") >>= fromJSValUnchecked))