-
Notifications
You must be signed in to change notification settings - Fork 6
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
Possible to remove dependency on ghcjs-base to compile on GHC? #10
Comments
It is likely possible to use |
Seems feasible to implement such a thing based on diagrams-canvas |
@mgsloan How would that work? Are there libraries that provide access to DOM APIs that abstract over |
Hmm, good point! |
What exactly in |
Can you explain what you are trying to do? Maybe I can suggest a way to do it with the existing Diagrams Backends. |
I think these should explain what I'm trying to achieve:
I guess these also explain why it's not possible to compile As a work around, I guess I could just use |
I wondering about the feasibility of writing a dummy fork of Without this, any users of e.g. ghc-mod with diagrams-ghcjs won't be able to benefit from e.g. typechecking in the editor. |
I think the stub library you describe is feasible. It seems annoying to maintain, and likely to confuse people, but that's just my opinion. A typical Diagrams program has lots of code that uses Diagrams, and only a little that uses the particular Backend. The easiest way to let the whole program typecheck with GHC is probably to CPP-guard the dia :: Diagram B V2 Double
dia = circle 1 # fc blue
renderCanvas :: IO ()
#ifdef GHCJS
renderCanvas = do
c <- getCanvasContext -- not a real function
renderDia D.Canvas (CanvasOptions (dims2D 200 200) c)
#else
renderCanvas = return ()
type B = NullBackend
-- diagrams-ghcjs provides type B = D.Canvas
#endif
The `Diagram B V2 Double` can be typechecked with just `diagrams-lib`. |
@eallik the last few weekends I have been working on a code generator for jsaddle-dom that will hopefully plug a lot of the gaps in the native version of ghcjs-dom. Instead of using the webkitgtk dom C functions it calls the JavaScriptCore C functions via jsaddle and webkitgtk3-javascriptcore. I am trying to keep the interface the same as ghcjs-dom. It also should make it easier to use JavaScript libraries in native apps. If it performs well enough we can make it the default implementation for ghcjs-dom on ghc. |
That's awesome! Where would it render though? Still webkitgtk? Or headless?
|
It will render using webkitgtk so we should be able to get diagrams-ghcjs fully working in ghc with webkitgtk rendering. diagrams-ghcjs uses ghcjs-base JavaScript.Web.Canvas and not ghcjs-dom CanvasRenderingContext2D. So we will need to resolve that somehow (perhaps a JavaScript.Web.Canvas compatibility layer). |
Sounds exactly perfect. Currently, that type in ghcjs-dom maps to nothing on GHC, because for some Do you intend to reproduce the full Canvas API via javascriptcore, so that
|
That is the plan. The interface will be complete, but some stuff may not work at run time (for instance I do not think webkitgtk comes with WebDB support). |
@hamishmack This sounds great. I'm happy to port |
@hamishmack: I'm thinking could it make sense to simply port parts of Currently GHCJS is really transmogrification plus libraries, but it could be just transmogrification, and the libraries could be cross platform and usable for any HTML/DOM/JS/WebKit/whatnot project, GHC or GHCJS. All this would also make sense even more should GHCJS be merged into GHC. |
If |
Is it feasible to remove the dependency on ghcjs-base, or make it optional? So that diagrams-ghcjs could also compile natively on GHC, to be used with e.g. webkitgtk.
The text was updated successfully, but these errors were encountered: