Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/canvas/ canvas code sample does not compile (Windows 10, haste v0.6.0.0) #417

Open
trenttobler opened this issue Feb 17, 2018 · 1 comment

Comments

@trenttobler
Copy link

trenttobler commented Feb 17, 2018

Looks like some changes made from String to JSStr broke at least this example.

I was just exploring haste / client side javascript generation from Haskell, and encountered this. I've created a patch for the one example I was working on.

I am not sure if this is the correct fix, but compiles and runs. Chrome run-time error "Tainted canvases may not be exported" occurred, but did not seem to impact testability outside the developer console.

This also includes changes to fix obsolete warning, on the getCanvas function.

From 67bb04da057f07177bb9982cc6da4863f4be63ff Mon Sep 17 00:00:00 2001
From: Trent Tobler <trenttobler@gmail.com>
Date: Sat, 17 Feb 2018 16:26:05 -0500
Subject: [PATCH] Fixed warnings and errors for the canvas sample when compiled
 with 0.6.0.0 release.

---
 examples/canvas/canvas.hs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/examples/canvas/canvas.hs b/examples/canvas/canvas.hs
index a7142a5..4aabe6f 100644
--- a/examples/canvas/canvas.hs
+++ b/examples/canvas/canvas.hs
@@ -3,6 +3,7 @@ import Haste
 import Haste.DOM
 import Haste.Events
 import Haste.Graphics.Canvas
+import Haste.Prim
 import Data.IORef
 import Data.Array
 import Data.Array.MArray
@@ -69,14 +70,14 @@ main = do
   -- Setup: get the HTML element for a canvas, then proceed to create a canvas
   -- object from it.
   Just ce <- elemById "canvas"
-  Just c <- getCanvas ce
+  Just c <- fromElem ce
   
   -- Same for the canvas we're using as the tile "toolbox"
   Just tilemapElem <- elemById "tiles"
-  Just tiles <- getCanvas tilemapElem
+  Just tiles <- fromElem tilemapElem
   
   -- Load our tileset from a PNG file.
-  tileset <- loadBitmap "tileset.png"
+  tileset <- loadBitmap (toJSStr "tileset.png")
 
   -- The tile toolbox is a tilemap in itself.
   let allTiles = Tilemap {
@@ -126,4 +127,4 @@ drawEverything allTiles tiles c st = do
   render c $ scale (2, 2) $ do
     drawMap (tileMap st)
   Just dataurl <- elemById "dataurl"
-  toDataURL c >>= setProp dataurl "value"
+  toDataURL c >>= ( return . fromJSStr ) >>= setProp dataurl "value"
-- 
2.11.0.windows.1
@emmet-m
Copy link

emmet-m commented Jan 3, 2019

Same issue with me on Ubuntu 16.04, applying above changes fixed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants