Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Haskell be used to write shell scripts?

Tags:

Is it possible to write shell scripts in Haskell and if so, how do you do it? Just changing the interpreter like so?

#!/bin/ghci 
like image 799
ihatetoregister Avatar asked Jan 19 '12 12:01

ihatetoregister


People also ask

Is Haskell good for scripting?

Fortunately, Haskell is an excellent candidate for statically typed scripting for a few reasons: Haskell has lightweight syntax and very little boilerplate. Haskell has global type inference, so all type annotations are optional. You can type-check and interpret Haskell scripts very rapidly.

What language are shell scripts written in?

Shell scripts contain ASCII text and are written using a text editor, word processor or graphical user interface (GUI). The content of the script is a series of commands in a language that can be interpreted by the shell.

Which shell is best for scripting?

Tenex Shell This shell is recommended for programmers based on its C-like syntax, as those developers can use scripting features without any experience in sh or Bash.


1 Answers

Using ghci will just load the module in GHCi. To run it as a script, use runhaskell or runghc:

#!/usr/bin/env runhaskell main = putStrLn "Hello World!" 
like image 78
hammar Avatar answered Oct 04 '22 20:10

hammar