Rebuilding WAR files in webapps directory This script cleans up destination directory and copies file into it with new name. Can this intent be expressed more cleanly with shelly?

main = shellyFailDir $ verbosely $ do
  escaping False $ rm_rf $ webapps &lt;/&gt; "*"
  cp (m2repo
       &lt;/&gt; groupPath
       &lt;/&gt; artifact
       &lt;/&gt; version
       &lt;/&gt; (intercalate "-" [artifact, version] `append` ".war")
     ) $ webapps &lt;/&gt; (finalName `append` ".war")
  echo "done"


Alternate take:

main = shellyFailDir $ verbosely $ do
  ls webapps &gt;&gt;= mapM_ rm_rf
  cp (m2repo &lt;&gt; groupPath &lt;&gt; (mconcat . map fromText $ [artifact, version, artifactFileName]))
     $ webapps &lt;&gt; fromText (finalName &lt;&gt; extension)
  echo "done"

artifactFileName = intercalate "-" [artifact, version] &lt;&gt; extension


Having (types match only second version because they help pick correct Monoid):

m2repo = ".m2/repository" :: FilePath
version = "1.0-SNAPSHOT" :: Text
webapps = "tomcat/webapps" :: FilePath
groupPath = "com/example" :: FilePath
artifact = "app" :: Text
finalName = artifact
extension = ".war" :: Text
I think your first version looks pretty slick. You could use a let-binding to do a little reordering and naming.

import Data.Monoid

main = shellyFailDir $ verbosely $ do
  escaping False $ rm_rf $ webapps &lt;/&gt; "*"
  let sourceName = artifact &lt;&gt; "-" &lt;&gt; version &lt;&gt; ".war"
      source = m2repo &lt;/&gt; groupPath &lt;/&gt; artifact &lt;/&gt; version &lt;/&gt; sourceName
      destination = webapps &lt;/&gt; finalName &lt;&gt; ".war"
  cp source destination
  echo "done"