4 ms·
Ask HN: Can ghci realistically replace bash?
I live almost entirely in the command line; the only non-cli tool I use regularly is my browser. Also, I'd like to learn me a Haskell.
Learning Haskell has been a goal of mine for a while actually, and I've had false starts with some of the existing, excellent learning resources:
* Brent Yorgey's CS194 course,
* Learn You a Haskell for Great Good!, and
* Write Yourself a Scheme in 48 Hours.
So it occurred to me that I might actually learn if I started inserting Haskell into my current workflow. Better yet, if userspace is "just" tooling that calls into the kernel syscall API, it's concievably possible to replace everything with Haskell.
That being the goal, I have played with ghci along with a couple of the "Haskell scripting" libraries:
* shelly
* turtle
These are great tools, but I'd like to learn how to do things the Haskell Way instead of just wrapping my familiar tools in thin Haskelly types. So, in the course of my (limited) explorations, here are some questions and issues I've encountered:
* Can I install and load a new package from within ghci (i.e. do the equivalent of "stack install ...")?
* Is it possible to intelligently manage a git repository without calling out to the git binary? (I'm aware of the 'git' package but not familiar with it enough to judge usability.)
* How would SSHing into a machine even work?
* What are some ways to serialize typed data while keeping things "just text" and human readable?
* How do we pretty print things like directory listings etc.?
* Am I just being ridiculous?
Anyway, this isn't a comprehensive list of questions, but if any of you use Haskell as your primary method of interacting with the system, I'd like to hear what libraries and workflows you have.
Cheers!
- PaulHoule 9y agoWhy is it that when people can't do something with PHP they think that "PHP is stupid" but if they can't do it with Haskell they think they are stupid?
- jetti 9y agoJust a guess but it could have something to do with the perceived language. PHP is something that is perceived to be easy to pick up and easy to work with. If you can't do something with it that becomes a language issue because you are smart enough to use such a "simple language". Haskell, on the other hand, is seen as this language for "smart people". If one can't figure out how to do something in Haskell it is easier to say that they just aren't smart enough for the language.
- tome 9y agoThe Haskell subreddit would be a much better place to ask this question.
- brudgers 9y agoTo me, you are being curious not ridiculous. The idea of using Haskell as an interactive shell seems like a great learning exercise and worth pushing as far as you are willing to go. Even if from a practical standpoint, rewriting the entire *nix stack in Haskell is probably more than a lifetime's work. Technically, to me recreating Bash in Haskell to swim in the Turing Tarpit. [1] Some programming languages are mostly ready to serve as an operating system shell, e.g. Common Lisp (Lisp machines), Smalltalk, Erlang, or QBasic. [2] Others are not because there is a difference between the abstraction of an interpreter and the abstraction of a shell. One of them is session duration. The interpreter abstraction tends toward: starting the interpreter from a shell, running a sequence of commands, exiting to the shell. The shell abstraction tends toward starting (perhaps recursively from another shell) and possibly running indefinitely until crashing or the heat death of the universe whichever comes first. SSH is a great example of the recursive and indefinite temporal extent of shells. Python's global interpreter lock is a reasonable example of the interpreter abstraction. Good luck. [1]: https://en.wikipedia.org/wiki/Turing_tarpit https://en.wikipedia.org/wiki/Turing_tarpit [2]: or Bash.