Out of the shell solution for scripting in Haskell. Shellmet provides an easy and convenient way to call shell commands from Haskell programs.
Usage exampleπ
This README contains the usage example of the shellmet
library. The example is runnable. You can build and execute with the following command:
cabal run readme
Setting upπ
Since this tutorial is written using Literate Haskell, first, letβs write all necessary pragmas and imports.
{-# LANGUAGE OverloadedStrings #-}
import Data.Semigroup ((<>))
import Shellmet (($|))
import qualified Data.Text as T
Simple scripting exampleπ
Below you can see how easy it is to interact with shell commands in Haskell:
main :: IO ()
= do
main "echo" ["Starting shellmet readme..."]
<- "cat" $| ["README.md"]
text let cnt = T.pack $ show $ length $ T.lines text
"echo" ["Number of lines in this README: " <> cnt]
And the output is:
β echo 'Starting shellmet readme...'
Starting shellmet readme...
β echo 'Number of lines in this README: 54'
Number of lines in this README: 54