Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert between stack/cabal naming conventions #120

Open
alanz opened this issue Dec 31, 2019 · 11 comments
Open

Convert between stack/cabal naming conventions #120

alanz opened this issue Dec 31, 2019 · 11 comments

Comments

@alanz
Copy link

alanz commented Dec 31, 2019

The hie-bios README gives the following two examples

cradle: {stack: {component: "haskell-ide-engine:lib" }}
cradle: {cabal: {component: "lib:haskell-ide-engine"}}

They are both referring to the library component in haskell-ide-engine, but stack and cabal have different naming conventions for them.

If I have a complex multi-cradle, such as

cradle:
  stack:
    - path: "./test/dispatcher/"
      component: "haskell-ide-engine:test:dispatcher-test"
    - path: "./test/functional/"
      component: "haskell-ide-engine:test:func-test"
    - path: "./test/unit/"
      component: "haskell-ide-engine:test:unit-test"
    - path: "./hie-plugin-api/"
      component: "hie-plugin-api:lib"
    - path: "./app/MainHie.hs"
      component: "haskell-ide-engine:exe:hie"
    - path: "./app/HieWrapper.hs"
      component: "haskell-ide-engine:exe:hie-wrapper"
    - path: "./"
      component: "haskell-ide-engine:lib"

I would ideally like to just replace stack with cabal on the second line and have it continue to work.

Can we do some kind of implicit name translation for this case?

@alanz
Copy link
Author

alanz commented Dec 31, 2019

See sample files in haskell/haskell-ide-engine#1533

@fendor
Copy link
Collaborator

fendor commented Jan 13, 2020

Is there any specification for both of these formats?

@alanz
Copy link
Author

alanz commented Jan 13, 2020

I suspect it is a case of reading the code. Best case is it will be in the documentation, but I am not holding my breath.

@sureyeaah
Copy link

sureyeaah commented Feb 7, 2020

Couldn't find it in the documentation but relevant code can be found here (stack, cabal).
From what I understand, a stack build target can be specified in these ways:

  • package_name
  • package_name_with_version
  • :component_name
  • package_name:lib
  • package_name:[test|bench|exe]:component_name

while cabal uses the following syntax:

  • component_name
  • component_kind:component_name
  • component_name:module_or_file_name
  • component_kind:component_name:module_or_file_name

  • I think the naming convention might not be the same in both cases, not sure about it.
  • Cabal also lets you specify which module/file you want to build - is that relevant for our use case?
  • How should the translation work? I think we would need to restrict some cases to be able to do it unambiguously or make no changes for cases where we are unable to decide the translation. e.g. target is component_name that was written for a cabal cradle and we change it to stack. In that case, we can't decide if we want to interpret it as package_name or :component_name(user wants this).

@jneira
Copy link
Member

jneira commented Feb 7, 2020

@sureyeaah nice resume, i will use for reference too 😄
For completeness, i think that component_kind == [lib|test|bench|exe]

@sureyeaah
Copy link

@jneira thanks, would be great to document this somewhere. I could share this via a blog post maybe after I understand it more. Also Cabal lets you use the component kind "flib" for foreign libraries IIUC.

@jneira
Copy link
Member

jneira commented Feb 7, 2020

Well, it is documented but it seems it is not easily discoverable:

Also Cabal lets you use the component kind "flib" for foreign libraries IIUC

Oh yeah i forgot them (i've never used them)

@mpickering
Copy link
Collaborator

It's good to document this but I'm still not convinced it's something which needs to be "fixed" in the library.

@ndmitchell
Copy link
Contributor

I'd rather it was fixed in stack/cabal, but given how easy it is to shim between them, seems useful to have in hie-bios so people can experiment with stack/cabal quickly without running into the obvious bug.

@sureyeaah
Copy link

@jneira I should have searched the docs a bit better. Still got to read some code :)

@jneira
Copy link
Member

jneira commented Feb 7, 2020

Well, at least some validation would be great ("you are using wrong syntax for targets, see [link] of [build-tool] for reference"), even if translation ends up being tricky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants