jsaddle-dom-0.10.0.0: src/JSDOM/Generated/MIDIConnectionEventInit.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webmidi (webref). Do not edit.
module JSDOM.Generated.MIDIConnectionEventInit
(newMIDIConnectionEventInit, setPort, getPort, getPortUnsafe, getPortUnchecked, MIDIConnectionEventInit(..), gTypeMIDIConnectionEventInit)
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-midi-api/#dom-midiconnectioneventinit MIDIConnectionEventInit specification>
newMIDIConnectionEventInit :: (MonadDOM m) => m MIDIConnectionEventInit
newMIDIConnectionEventInit = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-midi-api/#dom-midiconnectioneventinit-port MIDIConnectionEventInit.port specification>
setPort :: (MonadDOM m, IsMIDIPort val) => MIDIConnectionEventInit -> val -> m ()
setPort self val = liftDOM (void (self ^. jss "port" (toJSVal val)))
-- | <https://webaudio.github.io/web-midi-api/#dom-midiconnectioneventinit-port MIDIConnectionEventInit.port specification>
getPort :: (MonadDOM m) => MIDIConnectionEventInit -> m (Maybe MIDIPort)
getPort self = liftDOM (((self ^. js "port") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-midi-api/#dom-midiconnectioneventinit-port MIDIConnectionEventInit.port specification>
getPortUnsafe :: (MonadDOM m, HasCallStack) => MIDIConnectionEventInit -> m MIDIPort
getPortUnsafe self = liftDOM ((((self ^. js "port") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://webaudio.github.io/web-midi-api/#dom-midiconnectioneventinit-port MIDIConnectionEventInit.port specification>
getPortUnchecked :: (MonadDOM m) => MIDIConnectionEventInit -> m MIDIPort
getPortUnchecked self = liftDOM (((self ^. js "port") >>= fromJSValUnchecked))