imeckler / mote

BSD 3-Clause "New" or "Revised" License
116 stars 5 forks source link

Copying code from ghc-mod rather than depending on it is _very_ fragile #12

Open DanielG opened 9 years ago

DanielG commented 9 years ago

There must be a better way to support your use case than to outright duplicate the code. Maybe we can work together to add whatever you need to the exported API? I'm ghc-mod's maintainer so I might be able to help ;)

imeckler commented 9 years ago

Great! The code duplicated from ghc-mod is only used to set ghc flags according to the project's cabal file. I don't remember exactly, but I think the main reason I had to duplicate it was to fix the issue in ghc-mod where the new binary cabal format wasn't supported. It seems like this has been fixed as of the last few weeks, so I think I'll be able to remove the duplicated code.

I'll make a comment here when I know for certain what (if anything) I would need to be exposed in ghc-mod.

DanielG commented 9 years ago

On Tue, Apr 28, 2015 at 07:50:33AM -0700, Izzy Meckler wrote:

Great! The code duplicated from ghc-mod is only used to set ghc flags according to the project's cabal file. I don't remember exactly, but I think the main reason I had to duplicate it was to fix the issue in ghc-mod where the new binary cabal format wasn't supported.

That's odd because when I tried mote I still got the error that was symptomatic of the Cabal-1.22 trouble.

It seems like this has been fixed as of the last few weeks, so I think I'll be able to remove the duplicated code.

Yeah that's all supported now.

You copied some quite old code I have since rewritten and it's a lot more precise now (I hope), even has native support for cabal components without requiring user intervention.

I'll make a comment here when I know for certain what (if anything) I would need to be exposed in ghc-mod.

Ok, cool.

imeckler commented 9 years ago

That's odd because when I tried mote I still got the error that was symptomatic of the Cabal-1.22 trouble.

Did you install cabalparse? This was my workaround hack to address the 1.22 problem.

DanielG commented 9 years ago

Ah right, that's probably it.

imeckler commented 9 years ago

Which version of ghc-mod should I depend on? Is it on hackage?

DanielG commented 9 years ago

Well you'll have to build against the development version until I release it if you need ghc 7.10 and cabal>1.22 support. Otherwise the one from hackage is fine. Though if you need any API additions then you'll have to build against a development version anyways.

I guess the best way to solve this would be to add a flag to mote's cabal file, something like ghc-mod-devl, set that to default to true and in that flag depend on ghc-mod == 0 (which is the version of ghc-mod from master). Cabal will then and then try to find the development version (you can make it available using cabal sandbox add-source) and fall back to that flag being false if it can't find it. In which case you would depend on ghc-mod >= 5.2 or whatever.

You can then use your existing module doing the ghc-mod stuff with ghc-mod-5.2.x.x and use the new stuff with the devel version by setting CPP defines when the flag is set/unset or by using some hs-source-dirs sorcery.

DanielG commented 9 years ago

BTW did you not get the E-Mail I sent you a few days ago?

imeckler commented 9 years ago

I did not. It's in this image. http://parametricity.com/images/back.jpg

DanielG commented 9 years ago

Yeah, that's where I sent it before. I sent you another one. According to my mail sever it was delivered. Maybe check spam or something?