
Hi Cafe! I've written very first version of GHCJS port https://github.com/geraldus/ghcjs-perch of Perch https://github.com/agocorona/haste-perch library originally designed to work with Haste compiler. Most of work is already done, though some polishing is needed. In essence Haste and GHCJS versions are very similar, the major difference is how foreign functions are defined, and in fact Perch is built using just a few low-level primitives https://github.com/geraldus/ghcjs-perch/blob/master/src/Internal/FFI.hs. So, as these libraries are very similar I want to generalize Perch to make it independent of compiler somehow. My initial idea was to have a Perch library and several compiler specific back-ends which user should select depending on his toolchain, but my Haskell skills are still very poor to find a proper way to do this. Can someone point me in right direction or at least give some advices? Very appreciate any help!

The way Fay handles this is to set the `FAY` variable for CPP so you can
use `#ifdef FAY`. I then usually have a module Foo.GHC and Foo.Fay imported
conditionally. Perhaps something similar is applicable here?
HTH,
Adam
On Wed, Jun 24, 2015 at 10:30 AM, Geraldus
Hi Cafe!
I've written very first version of GHCJS port https://github.com/geraldus/ghcjs-perch of Perch https://github.com/agocorona/haste-perch library originally designed to work with Haste compiler. Most of work is already done, though some polishing is needed. In essence Haste and GHCJS versions are very similar, the major difference is how foreign functions are defined, and in fact Perch is built using just a few low-level primitives https://github.com/geraldus/ghcjs-perch/blob/master/src/Internal/FFI.hs.
So, as these libraries are very similar I want to generalize Perch to make it independent of compiler somehow.
My initial idea was to have a Perch library and several compiler specific back-ends which user should select depending on his toolchain, but my Haskell skills are still very poor to find a proper way to do this. Can someone point me in right direction or at least give some advices?
Very appreciate any help!
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Sorry for late response! So likely CPP is the only option. Thank you, Adam! I know GHCJS also sets similar variable and I think it is possible to check compiler using `impl(ghcjs)` in cabal file and have conditional dependencies list (correct me if I wrong). But I don't know if Haste has similar var and flag.
participants (2)
-
Adam Bergmark
-
Geraldus