ghcjs / diagrams-ghcjs

diagrams backend that renders directly to an HTML5 canvas
Other
23 stars 6 forks source link

Cannot compile tests #8

Closed ivanperez-keera closed 8 years ago

ivanperez-keera commented 8 years ago

The tests throw a lot of errors. They refer to an old JavaScript.Canvas module (is that JavaScript.Web.Canvas?) and the constraint:

 ( Renderable (Path R2) canvas
 , Renderable Text      canvas
 , Backend canvas R2
 ) => Diagram canvas R2

does not seem valid (?) because R2 is a type class.

I played around with it for some time but I just can't compile it. Help updating the example would be appreciated.

bergey commented 8 years ago

I'm sorry about that. The tests are a couple of years old. Diagrams has changed a lot, and GHCJS even more so. I'm not sure when I'll have time to get them working again.

In the meantime, any of the examples in the Diagrams manual should work. My GHCJS examples page has two examples of using Diagrams with GHCJS, near the bottom of the page.

ivanperez-keera commented 8 years ago

Thanks for the link to your examples. I was able to make the canvas example work with some minor modifications. I created a modified version of haskanoid and put it online.

bergey commented 8 years ago

Thank you for sharing those! The arkanoid is exciting. Would you mind sending me a pull request with the changes needed for the canvas example?

ivanperez-keera commented 8 years ago

There is only one tiny problem: I had to modify one of ghcjs's libraries to expose the canvas constructor. I did it using unsafeToCanvas, but that is just Canvas (data constructor). On the one hand, flagging all canvas-related code as unsafe may not sound very appealing. On the other, there are reasons to hide internal constructors.

Which one would be best in this case?

bergey commented 8 years ago

There's an open PR to export unsafeToCanvas. As far as I know, no one has yet implemented toCanvas; the current version is a placeholder. What would be best is to implement toCanvas, but I think in the short term, it's fine to use unsafeToCanvas and depend on a version of ghcjs-base that exports it.

bergey commented 8 years ago

Looking at ghcjs-base a bit more, I found that we can use coerce on Canvas. I just updated the example in this repo to do it this way.

Would you verify that with the changes I just pushed, the tests build? If so, I think we can close this issue.