takeoutweight / shade

Interactive, client-side web apps in Haskell
149 stars 9 forks source link

Could not deduce (Pack a) arising from a use of `ffi' #1

Open darthdeus opened 10 years ago

darthdeus commented 10 years ago

I've done clean install of GHC 7.6.3, compiled the latest version of haste, cloned shade, ran haste-inst install in shade-core, which ran successfully. But then I tried to run it inside `shade-haste and I get the following error.

$ haste-inst install
Resolving dependencies...
Configuring shade-haste-0.1.0.0...
Building shade-haste-0.1.0.0...
Preprocessing library shade-haste-0.1.0.0...

src/Shade/Haste/Internal/React.hs:156:32:
    Could not deduce (Pack a) arising from a use of `ffi'
    from the context (Unpack a, Pack b)
      bound by the type signature for
                 fieldIn :: (Unpack a, Pack b) => String -> a -> b
      at src/Shade/Haste/Internal/React.hs:155:12-49
    Possible fix:
      add (Pack a) to the context of
        the type signature for
          fieldIn :: (Unpack a, Pack b) => String -> a -> b
    In the second argument of `(.)', namely
      `(ffi (toJSStr (fieldIn' f)))'
    In the expression: unsafePerformIO . (ffi (toJSStr (fieldIn' f)))
    In an equation for `fieldIn':
        fieldIn f
          = unsafePerformIO . (ffi (toJSStr (fieldIn' f)))
          where
              fieldIn' f = "(function(u){return u." ++ f ++ ";})"
Failed to install shade-haste-0.1.0.0
cabal: Error: some packages failed to install:
shade-haste-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1
takeoutweight commented 10 years ago

Hmm! I just tried 7.6.3 on a clean Ubuntu VM with the latest Haste and everything seemed to work. I'm not entirely sure what could be the issue here... Is there any way you have old leftover haste binaries or libraries left over from a previous install?

katyo commented 10 years ago

I also get same error:

kayo@ikki:~/shade/shade-haste$ haste-inst install
Resolving dependencies...
Configuring shade-haste-0.1.0.0...
Building shade-haste-0.1.0.0...
Preprocessing library shade-haste-0.1.0.0...

src/Shade/Haste/Internal/React.hs:158:32:
    Could not deduce (Pack a) arising from a use of `ffi'
    from the context (Unpack a, Pack b)
      bound by the type signature for
                 fieldIn :: (Unpack a, Pack b) => String -> a -> b
      at src/Shade/Haste/Internal/React.hs:157:12-49
    Possible fix:
      add (Pack a) to the context of
        the type signature for
          fieldIn :: (Unpack a, Pack b) => String -> a -> b
    In the second argument of `(.)', namely
      `(ffi (toJSStr (fieldIn' f)))'
    In the expression: unsafePerformIO . (ffi (toJSStr (fieldIn' f)))
    In an equation for `fieldIn':
        fieldIn f
          = unsafePerformIO . (ffi (toJSStr (fieldIn' f)))
          where
              fieldIn' f = "(function(u){return u." ++ f ++ ";})"
Failed to install shade-haste-0.1.0.0
cabal: Error: some packages failed to install:
shade-haste-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1

My env:

kayo@ikki:~$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
kayo@ikki:~$ hastec --version
0.3
katyo commented 10 years ago

I changed fieldIn function signature as GHC suggests:

fieldIn :: (Pack a, Unpack a, Pack b, Unpack b) => String -> a -> b

It works fine for me. I also test todo example from here https://github.com/takeoutweight/shade-todomvc It works too.