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
7
votes
1 answer

Turning requestAnimationFrame into an Event t ()

Using Reflex-DOM, I'd like to make an Event t () that fires when the browser is ready to paint the next frame, i.e. when requestAnimationFrame fires. I tried it like this: {-# LANGUAGE RecursiveDo, TypeFamilies #-} import Reflex.Dom import…
Cactus
  • 27,075
  • 9
  • 69
  • 149
7
votes
0 answers

How can I reduce (incremental) compilation times with ghcjs?

I have a small project using ghcjs, which currently has a best-case incremental recompilation time of 8 seconds, for a measly 637 lines of source code (as counted by find -L . -name '*.hs' | xargs wc -l | grep total). The worst offender is the final…
ajp
  • 1,723
  • 14
  • 22
7
votes
2 answers

XhrRequest with reflex/reflex-dom

I want to perform a basic Ajax request, that's all. I use reflex for the frontend and Scotty for the backend. The Firefox Web Console tells me the request was a success and I see the expected result there. But the website switches from Just…
somesoaccount
  • 1,267
  • 15
  • 37
7
votes
1 answer

How can this Haskell program, compiled to JavaScript, be faster than JavaScript itself?

I always believed GHCJS, for obvious reasons, generated very slow JavaScript programs, compared to manually written and optimized code. When experimenting with it, though, I noticed it was not as bad as I expected. I decided to run a series of small…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
7
votes
1 answer

Too many variables to run GHCJS program with Node

I'm trying to run a program built with GHCJS using node.js. However, I get the following error: SyntaxError: Too many variables declared (only 131071 allowed) at Module._compile (module.js:439:25) at Object.Module._extensions..js…
jmite
  • 8,171
  • 6
  • 40
  • 81
6
votes
1 answer

install ghcjs from stack

I have GHC installed through stack ( so that stack ghc -- --version shows GHC-7.10.3 ) $ stack install ghcjs Run from outside a project, using implicit global project config Using resolver: lts-5.2 from implicit global project's config file:…
john mangual
  • 7,718
  • 13
  • 56
  • 95
6
votes
2 answers

How to execute an action periodically in a GHCJS program?

Should one use setInterval via Javascript, or use some more idiomatic solution based on threads?
danza
  • 11,511
  • 8
  • 40
  • 47
6
votes
0 answers

ghcjs + sodium: no events after some time

UPDATE: there is a issue in ghcjs: https://github.com/ghcjs/ghcjs/issues/296 i play with ghcjs and sodium but after 3 seconds my application doesn't emit events anymore. a minimal example: a button: emit events a counter behavior: counts the…
j-keck
  • 1,021
  • 1
  • 7
  • 13
5
votes
1 answer

Initializing a new GHCJS project using the Haskell Tool Stack

What do I need to do to initialize a GHCJS project using Haskell Stack? Following the stack documentation I am trying to initialize a GHCJS project so that I can compile Haskell code to JavaScript. After doing stack templates I see there is a GHCJS…
user8876236
  • 105
  • 5
5
votes
1 answer

ccall import of emscripten export in GHCJS

I'm trying to port the haskell library minisat to JavaScript using ghcjs, for integration in a larger haskell-ghcjs project. minisat contains a couple of ffi imports from a c library. I've manged to compile the c library to javascript using…
5
votes
0 answers

How does getCurrentTime work under GHCJS?

Under GHCJS, how does getCurrentTime work? In the time library itself, this is implemented using the FFI, calling out to functions provided by the operating system. However, there aren't any lines in time that start with: foreign import javascript…
5
votes
1 answer

Using javascript libraries from Haskell

I am fairly new to Haskell. Recently, I heard about this compiler called GHCJs where you can write code in Haskell which can then be compiled to Javascript. I am interested in using libraries such as three.js and webgl for making cool interactive…
smilingbuddha
  • 14,334
  • 33
  • 112
  • 189
5
votes
0 answers

How to convert an `IO ()` to `JSVal` in GHCJS

i want to execute some effectful computation on a regular basis in a program compiled with GHCJS, but GHCJS.DOM.WindowTimers.setInterval wants a JSVal as parameter. Could anybody give me some pointers for turning my IO () into a JSVal? Edit: I was…
danza
  • 11,511
  • 8
  • 40
  • 47
5
votes
1 answer

Why does this Reflex code result in Dynamics firing indefinitely with the same value?

The intent of this small program is to show three buttons, with the third button's label initially being "0" and afterwards being the index of the last-clicked button. For now the number of buttons and the labels of the other buttons are…
ajp
  • 1,723
  • 14
  • 22
5
votes
1 answer

Am I using ghcjs correctly?

I'm quite new to Haskell and ghcjs. I'm starting with the very first "Hello, world!" program to learn. Here is my Haskell program, copied from GHCJS wiki: module Main where main = putStrLn "Hello world!" I use the command ghcjs -o hello hello.hs to…
Yiyue Wang
  • 152
  • 1
  • 12