Concerning free software, programming, and whatever else I find interesting. Also the blog for my Web site, frigidcode.com.
Haskell shell scripting!
Posted 10-25-2012 at 11:19 AM by hydraMax
Practical shell scripting AND full-fledged Haskell functional programming at the same time!? Is it really possible to have your cake and eat it too!? I'm sweating with excitement at my recent discovery.
Not only is it possible, but there is a well-developed module that allows you to do shell like programming with Haskell, without losing any of the benefits of the language:
http://hackage.haskell.org/packages/...ml/Shelly.html
Combine that with a shebang call to runghc, and you get a stand alone Haskell script. For a quite simple example:
Then chmod and run:
The module author's examples are much better:
https://www.linux-magazin.de/Online-...using-Haskell/
Not only is it possible, but there is a well-developed module that allows you to do shell like programming with Haskell, without losing any of the benefits of the language:
http://hackage.haskell.org/packages/...ml/Shelly.html
Combine that with a shebang call to runghc, and you get a stand alone Haskell script. For a quite simple example:
Code:
$ cat test.hs #!/usr/bin/runghc {-# LANGUAGE OverloadedStrings #-} import Shelly main = shelly $ do files <- ls "/scratch/cmhoward/test1" mapM_ (echo . toTextIgnore) files
Code:
$ chmod +x test.hs $ ./test.hs /scratch/cmhoward/test1/file1.txt /scratch/cmhoward/test1/file2.txt /scratch/cmhoward/test1/file3.txt
https://www.linux-magazin.de/Online-...using-Haskell/
Total Comments 0