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

Performant decoding of json values in GHCJS using Aeson

I found a weird behaviour while decoding a JSON list into a native [(UTCTime, Double)]. The operation takes around 2 seconds for lists with 3K elements. I've been digging into the browser's performance report but I couldn't find a clear culprit. I…
Jesuspc
  • 1,664
  • 10
  • 25
3
votes
1 answer

Using custom ghcjs fork with stack

I'm testing some of my own patches to ghcjs, and I was wondering how I can package it up to use with stack's fields, which seem to expect something like: setup-info: ghcjs: source: ghcjs-0.2.1.9007019_ghc-8.0.1: url:…
Justin L.
  • 13,510
  • 5
  • 48
  • 83
3
votes
1 answer

GHCJS Text Data Constructor

I am using nix with reflex platform to compile haskell to javascript with GHCJS 8.0.1. I have written some functions that rely on an internal module in the text library: Data.Text.Internal. The only thing I need from this is the data constructor for…
3
votes
1 answer

Representing timestamps

I would like to represent the timestamp coming from an HTMLMediaElement. Its defining characteristics are: Its value is represented as a Double It can be queried at any time using getCurrentTime :: IO Double (as partially applied on a given…
Cactus
  • 27,075
  • 9
  • 69
  • 149
3
votes
0 answers

Accessing the WebKit API from Haskell via something other than WebKitGTK

I'm trying to understand if there is any other way to access the WebKit API directly from from a Haskell (ghc-7.10.2 currently) program without having to go through something like webkitgtk3, which is a Haskell wrapper around WebKitGTK. It appears…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
3
votes
1 answer

How do I do multiline foreign imports with ghcjs?

How do I do multiline foreign imports in GHCJS? I have a block of javascript that stretches over multiple lines: foreign import javascript unsafe "{ var x = 41;\ \ $r = x + 1; \ \}" answerToGreatestQuestion :: IO (JSRef Double) And I get…
pchiusano
  • 775
  • 5
  • 12
2
votes
1 answer

manage events in Haskell

I'm currently working with GHCJS.DOM/JSDOM in Haskell with the aim of create a small web application. In order to capture the event "click on a button" I write the following code: releaseAction <- on element click $ do w <-…
2
votes
1 answer

Haskell GHCJS with Diagrams gives error: no C compiler provided for this platform

I am trying to build a POC, using Reflex and Diagrams. I am using WSL2 with Ubuntu-20.04. I've used the Reflex-stone template, which builds fine. I then add diagrams-lib to the dependency list, and get this…
Chris Wohlert
  • 610
  • 3
  • 12
2
votes
1 answer

Compiling Haskell to JavaScript using GHCJS and Haskell Stack

How can Haskell be compiled to Javascript using GHCJS and Haskell Stack? I have the current version of Haksell Stack 1.5.1. I can initialize a GHCJS project with this command: stack new ghcjsSetup ghcjs Once in the project directory I try following…
user8876236
  • 105
  • 5
2
votes
1 answer

Installing reflex-dom likely to break ghcjs

I am trying to install reflex and reflex-dom using cabal install I got the following error messages: $ cabal install reflex-dom ... cabal: The following packages are likely to be broken by the…
john mangual
  • 7,718
  • 13
  • 56
  • 95
2
votes
0 answers

How to use haskell stack 1.2, nix, and ghcjs

When I try to build this repo with the latest version of stack: λ ~/repos/ghcjs-typeahead/src/Typeahead/ master* stack --version ~/repos/ghcjs-typeahead/src/Typeahead Version 1.2.0 x86_64 I get this error: λ…
Kyle McKean
  • 445
  • 2
  • 11
2
votes
0 answers

Wrapping JavaScript FFI in Either

I am very new to JavascriptFFI and will very much appreciate help here. I have a working javascript code to grab image as FILE URI from camera (via cordova camera plugin). Now, it can return either error or file uri on success. We want to map them…
Sal
  • 4,312
  • 1
  • 17
  • 26
2
votes
2 answers

How to convert list to JSVal?

I'm trying to build JS FFI for some JS library to get it work with GHCJS and I need to convert list to single JSVal listToJSVal :: PToJSVal a => [a] -> JSVal listToJSVal = map pToJSVal but get error Couldn't match type ‘[JSVal]’ with ‘JSVal’ …
sigrlami
  • 1,822
  • 1
  • 17
  • 35
2
votes
1 answer

Is it possible GHCJS to reuse code generated by Template Haskell

At this moment GHCJS fails to compile postgresql-simple package (see [1]). I want to use persistent package to generate DB models. I wonder is it possible to compile models with GHC itself and re-use code generated by Template Haskell in GHCJS…
Geradlus_RU
  • 1,466
  • 2
  • 20
  • 37
2
votes
1 answer

Does ghc-mod support ghcjs?

As of May 2016, does ghc-mod support projects compiled with ghcjs? I realise that in a lot of cases, the source is the same, but this is not the case when working with ghcjs-dom library. I currently have 2 project folders, configured with stack.…
OllieB
  • 1,431
  • 9
  • 14