packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SpeechRecognitionEvent.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.SpeechRecognitionEvent
       (newSpeechRecognitionEvent, getResultIndex, getResults, SpeechRecognitionEvent(..), gTypeSpeechRecognitionEvent)
       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://developer.mozilla.org/docs/Web/API/SpeechRecognitionEvent/SpeechRecognitionEvent MDN SpeechRecognitionEvent. documentation>
newSpeechRecognitionEvent :: (MonadDOM m, ToJSString type') => type' -> SpeechRecognitionEventInit -> m SpeechRecognitionEvent
newSpeechRecognitionEvent type' eventInitDict = liftDOM (((new (jsg "SpeechRecognitionEvent") [toJSVal type', toJSVal eventInitDict]) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechRecognitionEvent/resultIndex MDN SpeechRecognitionEvent.resultIndex documentation>
getResultIndex :: (MonadDOM m) => SpeechRecognitionEvent -> m Word
getResultIndex self = liftDOM ((P.round <$> ((self ^. js "resultIndex") >>= valToNumber)))

-- | <https://developer.mozilla.org/docs/Web/API/SpeechRecognitionEvent/results MDN SpeechRecognitionEvent.results documentation>
getResults :: (MonadDOM m) => SpeechRecognitionEvent -> m SpeechRecognitionResultList
getResults self = liftDOM (((self ^. js "results") >>= fromJSValUnchecked))