hapistrano
hapistrano copied to clipboard
Use deriving strategies for Hapistrano's Monad
As it is now, we Hapistrano is using the following monad stack: https://github.com/stackbuilders/hapistrano/blob/f3fbe9a34cde5c645cbb4d51a48647a80ea00b92/src/System/Hapistrano/Types.hs#L49
Using deriving strategies The monad could be implemented like the following:
newtype Hapistrano (a :: Type) = Hapistrano {unHapistrano :: Config -> IO a}
deriving (Functor, Applicaitve, Monad, MonadThrow) via (ReaderT Config IO)
That could remove the current monad stack and also lift operations between them, exceptions could be caught at top level during the execution of commands and could simplify the code a bit.
For backward compatibility, we might use CPP as well to keep the monad stack or choose the new monad as well.
Let me know how does this sound :smile:
This looks doable. I have a question regarding the usage of MonadCatch
here (which would need to be added to the instances of the newtype): to preserve the ability to handle the current error we have, i.e. the pair (Failure, Maybe Release)
, we would define something like this:
newtype FailureException = FailureException { unFailureEx :: (Failure, Maybe Release) }
deriving (Show, Typeable)
instance Exception FailureException
is that right? In that case, I think the refactor could be quite easy to carry out.
Yeah, I think that would do. You could also use anyclass
as well for the instance of Exception
.
newtype FailureException = FailureException { unFailureEx :: (Failure, Maybe Release) }
deriving (Show, Typeable)
deriving anyclass Exception
Hey @ibarrae Would you mind if I pick this one? I haven't touch this new type of deriving and I'd love to learn more about it.
For sure @CristhianMotoche :rocket:
Solved in #204