faylang / fay

A proper subset of Haskell that compiles to JavaScript
https://github.com/faylang/fay/wiki
BSD 3-Clause "New" or "Revised" License
1.29k stars 86 forks source link

Data.Aeson sought and not found #383

Closed christianpbrink closed 10 years ago

christianpbrink commented 10 years ago

I'm writing a web app with a Haskell backend, and I've got a Haskell module to perform computations which I now realize should be performed on the client side. I don't relish the thought of porting its exports to JS by hand, and the idea of being able to trans-compile the module to Javascript is pretty sweet. Its only dependency is Prelude, so I figure it should be Fay-compatible.

I expected to be able to follow this example, which works fine for me. But when I run fay MyModule.hs --strict MyModule, I get this report:

fay: could not find an import in the path: Data.Aeson,
searched in these places: /home/vagrant/.cabal/share/x86_64-linux-ghc-7.6.3/fay-0.18.1/src/, /home/vagrant/.cabal/share/x86_64-linux-ghc-7.6.3/fay-base-0.18.0.0/src, /home/vagrant/.cabal/share/x86_64-linux-ghc-7.6.3/fay-base-0.18.0.0, .

First, my code doesn't try to import Data.Aeson, so I don't know why it's even being mentioned. Can anyone help me understand that?

Second, I have no idea how to direct fay to Data.Aeson. I don't really understand how fay thinks about packages in the firs place -- to what extent (if any) it can just piggyback on my cabal environment (which is global, not sandboxed), whether I should be install special fay packages or reinstalling my normal cabal packages in a special way suitable for fay's use, and whether should I be trying to build this as a fay package instead of working with a single module file.

I appreciate any help. Thank you.

christianpbrink commented 10 years ago

My mistake. My description above was incorrect -- I was in fact importing one thing other than Prelude, a module that simply exported an ADT. That ADT had ToJSON and FromJSON instances.

Womp. Sorry for the noise.