cocreature / diagrams-miso

Miso backend for the diagrams Haskell graphics library
Other
9 stars 1 forks source link

compatibility with stack and the miso stack ... stack? #1

Open silky opened 5 years ago

silky commented 5 years ago

as a lover of diagrams, this is an awesome library and i'm very excited to try it :)

presently, miso builds nicely with stack

i'm trying to include this library as a dep of sample-app; i've tried changing the app.cabal there to have:

  build-depends:       base, miso, diagrams-miso

and pointing the stack file at a clone of diagrams-miso like so:

extra-deps:
 - miso-0.18.0.0
 - ../../diagrams-miso

but no such luck; i get:

03:43 PM noon ∈ sample-app (master*) ♫ stack build
Building a GHCJS project. Note that GHCJS support in Stack is EXPERIMENTAL

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for diagrams-miso-0.1:
    base-4.8.2.0 from stack configuration does not match >=4.9 && <4.10  (latest matching version is 4.9.1.0)
    diagrams-core-1.3.0.8 from stack configuration does not match >=1.4 && <1.5  (latest matching version is 1.4.1.1)
    diagrams-lib-1.3.1.4 from stack configuration does not match >=1.4 && <1.5  (latest matching version is 1.4.2.3)
    lens-4.13 from stack configuration does not match >=4.15 && <4.16  (latest matching version is 4.15.4)
needed due to app-0.1.0.0 -> diagrams-miso-0.1

it gets much further with allow-newer: true, but fails here:


    Configuring hinotify-0.3.8.1...
    Building hinotify-0.3.8.1...
    Preprocessing library hinotify-0.3.8.1...
    hsc2hs-ghcjs-0.2.0.9006020-7.10.3.bin: hsc2hs: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)

and stack-installing that binary doesn't really help (probably not surprisingly; i'm not even sure what that does here...)

thoughts?

would it be best to set up a stack environment in this repo first, maybe following the scheme of miso itself, or is there some better approach?

silky commented 5 years ago

i "fixed" it with two terrible hacks:

  1. i manually set the path to hsc2hs in my path: export PATH=/home/noon/.stack/programs/x86_64-linux/ghc-7.10.2/bin/:$PATH

  2. this code had to be changed:

mouseEventDecoder :: Decoder (Int, Int)
mouseEventDecoder =
  Decoder
    (withObject "event" $ \o -> liftA2 (,) (o .: "clientX") (o .: "clientY"))
    mempty

to

mouseEventDecoder :: Decoder (Int, Int)
mouseEventDecoder =
  Decoder
    (withObject "event" $ \o -> liftA2 (,) (o .: "clientX") (o .: "clientY"))
    (DecodeTarget [])

because apparently DecodeTarget doesn't have a Monoid instance.

then, this project builds with the following stack.yaml

resolver: lts-6.20
compiler: ghcjs-0.2.0.9006020_ghc-7.10.3
compiler-check: match-exact

packages:
  - '.'

extra-deps:
  - miso-0.21.2.0@sha256:298ac5017beb44c5e4002eef917c40e2fdf017c7ffa84a1344dc73d0c01664c2

setup-info:
  ghcjs:
    source:
      ghcjs-0.2.0.9006020_ghc-7.10.3:
         url: http://ghcjs.tolysz.org/lts-6.20-9006020.tar.gz
         sha1: a6cea90cd8121eee3afb201183c6e9bd6bacd94a

and all the bounds removed from the cabal file.

cocreature commented 5 years ago

What the version errors are telling you is that this project is intended to be used with GHCJS >= 8.0 and newer versions of diagrams that provide this Monoid instance. Since 7.10 is really old by now, I’d say it makes more sense that you try to upgrade rather than try to make this library compatible with 7.10 and older versions of diagrams.

silky commented 5 years ago

diagrams won't provide a monoid instance of DecodeTarget, though, because that comes from miso itself?

cocreature commented 5 years ago

Oh right, good catch! In that case I’m happy to accept a PR that fixes this (the patch you showed above looks totally fine).