Search code examples
haskellhaskell-turtle

Is there a turtle function or other Haskell abstraction for joining commands using .&&


I have the following piece of code:

foldM (\exitCode args -> pure exitCode .&&. someCmdWith args) ExitSuccess argss

Which uses turtle's (.&&.) operator.

Is there a better abstraction I could use to apply .&&. to the results of applying someCmdWith to argss?


Solution

  • Would this work?

    runCmds argss = foldr (.&&.) (pure ExitSuccess) (fmap someCmdWith argss)
    

    If you want to write it even shorter, I believe this would also work:

    runCmds = foldr (.&&.) (pure ExitSuccess) . fmap someCmdWith