ghcjs-base-stub: Allow GHCJS projects to compile under GHC and develop using intero.

[ bsd3, library, web ] [ Propose Tags ]

Allow GHCJS projects to compile under GHC and develop using intero. Please refer to README.md.


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.2.0.0, 0.3.0.1, 0.3.0.2 (info)
Change log changelog.md
Dependencies aeson (>=0.8), attoparsec (>=0.11), base (>=4.7 && <5), binary (>=0.8), bytestring (>=0.10), containers (>=0.5), deepseq (>=1.3), dlist (>=0.7), ghc-prim, ghcjs-prim, hashable (>=1.2), integer-gmp, primitive (>=0.5), scientific (>=0.3), text (>=1.1), time (>=1.5), transformers (>=0.3), unordered-containers (>=0.2), vector (>=0.10) [details]
License BSD-3-Clause
Copyright 2019 Louis Pan
Author Louis Pan
Maintainer louis@pan.me
Category Web
Home page https://github.com/louispan/javascript-stub#readme
Source repo head: git clone https://github.com/louispan/ghcjs-base-stub
Uploaded by louispan at Fri Oct 11 23:30:07 UTC 2019
Distributions NixOS:0.3.0.2
Downloads 2509 total (82 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-10-11 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for ghcjs-base-stub-0.3.0.1

[back to package description]

Hackage Build Status

Motivation

Javascript projects using GHCJS must use ghcjs-base, which cannot be compiled by GHC as it requires JavaScriptFFI. This package is is drop-in-replacement (same type signature, module namespace) for ghcjs-base that can be compiled in GHC.

When using GHCJS to compile, the original modules from ghjs-base is exported.

When using GHC to compile, fake stubs are emitted for all the ghcjs-base javascript functions, so this is not meant for production use with GHC.

However, this will allow tooling (such as intero, generating haddocks) to use the much faster GHC to compile GHCJS projects.

Prod GHC use case

For project that need to compile to both GHC and GHCJS for production, consider using jsaddle, which compiles to ghcjs-dom under GHC. However, the type signatures will change as the the IO monad becomes the JSM monad.

Usage

In your project cabal file, instead of using ghcjs-base, use ghcjs-base-stub

build-depends: ghcjs-base-stub

Version 0.1.x.x of ghjc-base-stub did not re-export the original ghcjs-base when compiling under GHCJS. Version 0.2.x.x re-exports ghjs-base so that cabal.project does not need preprocesisng to select which ghcjs base library to use.

Pull requests

This package is actually missing a few ghcjs-base modules that I have not got around to stubbing. Pull requests are welcome if you need those extra stubs. When making a stub, please do not create partial functions, just emit safe stubbed values. Eg. Bad

foo :: IO JSVal
foo = undefined

Better

foo :: IO JSVal
foo = pure nullRef

How to build manually

git clone https://github.com/louispan/ghcjs-base-stub
cd ghcjs-base
git submodule update --init --recursive