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
22
votes
2 answers

How to call Haskell from Javascript with GHCJS

I've been playing about with GHCJS. The FFI can be used to call javascript from Haskell but I can't figure out how do go the other way round. Say I had a super useful utility function I wrote in Haskell: sayHello :: String -> IO () sayHello name =…
Gareth Charnock
  • 1,166
  • 7
  • 17
19
votes
1 answer

Installing webkitgtk3 for GHCJS on osx

I'm trying to install the ghcjs-dom package on Mac OSX. It's been bumpy as there are a lot of dependencies. Webkitgtk3 is my current nemesis cabal install ghcjs-dom Resolving dependencies... Configuring webkitgtk3-0.14.1.1... Failed to install…
Mark Karavan
  • 2,654
  • 1
  • 18
  • 38
18
votes
1 answer

GHCJS: How do I import a high order javascript function using FFI?

How do I import in GHCJS a Javascript function like the following ? xs.subscribe(function(x) { console.log(x) }) I tried various combinations of the following without success: data Observable_ data Disposable_ type Observable a = JSRef…
Holoed
  • 643
  • 4
  • 15
17
votes
1 answer

Using Overloaded Strings

OverloadedStrings extension is really very useful, however it has some downsides. Consider the following function definition: someFunction :: ToJSSTring a => a -> IO () someFunction = js_function . toJSSTring In this case when if I want to pass a…
Geradlus_RU
  • 1,466
  • 2
  • 20
  • 37
16
votes
0 answers

Type safe RPC call example from GHCJS client to Yesod/Snap/Servant

I have two, related questions about RPC call to Yesod/Snap/Servant: Say I have a function on the server, written in Haskell, compiled by GHC: add x y = x+y+42 How can: I call this function from the client (the client is also written in Haskell,…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
14
votes
1 answer

Compiling Haskell module to Javascript using ghcjs

Is it possible to compile a Haskell module to JS using ghcjs? I played with it, but it seems it requires main function to be defined before it would generate JS. A toy code below: module Test where add :: Int -> Int -> Int add x y = x + y I can't…
Sal
  • 4,312
  • 1
  • 17
  • 26
12
votes
1 answer

Can GHCJS/Haste compile themselves?

If so, then I could let people play around with a project of mine by changing its (Haskell) configuration: recompiling it in the browser, and then rerunning it in the browser. I don't care about speed. I just want to be able to demo a hard-to-setup…
sam boosalis
  • 1,997
  • 4
  • 20
  • 32
11
votes
2 answers

Creating a Behavior for a continuously measurable phenomenon

I would like to create a Behavior t a from an IO a, with the intended semantics that the IO action would be run every time the behavior is sampled: {- language FlexibleContexts #-} import Reflex.Dom import Control.Monad.Trans onDemand ::…
Cactus
  • 27,075
  • 9
  • 69
  • 149
11
votes
2 answers

Running the Haskell compiled to JavaScript on the JVM

Java 8 has an inbuilt JavaScript engine called Nashorn so it is actually possible to run Haskell compiled to JavaScript on the JVM. The following program works: {-# LANGUAGE JavaScriptFFI #-} module Main where foreign import javascript unsafe…
Marimuthu Madasamy
  • 13,126
  • 4
  • 30
  • 52
10
votes
2 answers

Is it possible to run a game written in Haskell in the browser? (Through GHCJS maybe?)

I wonder if it is currently possible to write games in Haskell with Helm or any other engine that run on the browser through GHCJS?
Lay González
  • 2,901
  • 21
  • 41
8
votes
1 answer

Faster compilation for Haskell Miso

I use the Haskell Miso framework to write frontend web apps and the Nix compilation process takes a long time. How can I speed it up? Or what is the recommended approach to have a near instantaneous edit-compile-run cycle?
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
8
votes
1 answer

How to configure stack for most recent ghcjs / lts build

The stack docs gives example configurations for compiling with ghcjs https://docs.haskellstack.org/en/stable/ghcjs/ . But the latest example is with lts-7.19. I'd like to configure stack to use the latest ghcjs possible with the latest lts…
matchwood
  • 257
  • 1
  • 7
8
votes
1 answer

Most efficient wire format for GHCJS code over websockets

I am working on a Haskell application, running in the browser compiled with GHCJS, which communicates with a server, also written in Haskell, over websockets. Both programs share the same Haskell data type definition, and I “just” have to pick…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
8
votes
2 answers

Is it possible to server-side render Haskell frontend with Ghcjs, Haste, Elm, etc?

I think that Haskell offers fantastic features. Also suited for Web development. However, one feature I miss. Server-side rendering. The reasons are Google indexing crawlers and pre-rendering to increase performance on mobile devices. Is it possible…
Jakub Kříž
  • 89
  • 1
  • 6
8
votes
1 answer

GHCJS-DOM event guidance

I'm trying to understand how to create a GUI with GHCJS-DOM. I've been looking at the hello world example https://github.com/ghcjs/ghcjs-dom-hello, which is trivial. Adding new nodes is straightforward. What I can't do, and cannot work out from the…
OllieB
  • 1,431
  • 9
  • 14
1
2 3 4 5 6 7