shade icon indicating copy to clipboard operation
shade copied to clipboard

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

Open darthdeus opened this issue 11 years ago • 3 comments

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

darthdeus avatar Jun 23 '14 02:06 darthdeus

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?

takeoutweight avatar Jun 23 '14 08:06 takeoutweight

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 avatar Aug 03 '14 17:08 katyo

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.

katyo avatar Aug 03 '14 18:08 katyo