Use Haskell for shell scripting
haskellforall.com
Use Haskell for shell scripting
1–10 of 105 posts
Re: Use Haskell for shell scripting
#2For example, the pwd function returns a FilePath type rather than a String:
Prelude Turtle> :type pwd
pwd :: IO Turtle.FilePath
The datefile function is also typed: Prelude Turtle> :type datefile
datefile :: Turtle.FilePath -> IO UTCTime
So this really does seem to structure the data passed between commands, instead of the "stringly typing" unix shells have historically been known for.Re: Use Haskell for shell scripting
#3Re: Use Haskell for shell scripting
#4Hamming has this great set of lectures on how he became a world renowned scientist and in one of the lectures he explains why Ada failed and other languages succeeded. The difference was that Ada was designed logically and most successful languages were designed psychologically. Even when government contracts mandated Ada people still wrote in Fortan and hand translated to Ada. You can watch the videos and take from it what you will.
A minimal bash file is`#!/bin/bash`. A minimal turtle file is already way too long and logical.
The set of videos: https://www.youtube.com/playlist?list=PL2FF649D0C4407B30.
Re: Use Haskell for shell scripting
#5But why "turtle"?
Re: Use Haskell for shell scripting
#6Re: Use Haskell for shell scripting
#7Re: Use Haskell for shell scripting
#8Who's the target audience of this exactly? I already see a language pragma, do notation, liftIO, parser combinators. Hamming has this great set of lectures on how he became a world renowned scientist and in one of the lectures he explains why Ada failed and other languages succeeded. The difference was that Ada was designed logically and most successful languages were designed psychologically. Even when government co…
Re: Use Haskell for shell scripting
#9Some related projects:
- Joey Hess recently released a nice Haskell-to-sh compiler. I like this approach as the resulting sh scripts are runnable on pretty much every *nix. https://joeyh.name/blog/entry/shell_monad/
- Chris Done also released a lib to do shell stuff from Haskell, which build on the conduit library http://chrisdone.com/posts/shell-conduit
- Chris also wrote a shell in Haskell https://github.com/chrisdone/hell
- Then there is Shelly by Greg Weber https://github.com/yesodweb/Shelly.hs
There are probably more...
Re: Use Haskell for shell scripting
#10POSIX shell is everywhere - your current Linux and OS X machines, old UNIX workstations, home routers, servers... Just drop in a file and it will probably run just fine, unless the author screwed something up completely. POSIX shell scripts are the perfect bootstrap mechanisms that will run almost anywhere regardless of architecture.
Haskell, on the other hand, is rarely present in an operating system - if you absolutely, positively need a higher-level language for „shell scripting”, then you have a much higher chance of finding a Perl interpreter, or even Python. Heck, even getting ghc and its' basic ecosystem running has always proved to be a huge burden to me. Try sticking a `cabal install` in your CI flow, you'll see your job times increase by hours.
Third, there's just the KISS aspect of it - if you're writing something that has logic so simple it can be stuck in a shell file, why not just write it in a shell file? You don't need category theory to get a few files installed...