LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Blogs > Bits and Pixels
User Name
Password

Notices


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

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:

Code:
$ cat test.hs 
#!/usr/bin/runghc

{-# LANGUAGE OverloadedStrings #-}
import Shelly

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

Code:
$ chmod +x test.hs
$ ./test.hs 
/scratch/cmhoward/test1/file1.txt
/scratch/cmhoward/test1/file2.txt
/scratch/cmhoward/test1/file3.txt
The module author's examples are much better:

https://www.linux-magazin.de/Online-...using-Haskell/
Posted in Uncategorized
Views 1643 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



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

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