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

Compiling with GHC fails with error: No instance for ToJSString (Maybe [Char]) #7

Open
hansroland opened this issue Jun 5, 2017 · 0 comments

Comments

@hansroland
Copy link

hansroland commented Jun 5, 2017

I tried to compile ghcjs-dom-hello under GHC / WebkitGtk2 with the following stack.yaml file:

resolver: lts-8.17
packages:
- location: '.'
#- location:
#    git: https://github.com/GHCJS/jsaddle
#    commit: a51df99cbcca19d11df079f1a99771043153d1a7 
#  subdirs:
#  - jsaddle
# extra-dep: true
  
extra-deps:
- jsaddle-0.9.0.0
- jsaddle-dom-0.9.0.0
- ghcjs-dom-0.9.0.0
- jsaddle-warp-0.9.0.0
- jsaddle-webkit2gtk-0.9.0.0
- ref-tf-0.4.0.1
- ghcjs-dom-jsaddle-0.9.0.0
- gi-webkit2-4.0.12
- webkit2gtk3-javascriptcore-0.14.2.1
- gi-javascriptcore-4.0.12
flags: {}

extra-package-dbs: []

And got the error:

/home/roland/Projekte/ghcjs-dom-hello/src/HelloMain.hs:22:5-52: error:
    • No instance for (Language.Javascript.JSaddle.Marshal.String.ToJSString
                         (Maybe [Char]))
        arising from a use of ‘setInnerHTML’

Note: To be able to build under Linux I had to remove the section executable ghcjs-dom-hello-wkwebview and the if os(osx) || os(ios) from the cabal file.

I don't really understand why we have this error. We have in module Language.Javascript.JSaddle.Marshal.String :

-- | Anything that can be used to make a JavaScript string
class ToJSVal a => ToJSString a where
    toJSString :: a -> JSString

and in module Language.Javascript.JSaddle.Value :

instance ToJSVal a => ToJSVal (Maybe a) where
    toJSVal Nothing = return jsNull
    toJSVal (Just a) = toJSVal a

Here is the full building log with the complete error message:

roland@goms:~/Projekte/ghcjs-dom-hello$ stack setup
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
roland@goms:~/Projekte/ghcjs-dom-hello$ stack setup
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
roland@goms:~/Projekte/ghcjs-dom-hello$ stack build
webkit2gtk3-javascriptcore-0.14.2.1: configure
webkit2gtk3-javascriptcore-0.14.2.1: build
gi-javascriptcore-4.0.12: configure
webkit2gtk3-javascriptcore-0.14.2.1: copy/register
gi-javascriptcore-4.0.12: build
ref-tf-0.4.0.1: configure
ref-tf-0.4.0.1: build
gi-javascriptcore-4.0.12: copy/register
ref-tf-0.4.0.1: copy/register
gi-webkit2-4.0.12: configure
gi-webkit2-4.0.12: build
jsaddle-0.9.0.0: configure
jsaddle-0.9.0.0: build
gi-webkit2-4.0.12: copy/register
jsaddle-0.9.0.0: copy/register
jsaddle-warp-0.9.0.0: configure
jsaddle-warp-0.9.0.0: build
jsaddle-webkit2gtk-0.9.0.0: configure
jsaddle-webkit2gtk-0.9.0.0: build
jsaddle-dom-0.9.0.0: configure
jsaddle-dom-0.9.0.0: build
jsaddle-warp-0.9.0.0: copy/register
jsaddle-webkit2gtk-0.9.0.0: copy/register
jsaddle-dom-0.9.0.0: copy/register
ghcjs-dom-jsaddle-0.9.0.0: configure
ghcjs-dom-jsaddle-0.9.0.0: build
ghcjs-dom-jsaddle-0.9.0.0: copy/register
ghcjs-dom-0.9.0.0: configure
ghcjs-dom-0.9.0.0: build
ghcjs-dom-0.9.0.0: copy/register
ghcjs-dom-hello-5.0.0.0: configure (lib + exe)
Configuring ghcjs-dom-hello-5.0.0.0...
ghcjs-dom-hello-5.0.0.0: build (lib + exe)
Preprocessing library ghcjs-dom-hello-5.0.0.0...
[1 of 1] Compiling HelloMain        ( src/HelloMain.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/HelloMain.o )
               
/home/roland/Projekte/ghcjs-dom-hello/src/HelloMain.hs:22:5-52: error:
    • No instance for (Language.Javascript.JSaddle.Marshal.String.ToJSString
                         (Maybe [Char]))
        arising from a use of ‘setInnerHTML’
    • In a stmt of a 'do' block:
        setInnerHTML body (Just "<h1>Kia ora (Hi)</h1>")
      In the expression:
        do { doc <- currentDocumentUnchecked;
             body <- getBodyUnsafe doc;
             setInnerHTML body (Just "<h1>Kia ora (Hi)</h1>");
             _ <- on doc click
                  $ do { (x, y) <- mouseClientXY;
                         newParagraph <- uncheckedCastTo HTMLParagraphElement
                                         <$> createElement doc "p";
                         .... };
             .... }
      In an equation for ‘helloMain’:
          helloMain
            = do { doc <- currentDocumentUnchecked;
                   body <- getBodyUnsafe doc;
                   setInnerHTML body (Just "<h1>Kia ora (Hi)</h1>");
                   .... }
Completed 11 action(s).

--  While building package ghcjs-dom-hello-5.0.0.0 using:
      /home/roland/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 build lib:ghcjs-dom-hello exe:ghcjs-dom-hello exe:ghcjs-dom-hello-warp exe:ghcjs-dom-hello-webkitgtk --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
roland@goms:~/Projekte/ghcjs-dom-hello$ 
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

1 participant