Visit Jeremy's Blog.
Go Back > Blogs > Bits and Pixels
User Name


Concerning free software, programming, and whatever else I find interesting. Also the blog for my Web site,
Rate this Entry

Haskell shell scripting!

Posted 10-25-2012 at 12:19 PM 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:

Combine that with a shebang call to runghc, and you get a stand alone Haskell script. For a quite simple example:

$ cat test.hs 

{-# LANGUAGE OverloadedStrings #-}
import Shelly

main = shelly $
  do files <- ls "/scratch/cmhoward/test1"
     mapM_ (echo . toTextIgnore) files
Then chmod and run:

$ chmod +x test.hs
$ ./test.hs 
The module author's examples are much better:
Posted in Uncategorized
Views 985 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 02:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration