Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems building template Haskell #4

Open
commandodev opened this issue Mar 2, 2015 · 4 comments
Open

Problems building template Haskell #4

commandodev opened this issue Mar 2, 2015 · 4 comments

Comments

@commandodev
Copy link
Owner

With b874983 checked out:

ben@xps:~/dev/ghcjs/examples/todo-mvc|haskell-ng⚡
⇒  ls -la
total 68
drwxrwxr-x 7 ben ben  4096 Mar  2 18:05 .
drwxrwxr-x 6 ben ben  4096 Jan  6 06:12 ..
drwxrwxr-x 2 ben ben  4096 Dec 31 15:17 build
-rw-rw-r-- 1 ben ben  1488 Feb 28 09:16 build.nix
-rw-rw-r-- 1 ben ben    16 Nov 27 06:10 cabal.config
-rw-rw-r-- 1 ben ben   528 Mar  1 21:38 default.nix
drwxr-xr-x 4 ben ben  4096 Mar  2 20:13 dist
drwxrwxr-x 3 ben ben  4096 Jan 19 08:14 docs
-rw-rw-r-- 1 ben ben 11514 Nov 27 06:10 LICENSE.txt
-rwxrwxr-x 1 ben ben   291 Dec 24 15:13 make.sh
lrwxrwxrwx 1 ben ben    13 Jan  4 06:23 nixpkgs -> ../../nixpkgs
lrwxrwxrwx 1 ben ben     9 Jan  4 06:22 oHm -> ../../oHm
-rw-rw-r-- 1 ben ben  1435 Mar  2 17:48 ohm-todo-mvc.cabal
-rw-rw-r-- 1 ben ben     0 Dec 30 15:39 .projectile
-rw-rw-r-- 1 ben ben    46 Nov 27 06:10 Setup.hs
-rw-rw-r-- 1 ben ben   311 Mar  1 21:37 shell.nix
drwxrwxr-x 2 ben ben  4096 Mar  2 20:17 src
drwxrwxr-x 2 ben ben  4096 Jan  7 08:38 static
lrwxrwxrwx 1 ben ben    17 Mar  1 21:37 virtual-dom -> ../../virtual-dom
ben@xps:~/dev/ghcjs/examples/todo-mvc|haskell-ng⚡
⇒  nix-shell -I . --command "cabal configure --ghcjs"
Warning: The package list for 'hackage.haskell.org' is 268.5 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring ohm-todo-mvc-0.1.0.0...
ben@xps:~/dev/ghcjs/examples/todo-mvc|haskell-ng⚡
⇒  nix-shell -I . --command "cabal build"            
Building ohm-todo-mvc-0.1.0.0...
Preprocessing executable 'todo-mvc' for ohm-todo-mvc-0.1.0.0...
[1 of 1] Compiling Main             ( src/Main.hs, dist/build/todo-mvc/todo-mvc-tmp/Main.js_o )
Linking Template Haskell (ThRunner1)

/tmp/ghc939_0/ghc939_45.jspp:205:28:
     warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
         compliantExecNpcg = /()??/.exec("")[1] === undef,
     ^
uncaught exception in Haskell main thread: ReferenceError: navigator is not defined
ReferenceError: navigator is not defined
    at Object.eval (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:7457:17)

    at Object../keys (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:7908:4)
<no location info>:
    Data.Binary.Get.runGet at position 0: demandInput: not enough bytes
    at s (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:4624:540)
    at eval (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:4624:591)
    at Object.component-emitter (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:6358:14)
    at s (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:4624:540)
    at eval (eval at h$loadCodeStr (/nix/store/w75wnmyfpgg7nsi3kxapy8kwqh77pr1d-ghcjs-0.1.0/lib/ghcjs-0.1.0/thrunner.js:139:10), <anonymous>:4624:591)
@jkozlowski
Copy link

Seeing a similar problem (but I compiled ghcjs manually) on f703757:

Building todomvc-ghcjs-0.1.0.0...
Preprocessing executable 'todomvc-ghcjs' for todomvc-ghcjs-0.1.0.0...
[1 of 1] Compiling Main             ( src/Main.hs, dist/build/todomvc-ghcjs/todomvc-ghcjs-tmp/Main.js_o )
Linking Template Haskell (ThRunner1)
uncaught exception in Haskell main thread: ReferenceError: document is not defined
ReferenceError: document is not defined
    at eval (eval at h$loadCodeStr (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:139:10), <anonymous>:1142:12)
    at eval (eval at h$loadCodeStr (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:139:10), <anonymous>:1171:3)
    at eval (native)
    at Object.h$loadCodeStr [as loadCodeStr] (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:139:10)
    at Object.h$loadCode [as loadCode] (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:147:10)
    at h$$ghcjszu2U6CT3su9VuHXMTtRe30dXZCGHCJSziPrimziTHziEval_dJ (eval at h$loadCodeStr (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:139:10), <anonymous>:41465:16)
    at h$mainLoop (eval at h$loadCodeStr (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:139:10), <anonymous>:10462:25)
    at eval (eval at h$loadCodeStr (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:139:10), <anonymous>:10945:13)
    at /Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:95:9
    at h$processQueue (/Users/jakubkozlowski/.ghcjs/x86_64-darwin-0.1.0-7.10.1/ghcjs/thrunner.js:71:13)

<no location info>:
    Data.Binary.Get.runGet at position 0: demandInput: not enough bytes

@jkozlowski
Copy link

Managed to fix mine; it is beacuse of https://github.com/boothead/oHm/blob/master/vendor/keymaster.js having references to the browser document object, which doesn't exist when ran through nodejs. Moving the types (and hence the TH magic for lenses) to a separate module fixed this.

@commandodev
Copy link
Owner Author

Thanks @jkozlowski - sorry I missed this update. @luite is this useful info for you?

@luite
Copy link

luite commented Jun 9, 2015

Yeah this is a general problem of how TH is run. The code has to work under the node.js environment, otherwise it breaks.

We could perhaps add some workarounds, like preprocessor options that exclude code from being linked when running TH, or add some thin browser compatibility layer that would at least get rid of some undefined variable errors. Does anyone have any preference or suggestions here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants