Open chshersh opened 2 years ago
Iris.need is the main function for checking whether a specified tool executable in PATH:
Iris.need
need :: MonadIO m => [Tool] -> m ()
It supposed to be used like this in the main application code:
app :: App () app = Iris.asksCliEnv Iris.cliEnvCmd >>= \case Download url -> do need ["curl"] runDownload url Evaluate hs -> do need ["ghc", "cabal"] runEvaluate hs
Where the Tool type is the following:
Tool
https://github.com/chshersh/iris/blob/c1597ee1b7e271d744e9460fccef2a46804e9ccf/src/Iris/Tool.hs#L43-L71
It does the job but it's a bit suboptimal and maybe inconvenient at times.
I'd love to improve this API in the following way:
With such an eDSL, it should be possible to write the following code:
ghc :: Iris.Tool ghc = "ghc" `Iris.versionAtLeast` [8, 10, 7] `Iris.usingVersionFlag` "--numeric-version" cabal :: Iris.Tool cabal = "cabal" `Iris.versionAtLeast` [3, 6, 2, 0] `Iris.usingVersionFlag` "--numeric-version" app :: App () app = Iris.asksCliEnv Iris.cliEnvCmd >>= \case Download url -> do need ["curl"] runDownload url Evaluate hs -> do need [ghc, cabal] runEvaluate hs
The checkToolFunction should patched accordingly.
checkToolFunction
Part of the API improvements are described in:
I'd like to work on this after #97 is merged, but I don't understand what you're suggesting on the second task. Could you help clarifying it please?
Iris.need
is the main function for checking whether a specified tool executable in PATH:It supposed to be used like this in the main application code:
Where the
Tool
type is the following:https://github.com/chshersh/iris/blob/c1597ee1b7e271d744e9460fccef2a46804e9ccf/src/Iris/Tool.hs#L43-L71
It does the job but it's a bit suboptimal and maybe inconvenient at times.
I'd love to improve this API in the following way:
With such an eDSL, it should be possible to write the following code:
The
checkToolFunction
should patched accordingly.