fpco / ghcjs-react

React bindings for GHCJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing Ace and Ref modules?

mmaz opened this issue · comments

First, thanks for these bindings; I'm very excited to start using this project! I'm having an issue trying to build the example:

  1. It looks like React.Ace was removed from the cabal file but Main.hs still imports it.
  2. Is React.Ref also missing? In my docker container of ghcjs:
root@2146e7004535:/ghcjs-shared/ghcjs-react# ghcjs -iexamples/ -isrc/ examples/Main.hs 

examples/Main.hs:12:8:
    Could not find module ‘React.Ace’
    Use -v to see a list of the files searched for.

examples/Main.hs:15:8:
    Could not find module ‘React.Ref’
    Use -v to see a list of the files searched for.

(The rest of this issue is additional information for upstream reference, and can probably be ignored)

I've also raised an upstream question on how to use ghcjs with cabal sandboxing, since I wasn't able to figure it out. I installed ghcjs-react inside a cabal sandbox (which in turn is inside a docker container) successfully after adding the jquery sandbox as a source dependency:

$ cd / && git clone https://github.com/ghcjs/ghcjs-jquery && cd ghcjs-jquery
$ cabal sandbox init && cabal install --ghcjs
...
Installed ghcjs-jquery-0.1.0.0
$ cd / && git clone https://github.com/fpco/ghcjs-react && cd ghcjs-react
$ cabal sandbox add-source /ghcjs-jquery/
$ cabal install --ghcjs
Resolving dependencies...
Notice: installing into a sandbox located at
/ghcjs-react/.cabal-sandbox
...
Installed lens-4.9.1
Configuring ghcjs-react-0.0.0...
Building ghcjs-react-0.0.0...
Installed ghcjs-react-0.0.0

I thought this would be enough to build the examples, but I couldn't get ghcjs to find the installed dependencies in my sandbox:

(in addition to React.Ace and React.Ref above):

src/React/Builder.hs:28:18:
    Could not find module ‘GHCJS.DOM.Types’
    Perhaps you meant GHCJS.Types (from ghcjs-base-0.1.0.0)
    Use -v to see a list of the files searched for.

src/React/Internal.hs:27:18:
    Could not find module ‘Control.Lens’
    Perhaps you meant Control.Seq (from parallel-3.2.0.4)
    Use -v to see a list of the files searched for.

src/React/Internal.hs:48:18:
    Could not find module ‘JavaScript.JQuery’
    Use -v to see a list of the files searched for.

src/React/Internal.hs:51:18:
    Could not find module ‘GHCJS.DOM’
    Use -v to see a list of the files searched for.

src/React/Internal.hs:52:18:
    Could not find module ‘GHCJS.DOM.Element’
    Use -v to see a list of the files searched for.

src/React/Internal.hs:53:18:
    Could not find module ‘GHCJS.DOM.Event’
    Use -v to see a list of the files searched for.

I tried to use both the -package-db flag and the GHC_PACKAGE_PATH environment variable, but the verbose output when running ghcjs -v suggests it's still trying to use the packages only in ~/.ghcjs/ and not in my sandbox

$ export GHC_PACKAGE_PATH=$PWD/.cabal-sandbox/x86_64-linux-ghc-7.8.4-packages.conf.d/
$ ghcjs -v -package-db=.cabal-sandbox/x86_64-linux-ghc-7.8.4-packages.conf.d/ -iexamples/ -isrc/ examples/Main.hs
Glasgow Haskell Compiler for JavaScript, Version 7.8.4, stage 2 booted by GHC version 7.6.3
Using binary package database: /root/.ghcjs/x86_64-linux-0.1.0-7.8.4/ghcjs/package.conf.d/package.cache
Using binary package database: /root/.ghcjs/x86_64-linux-0.1.0-7.8.4/package.conf.d/package.cache

On master you should be able to build with:

ghcjs -iexamples/ -isrc/ examples/Main.hs -fforce-recomp; cp examples/index.html examples/Main.jsexe/
[1 of 9] Compiling GHCJS.Compat     ( src/GHCJS/Compat.hs, src/GHCJS/Compat.js_o )
[2 of 9] Compiling React.Internal   ( src/React/Internal.hs, src/React/Internal.js_o )
[3 of 9] Compiling React.Event      ( src/React/Event.hs, src/React/Event.js_o )
[4 of 9] Compiling React.Builder    ( src/React/Builder.hs, src/React/Builder.js_o )
[5 of 9] Compiling React.Lucid      ( src/React/Lucid.hs, src/React/Lucid.js_o )
[6 of 9] Compiling React.Component  ( src/React/Component.hs, src/React/Component.js_o )
[7 of 9] Compiling React            ( src/React.hs, src/React.js_o )
[8 of 9] Compiling React.Ace        ( examples/React/Ace.hs, examples/React/Ace.js_o )
[9 of 9] Compiling Main             ( examples/Main.hs, examples/Main.js_o )
Linking template haskell (GHCJS.Compat,React,React.Ace,React.Builder,React.Component,React.Event,React.Internal,React.Lucid,ThRunner1)
Linking template haskell (GHCJS.Compat,React,React.Ace,React.Builder,React.Component,React.Event,React.Internal,React.Lucid,ThRunner2)
Linking examples/Main.jsexe (GHCJS.Compat,Main,React,React.Ace,React.Builder,React.Component,React.Event,React.Internal,React.Lucid)

But I discovered some issues while fixing this. Receiving properties is not sent to the Ace editor. I'll look into it.

Thanks @chrisdone and my apologies for leaving this ticket open for so long. It took me some time to setup ghcjs in a sandbox-friendly manner; ultimately this comment from Luite in ghcjs/ghcjs#353 helped me a lot with the sandboxing issues I was having above (in case anyone else comes across this via Google or Github). Afterwards, I was able to build ghcjs-react successfully :)