Skip to content

Instantly share code, notes, and snippets.

@et4te
Created October 7, 2015 18:19
Show Gist options
  • Select an option

  • Save et4te/314a73f5047ead28418f to your computer and use it in GitHub Desktop.

Select an option

Save et4te/314a73f5047ead28418f to your computer and use it in GitHub Desktop.
Line 24 is where I am confused
mkCanvas' :: CanvasInfo -> IO (OCanvasRef)
mkCanvas' cnvInfo = do
cnvObj <- toJSRef cnvInfo
cnvRef <- js_create cnvObj
js_setWidth cnvRef (toJSInt $ width cnvInfo)
js_setHeight cnvRef (toJSInt $ height cnvInfo)
return cnvRef
mkCanvas :: (MonadWidget t m) => Event t CanvasInfo -> m (Event t OCanvasRef)
mkCanvas cnvInfoE = do
performEvent $ fmap (liftIO . mkCanvas') cnvInfoE
canvasDisplay' :: OCanvasRef -> ImageInfo -> IO (OImageRef)
canvasDisplay' cnvRef imgInfo = do
imgInfoRef <- toJSRef imgInfo
imgRef <- js_display cnvRef imgInfoRef
return imgRef
canvasDisplay :: (MonadWidget t m) => Event t OCanvasRef -> Dynamic t ImageInfo -> m (Event t OImageRef)
canvasDisplay cnvRefE imgInfoD = do
cnvRefD <- foldDynMaybe notNull jsNull cnvRefE
let cnvImgE = attachDyn cnvRefD (updated imgInfoD)
performEvent $ fmap (liftIO . canvasDisplay') cnvImgE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment