Hacker News new | ask | show | jobs
by hyllos 939 days ago
I’ve turned some time ago a build and deploy script (single production server) some bash scripts into Haskell using Turtle [1]. What I enjoyed was the ability to reduce redundancies significantly. It was significantly shorter code afterwards.

[1] https://hackage.haskell.org/package/turtle

1 comments

I recently tried Turtle but ended up throwing it out in favour of typed-process.

Afaik a Turtle program has a single current directory, which makes it hard when you want to run concurrent jobs that need to be executed from particular directories. I partially solved the problem by using locks/queues/workers. But it got too much for me when Turtle started failing due to its current directory being deleted.

In contrast, typed-process lets you spawn separate processes, and execute within a working dir (rather than needing to cd there), so it works great for big, complicated workflows.

And it also has good support for OverloadedStrings, which means you can generally copy & paste what you would have typed into bash, and it just works.

I also use the interpolate package (with QuasiQuotes) to make the raw strings nicer in the source code, but it's not compatible with hlint, so I'm thinking of looking for a different package for string-handling.

Author of Shh [0] here. I've replaced a lot of Bash with Haskell (it's great!). I wrote Shh to help me out with that.

I ended up liking PyF [1] for quasiquoting. A friend of mine worked with the author a while ago to strip down it's dependencies, so it's easy to justify. It's what I recommend in my cargo culting guide [2].

[0] https://hackage.haskell.org/package/shh

[1] https://hackage.haskell.org/package/PyF

[2] https://github.com/luke-clifton/shh/blob/master/docs/porting...