packages feed

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

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from fs (webref). Do not edit.
module JSDOM.Generated.WriteParams
       (newWriteParams, setType, getType, setSize, getSize, getSizeUnsafe, getSizeUnchecked, setPosition, getPosition, getPositionUnsafe, getPositionUnchecked, setData, getData, getDataUnsafe, getDataUnchecked, WriteParams(..), gTypeWriteParams)
       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://fs.spec.whatwg.org/#dictdef-writeparams WriteParams specification>
newWriteParams :: (MonadDOM m) => WriteCommandType -> m WriteParams
newWriteParams type' = liftDOM ((((new (jsg "Object") () >>= \o -> (o ^. jss "type" (toJSVal type')) P.>> P.return o)) >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-type WriteParams.type specification>
setType :: (MonadDOM m) => WriteParams -> WriteCommandType -> m ()
setType self val = liftDOM (void (self ^. jss "type" (toJSVal val)))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-type WriteParams.type specification>
getType :: (MonadDOM m) => WriteParams -> m WriteCommandType
getType self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-size WriteParams.size specification>
setSize :: (MonadDOM m) => WriteParams -> Maybe Word53 -> m ()
setSize self val = liftDOM (void (self ^. jss "size" (toJSVal val)))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-size WriteParams.size specification>
getSize :: (MonadDOM m) => WriteParams -> m (Maybe Word53)
getSize self = liftDOM (((self ^. js "size") >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-size WriteParams.size specification>
getSizeUnsafe :: (MonadDOM m, HasCallStack) => WriteParams -> m Word53
getSizeUnsafe self = liftDOM ((((self ^. js "size") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-size WriteParams.size specification>
getSizeUnchecked :: (MonadDOM m) => WriteParams -> m Word53
getSizeUnchecked self = liftDOM (((self ^. js "size") >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-position WriteParams.position specification>
setPosition :: (MonadDOM m) => WriteParams -> Maybe Word53 -> m ()
setPosition self val = liftDOM (void (self ^. jss "position" (toJSVal val)))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-position WriteParams.position specification>
getPosition :: (MonadDOM m) => WriteParams -> m (Maybe Word53)
getPosition self = liftDOM (((self ^. js "position") >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-position WriteParams.position specification>
getPositionUnsafe :: (MonadDOM m, HasCallStack) => WriteParams -> m Word53
getPositionUnsafe self = liftDOM ((((self ^. js "position") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-position WriteParams.position specification>
getPositionUnchecked :: (MonadDOM m) => WriteParams -> m Word53
getPositionUnchecked self = liftDOM (((self ^. js "position") >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-data WriteParams.data specification>
setData :: (MonadDOM m, IsBlobPart val) => WriteParams -> Maybe val -> m ()
setData self val = liftDOM (void (self ^. jss "data" (toJSVal val)))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-data WriteParams.data specification>
getData :: (MonadDOM m) => WriteParams -> m (Maybe BlobPart)
getData self = liftDOM (((self ^. js "data") >>= fromJSValUnchecked))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-data WriteParams.data specification>
getDataUnsafe :: (MonadDOM m, HasCallStack) => WriteParams -> m BlobPart
getDataUnsafe self = liftDOM ((((self ^. js "data") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://fs.spec.whatwg.org/#dom-writeparams-data WriteParams.data specification>
getDataUnchecked :: (MonadDOM m) => WriteParams -> m BlobPart
getDataUnchecked self = liftDOM (((self ^. js "data") >>= fromJSValUnchecked))