Closed spl closed 7 years ago
Oh, this is great. Thanks!
Hmmm, this isn't working. I'm getting this error:
src/Reflex/Dom/SemanticUI/Dropdown.hs:41:1: error:
parse error (possibly incorrect indentation or mismatched brackets)
Not sure what's going on.
Is the error where the FOREIGN_IMPORT macro is? What is your C compiler?
Yeah, it's the FOREIGN_IMPORT. I'm running on Mac OS X. Here's the output of gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I think it might be a difference in the clang CPP from gcc. My guess is that it doesn't handle a multi-line macro application. I'll try it out in a bit.
Well, I can't currently get it working on the Mac. Do you have GHCi working? That is, since ghcjs-dom
in GHC needs gtk2hs
, did you get that working on the Mac? I haven't tried GHCJS on the Mac, yet. I do most of my development in a Linux VM on the Mac.
For the moment, can you check if this solution will work? Change
FOREIGN_IMPORT(A
B,
C,
D)
to
FOREIGN_IMPORT(A, B, C, D)
for all A
, B
, C
, D
.
I use reflex-platform to build on Mac with GHCJS. I describe how to do that in the README.
https://github.com/reflex-frp/reflex-dom-semui/blob/master/README.md
Ok, it looks like putting them on a single line works. I thought I tried that before and it didn't work, but I guess I was mistaken.
Ok, it looks like putting them on a single line works.
Great!
I use reflex-platform to build on Mac with GHCJS.
Right. But you're not using anything to build with GHC?
Right. But you're not using anything to build with GHC?
No. To my knowledge that can't be done until someone gets webkitgtk to build on nix in OS X.
@mightybyte I believe webkitgtk is working on current reflex-platform on OS X.
Oh nice. I'll have to give it a try.
Indeed it is. Nice!
I think this change is a step in the wrong direction. There was a natural place in the old code to add a GHC native implementation using JSaddle (or something else if prefered), but now it is gone.
@hamishmack Interesting. I'm not familiar with JSaddle. Could you provide an link to an example or perhaps snippet/pull request demonstrating how it would work in this library?
I'm not familiar with JSaddle.
https://github.com/ghcjs/jsaddle#jsaddle
Could you provide an link to an example or perhaps snippet/pull request demonstrating how it would work in this library?
Here is getElementById
from ghcjs-dom
(well from jsaddle-dom
which is used by the latest ghcjs-dom
when compiled with GHC)
getElementById ::
(MonadDOM m, IsDocument self, ToJSString elementId) =>
self -> elementId -> m (Maybe Element)
getElementById self elementId
= liftDOM
(((toDocument self) ^. jsf "getElementById" [toJSVal elementId])
>>= fromJSVal)
The JSaddle implementation of the function would look something like that. For more examples see https://github.com/ghcjs/jsaddle-dom/tree/master/src/JSDOM/Generated.
I am working on a port of reflex-dom
to the latest ghcjs-dom
which should be ready to try out soon. The ghcjs-dom version reflex currently uses is quite old and would not be easy to get the JSContextRef
needed to run JSaddle code on GHC (but not on GHCJS). But once the port is done everything will be running in DOM
(which is just IO
in ghcjs-dom-jsffi and JSM
in ghcjs-dom-jsaddle).
The
FOREIGN_IMPORT()
macro makes it really easy to declare foreign import that works in GHCJS and compiles in GHC.The compatibility module
GHCJS.Compat
hides the GHC stubs and cleans up the main code.