chshersh / iris

🌈 Haskell CLI Framework supporting Command Line Interface Guidelines
https://hackage.haskell.org/package/iris
Mozilla Public License 2.0
176 stars 21 forks source link

Split errors in Tool check #33

Closed chshersh closed 2 years ago

chshersh commented 2 years ago

Currently, the checkTool function has the following type:

checkTool :: cmd -> Tool cmd -> IO ToolCheckResult

where ToolCheckResult is defined as follows:

data ToolCheckResult
    = ToolNotFound Text
    | ToolWrongVersion Text
    | ToolOk

A value of ToolCheckResult is thrown as an exception here:

https://github.com/chshersh/iris/blob/6be65d46a5b3f2cabd09dedbc88045c4be4fb224/src/Iris/Env.hs#L138-L141

This is suboptimal because the result can never have the ToolOk constructors but we're forcing downstream users to handle this case.

So we want to split success and error cases in the ToolCheckResult type.