Questions tagged [ghcjs]

GHCJS is a Haskell to JavaScript compiler using the GHC API.

GHCJS is a Haskell to JavaScript compiler using the GHC API that supports many modern Haskell features, including:

  • All type system extensions supported by GHC
  • Lightweight preemptive threading with blackholes, MVar, STM, asynchronous exceptions
  • Weak references, CAF deallocation, StableName, StablePtr
  • Unboxed arrays, emulated pointers
  • Integer support through JSBN
  • Cabal support, GHCJS has its own package database
101 questions
5
votes
1 answer

How to use two different compilers for different targets in a .cabal file?

When I run cabal build it uses some Haskell compiler to build the executables and/or test-suites in my .cabal file. Can I control which compiler is used for the different targets? Ideally, I would like to have separate build targets that use ghc and…
ryantm
  • 8,217
  • 6
  • 45
  • 57
4
votes
0 answers

Can't get `dispatchEvent` to fire in GHCJS

The goal is to get window.addEventListener("popstate", ... to fire from an event dispatched from GHCJS code. Tried so far GHCJS.DOM doesn't work w <- currentWindowUnchecked e <- newPopStateEvent "popstate" Nothing dispatchEvent_ w…
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164
4
votes
3 answers

How to convert a ByteString value to a JSVal

In the module GHCJS.DOM.JSFFI.Generated.CanvasRenderingContext2D there is the function putImageData with the following type: putImageData :: Control.Monad.IO.Class.MonadIO m => CanvasRenderingContext2D -> Maybe GHCJS.DOM.Types.ImageData ->…
Jogger
  • 1,617
  • 2
  • 12
  • 22
4
votes
1 answer

How do you convert from an Unboxed Vector to a JS TypedArray on GHCJS?

I have an element of type Data.Vector.Unboxed.Vector Word32. I want to convert that to a native JS TypedArray (an Uint32Array, specifically). I'm aware of toJsArray and toJsValListOf, but both functions deal with lists, not vectors, and are…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
4
votes
1 answer

Lens not found when compiling sample program with GHCJS

I get this error: aff.hs:3:8: Could not find module ‘Control.Lens’ Perhaps you haven't installed the "js" libraries for package ‘lens-4.7’? Use -v to see a list of the files searched for. When compiling this file with ghcjs aff.hs: {-#…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
4
votes
0 answers

Triggering a JavaScript import/require from GHCJS FFI bindings

I'll use a Famo.us example as the starting point: var Engine = require("famous/core/Engine"); // or just var Engine = famous.core.Engine; var Surface = require("famous/core/Surface"); var ctx = Engine.createContext(); ctx.add(new…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
4
votes
1 answer

Locating Javascript libraries for FFI

I am digging through ghcjs-jquery code to see how JavascriptFFI works. What I am trying to figure out is that once you define FFI import type signature for a JS function, how do you help ghcjs locate the file containing the function. Checking…
Sal
  • 4,312
  • 1
  • 17
  • 26
4
votes
1 answer

Can I read files in GHCJS?

HTML5 introduced a standard file API. Does GHCJS give access to that? Can I use the standard Haskell IO facilities in System.IO?
Tobias Brandt
  • 3,393
  • 18
  • 28
3
votes
2 answers

How to install ghcjs 8.8 or 8.10?

I would like to produce an HTML / JS page with reflex-dom (only client side, frontend). However, I use the singletons package (2.6) and it seems that it cannot be compiled with ghcjs or ghc 8.6.5 (singletons 2.5.1, broken-unpatched). Therefore, the…
3
votes
1 answer

Is there a way to see the compile times of each module?

I've searched the ghc user manual to the best of my ability, but I haven't been able to find a way to have ghc print the timings of each module as it is compiled.
David Fox
  • 654
  • 4
  • 10
3
votes
0 answers

How to get the global keydown event in Reflex?

My current attempt at getting an event of global keypress (eg: user hits a keyboard shortcut, from anywhere in the UI, to trigger opening of modal dialog) is: prerender_ blank $ do -- ctx <- askJSM doc <- currentDocumentUnchecked win…
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
3
votes
0 answers

Using Web Component HTML tags with reflex

I try to use Web Components in Reflex. Code is as such: buttonUI5 :: DomBuilder t m => T.Text -> m (Event t ()) buttonUI5 t = do (e, _) <- element "ui5-button" def $ text t return $ domEvent Click e For ui5-button it worked as expected. Other…
3
votes
2 answers

How do immutable languages like ClojureScript, Elm, PureScript, GHCJS compile to mutable javascript?

I think burying to the listed languages' source code is too much for me. But is there anyone able to explain in simple terms how does the thing happens? I mean, in the end immutable data will still be javascript's data. Or is compiled code contains…
Nurbol Alpysbayev
  • 19,522
  • 3
  • 54
  • 89
3
votes
1 answer

How can I use ghci with my reflex project using only stack.yaml?

I've removed nix from my reflex project, having replaced it with stack. Everything is good, except being able to use the repl. I've tried to create a minimal reflex project to demonstrate what I have tried, and the errors my attempt…
user1198582
3
votes
1 answer

Stack GHCJS project initaliziation error when building a docker image

I am trying to create a docker image to be a GHCJS development environment. I am getting an error on this line of the Dockerfile which is to initialize a GHCJS template project using stack: RUN stack new helloWorld ghcjs The entire Dockerfile…
user8876236
  • 105
  • 5