Simple Unix commandline tools written in Haskell. This is
intended as a beginner’s tutorial for learning Haskell from a
“Let’s just solve things already!” point of view. The examples
should help give a flavor of the beauty and expressiveness of
Haskell programming. These functions can be executed as one
liners from a shell. For example, to use the Haskell version of
‘wc’: $ cat file.txt | ghc -e 'wc_l' UnixTools.hs Or, one could
define ‘main’ to be a chosen tool/function (add a line to the
effect that “main = wc_l”) and then compile the tool with $ ghc
--make UnixTools.hs import Control.Monad.Instances import
Data.List import Data.Char import Data.Maybe import Text.Printf
import System.Environment -- First, two helpers io f = interact
(unlines . f . lines) showln = (++ "n") . show -- remove
duplicate lines from a file (like uniq) uniq = nub -- repeat the
input file infinitely rpt = cycle -- Return the head -10 line of
a file take' = take 10 -- Remove the first 10 lines of a file
drop' = drop 10 -- Return the