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

Report what files are dependencies of the Cradle #35

Closed
ndmitchell opened this issue Sep 12, 2019 · 7 comments · Fixed by #42
Closed

Report what files are dependencies of the Cradle #35

ndmitchell opened this issue Sep 12, 2019 · 7 comments · Fixed by #42

Comments

@ndmitchell
Copy link
Contributor

See https://github.com/digital-asset/ghcide/issues/50, which wants ghcide to reload when you update your .cabal file. One option is that a Cradle should have an extra field cradeDependencies :: [FilePath] which would give the files which the cradle uses.

@fendor
Copy link
Collaborator

fendor commented Sep 13, 2019

So, cradleDependencies are files that ghcide needs to watch for changes for, right?
E.g. for cabal that would be a cabal.project and *.cabal file and for stack stack.yaml, package.yaml and *.cabal?

@ndmitchell
Copy link
Contributor Author

@fendor - yep!

@fendor
Copy link
Collaborator

fendor commented Sep 13, 2019

One more question, should it only contain files that exist, or all files that may be interesting? E.g. cabal.project may not always exist but as soon as one is added, we would want to know about it right?

@ndmitchell
Copy link
Contributor Author

The files don't have to exist - anything relevant would be useful.

@fendor
Copy link
Collaborator

fendor commented Sep 16, 2019

After talking with @mpickering, dependencies of a cradle should be loaded when loading a cradle and it should be possible to query the corresponding build tool.
Therefore, I propose the following API changes:

-- | The environment where this library is used.
data Cradle = Cradle {
  -- | The project root directory.
    cradleRootDir    :: FilePath
  -- | The action which needs to be executed to get the correct
  -- command line arguments
  , cradleOptsProg   :: CradleAction
  } deriving (Show)

data CradleAction = CradleAction 
    { actionName :: String
    , getDependencies :: IO [FilePath] 
    -- ^ Files that cause the cradle to change, may be monitored to reload a cradle
    , getOptions ::  (FilePath -> IO (ExitCode, String, [String]))
    -- ^ Options to compile a file in the cradle with.
    }

Further, extend the Cradle config to include a field cradle deps. This allows users to work around any missed cradle dependencies by supplying them themselves in hie.yaml:

data CradleType 
   = Cabal { component :: Maybe String }
   | Stack
   | Bazel
   | Obelisk
   | Bios { prog :: FilePath, deps :: Maybe FilePath }
   | Direct { arguments :: [String] }
   | Default
   deriving (Show)

data CradleConfig = CradleConfig
   { cradleType :: CradleType
   , cradleDependencies :: Maybe [FilePath]
    -- ^ Bikeshed, `Maybe` is not necessary, empty list might be good enough 
   }

Note, the changes to Bios CradleType, which now also includes the path to a program that produces cradle dependencies.

@ndmitchell
Copy link
Contributor Author

Looks sensible to me!

@mpickering
Copy link
Collaborator

Sounds right to me.

  • Make sure you properly combine together the dependencies directly specified by the user and dependencies reported by the bios program.
  • Just use [FilePath] rather than Maybe [FilePath].
  • Document the new addition (are filepaths expected to absolute? relative?)

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