5 ms·
Shh: Simple Shell Scripting from Haskell
- cole-k 3y agoThose of you who use (or used) this as your shell: care to share your experience? It seems a lot less full-featured than https://xon.sh/ https://xon.sh/, but maybe you don't need a lot of bells and whistles for regular usage. I mostly run build, execute, and install commands. I'm somewhat enticed at the possibility of being able to wrap common executables into forms that are typed (like nushell or elvish) and manipulate them in a way that leverages the type checker.
- themk 3y agoAuthor here. I rarely use it as a shell personally, though it does work, and sometimes I drop into it for the odd task. It's primarily designed to replace overgrown bash scripts.
- fuzztester 3y agoRelated: has anyone tried scheme shell (scsh) and what is your experiences with it? https://en.m.wikipedia.org/wiki/Scsh https://en.m.wikipedia.org/wiki/Scsh
- loevborg 3y agoLast time I tried I couldn't get it to compile These days https://babashka.org/ https://babashka.org/ is a much better option. It's powerful, fast, modern, works everywhere and has effortless multitasking.
- elviejo 3y agoThere is also Rash: Racket Shell that looks súper interesting. https://youtu.be/yXcwK3XNU3Y?si=XuABEBZReyfhraAh https://youtu.be/yXcwK3XNU3Y?si=XuABEBZReyfhraAh Haven't tried it though.
- velcrovan 3y agoIt is interesting, but not something you’d really want to rely on. (see the issues, comments and commit history: https://github.com/willghatch/racket-rash https://github.com/willghatch/racket-rash) This project could really benefit from picking up a couple of steady contributors. It looks like the author is a new dad, and his commit history looks about like what mine did at that stage.
- forgotpwd16 3y agoInterestingly Rash is also suitable as a user-oriented shell (like bash) rather be reserved for scripting (like scsh).
- chubot 3y agoFWIW there is a big list of similar libraries / internal DSLs in nearly all Lisps, and nearly all statically typed functional languages here: https://github.com/oilshell/oil/wiki/Internal-DSLs-for-Shell https://github.com/oilshell/oil/wiki/Internal-DSLs-for-Shell e.g. points to another Haskell project, which may be old - https://github.com/jgoerzen/hsh/wiki https://github.com/jgoerzen/hsh/wiki Which is related to the list of free-standing shells: https://github.com/oilshell/oil/wiki/Alternative-Shells https://github.com/oilshell/oil/wiki/Alternative-Shells
- agumonkey 3y agoNot this one, but for a while I tried getting https://wryun.github.io/es-shell/ https://wryun.github.io/es-shell/ to run (a functionalish shell)
- nemoniac 3y agoIMHO it's worth spending some time getting acquainted with it. It's very clearly thought out conceptually with good separation of concerns. I learned a lot about Scheme and a lot about Unix from using it.
- fuzztester 3y agoThanks for the answers, guys.
- adastra22 3y ago"Shell scripts" is kinda the domain of newLISP, which I've used before and like.
- ekiauhce 3y agoYou can’t really move away from bash, unless there would be alternative as widely available on different Unix systems as bash is. Yes, you came up with a nice syntax for your Haskell scripts, but what it cost to install all required dependencies on, for example, newly created Ubuntu server?
- pbiggar 3y agoWe're trying to do a similar thing with darklang right now: providing a single binary with a built-in package manager. The idea being making it easy to write readable "bash" scripts (including writing them with AI), but with just one dependency - the darklang binary itself.
- themk 3y agoYep, this is mainly used for turning those bash scripts that you let get too large into a real program. You port your script, basically line for line, into this, and then start chipping away at it until you have something less scary.
- forgotpwd16 3y agoToo bad Hugs98 (installation is few MBs) is no longer updated leaving only GHC (GB+).
- maleldil 3y agoYou don't need the compiler to run the program in production. You only need the binary. I'd argue that a heavy toolchain in the dev machine isn't a big deal.
- IshKebab 3y agoBash scripts tend to be used in situations where you want to edit them and not have to deal with a recompilation step, let alone a multi-GB compiler install. That seems like a deal-breaker to me. The best alternative I've found so far is Deno. It natively supports single file scripts with third party dependencies (this is a big issue with replacing Bash with Python). It uses an existing popular language (so now "learn our weird language" problem). Installation is very easy. The only real downside I've found is this stupid bug that they refused to fix: https://github.com/denoland/deno/issues/16466 https://github.com/denoland/deno/issues/16466
- themk 3y agoAuthor here. My main use for this is incremental migration away from bash. I'm not saying this is the best way to do scripts, but it's a pretty great stepping stone. Just following the cargo culting guide [0] can already uplift a bash script without changing the logic too much. From there you can start adding structure. My secondary use case is little scripts in NixOS/nixpkgs. There are some helpers in there that make it quite convenient. [0] https://github.com/luke-clifton/shh/blob/master/docs/porting.md https://github.com/luke-clifton/shh/blob/master/docs/porting...
- sshine 3y agoshh is a really cool package, and so is turtle and shelly: https://hackage.haskell.org/package/turtle/docs/Turtle-Tutorial.html https://hackage.haskell.org/package/turtle/docs/Turtle-Tutor... https://hackage.haskell.org/package/shelly https://hackage.haskell.org/package/shelly shh's "Alternatives" section summarises nicely some of the differences between these: https://github.com/luke-clifton/shh#alternatives https://github.com/luke-clifton/shh#alternatives shh has a neat [fmt| ... |] macro that gets you around escaping strings. shh generally has more Template Haskell support; you may or may not like this. I am personally leaning towards shh because of its "native pipe style".
- winterqt 3y ago> shh has a neat [fmt| ... |] macro that gets you around escaping strings. Per the README, this is actually the work of https://hackage.haskell.org/package/PyF https://hackage.haskell.org/package/PyF
- ben0x539 3y agoThis seems fun! Far too few people who are all "your bash scripts shouldn't be 300 lines and have complex logic!" address why people reach for bash scripts in the first place, so kudos for that.
- williamcotton 3y agoHuh, I was just tinkering with the same sort of thing with the same motivations but with F#: https://github.com/williamcotton/fs_playground/blob/main/Scratchpad/PltAwk.fsx https://github.com/williamcotton/fs_playground/blob/main/Scr... Thanks for this, I’m going to borrow a lot of your concepts, especially the added infix operators, those are slick!