jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SpeechGrammarList.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.SpeechGrammarList
(newSpeechGrammarList, addFromString, item, item_, itemUnsafe, itemUnchecked, getLength, SpeechGrammarList(..), gTypeSpeechGrammarList)
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/SpeechGrammarList/SpeechGrammarList MDN SpeechGrammarList. documentation>
newSpeechGrammarList :: (MonadDOM m) => m SpeechGrammarList
newSpeechGrammarList = liftDOM (((new (jsg "SpeechGrammarList") ()) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/SpeechGrammarList/addFromString MDN SpeechGrammarList.addFromString documentation>
addFromString :: (MonadDOM m, ToJSString string) => SpeechGrammarList -> string -> Maybe Float -> m ()
addFromString self string weight = liftDOM (void (self ^. jsf "addFromString" [toJSVal string, P.maybe (P.return jsUndefined) toJSVal weight]))
-- | <https://developer.mozilla.org/docs/Web/API/SpeechGrammarList/item MDN SpeechGrammarList.item documentation>
item :: (MonadDOM m) => SpeechGrammarList -> Word -> m (Maybe SpeechGrammar)
item self index = liftDOM (((self ^. jsf "item" [toJSVal index]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/SpeechGrammarList/item MDN SpeechGrammarList.item documentation>
item_ :: (MonadDOM m) => SpeechGrammarList -> Word -> m ()
item_ self index = liftDOM (void (self ^. jsf "item" [toJSVal index]))
-- | <https://developer.mozilla.org/docs/Web/API/SpeechGrammarList/item MDN SpeechGrammarList.item documentation>
itemUnsafe :: (MonadDOM m, HasCallStack) => SpeechGrammarList -> Word -> m SpeechGrammar
itemUnsafe self index = liftDOM ((((self ^. jsf "item" [toJSVal index]) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/SpeechGrammarList/item MDN SpeechGrammarList.item documentation>
itemUnchecked :: (MonadDOM m) => SpeechGrammarList -> Word -> m SpeechGrammar
itemUnchecked self index = liftDOM (((self ^. jsf "item" [toJSVal index]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/SpeechGrammarList/length MDN SpeechGrammarList.length documentation>
getLength :: (MonadDOM m) => SpeechGrammarList -> m Word
getLength self = liftDOM ((P.round <$> ((self ^. js "length") >>= valToNumber)))