My experience with the ghcjs
and ghcjs-dom
documentation has been quite limited. Here is a simple example with basic HTML code:
h1 { font-family: Helvetica; }
p {font-family: Helvetica; color: blue; }
<h1>
Hello World
</h1>
<p>
This is my test document.
</p>
From what I've gathered, ghcjs
essentially compiles Haskell to JavaScript. To manipulate the DOM tree even with this simple document, one needs to use the Foreign Function Interface (FFI) and possibly incorporate ghcjs-dom
.
The terminology of calling it the "Foreign Function Interface" is somewhat ironic given that JavaScript is considered "native" to browsers. This leads to a bit of confusion in terms.
In this straightforward case,
Let's attempt a basic DOM manipulation example. I have a plain HTML document and I wish to * change the blue paragraph to red or * toggle between red and blue every second
If these simple tasks are not achievable using the ghcjs toolset, then how can it handle more complex challenges? There seems to be a gap in explaining these very fundamental scenarios. I have raised an issue on Github highlighting this lack of clarity and guidance: