4 ms·
I've made 2-3 toy REST APIs, and now I'm working on a product using a Haskell backend that's bigger. https://github.com/seanhess/serials https://github.com/sean
by embwbam 11y ago
I've made 2-3 toy REST APIs, and now I'm working on a product using a Haskell backend that's bigger. https://github.com/seanhess/serials https://github.com/seanhess/serials
I love it. I mean I could have done the same thing in node. But there's something about the workflow in Haskell. I need to add a new feature I didn't think of. But I don't have to refactor as aggressively because all my code is made up of little functions. I start hacking, my editor has a list of errors I still need to clean up. I clean them up, and it usually works the first try.
Or this morning I wanted to add a connection pool to my rethinkdb driver code. The resource-pool package gives you an awesome way to do it for anything. Without knowing about rethinkdb at all.
Also this morning I wanted to do some IO in parallel. I found several nice concurrency packages and threw one in without any refactoring.
It has its difficulties (deployment?) but I'm really enjoying it.
- creichert 11y agoIt has its difficulties (deployment?) but I'm really enjoying it. Anything specific? What kind of environments are you deploying in?
- embwbam 11y agoJust compared to dynamic languages. Cross compiling and such. I went with docker (see the repo) and it works. Deploys via docker push are a little slower than I'd like but nothing I can't improve later.
- creichert 11y agoI see, it really depends on your goal. The Dockerfile in the repo looks like it's built primarily for Haskell development. When I'm working with production environments, I build the Haskell executable locally and add that (statically linked) program to the Dockerfile. That should tremendously speed things up. The caveat is that your local and production architecture are the same. I find deploying the static executable much quicker and more simple. You aren't doing it wrong, just thought I would my own preferences. Some environments like Elastic Beanstalk have timeouts that will kill the build if it doesn't build quickly enough (a problem on smaller VMs). Another issue is potential RAM needed by GHC. Keep in mind that Haskell executables statically link Haskell libraries and dynamically link system libs (by default). You can find your system library dependencies by running: $ ldd dist/build/serials/serials [...]
- embwbam 11y agoThat sounds way nicer than my 30 minute deploy process. I develop on a mac and deploy to ubuntu. How would you recommend I build? Vagrant? (I almost finished getting the vagrant stuff working).
- Ericson2314 11y agoI highly recommend https://github.com/NixOS/nixops https://github.com/NixOS/nixops, which is good for deployment in general, but especially good for Haskell since the Haskell infrastructure was rewritten this year.
- codygman 11y agoI found myself using cabbage[0] so I could have exact version dependencies. Nix was awesome when mostly using latest versions of a package, but for much of my code I needed specific versions and cabbage allowed me to have them. 0: https://github.com/acowley/cabbage https://github.com/acowley/cabbage
- Ericson2314 11y agoFor the sake of a single manager for my whole system I'll stick with nix. But yes, it would be nice if it knew more about versions. In a future where upstream projects can maintain their own nix packages, I think this will be unavoidable.
- embwbam 11y agoI've heard it mentioned several times, but I don't really understand how to use it to deploy haskell code. Do you know of a tutorial link somewhere?
- Ericson2314 11y agoSo recently the haskell package infrastructure was overhauled. This is great! But, it means that many resources are out of date. I really recommend you first read about nix with http://lethalman.blogspot.com/feeds/posts/default/-/nixpills http://lethalman.blogspot.com/feeds/posts/default/-/nixpills . Once you've done that, the simple instructions at http://wiki.ocharles.org.uk/Nix http://wiki.ocharles.org.uk/Nix should get you going. You can try to skip to the wiki page, but in the likely case something doesn't go quite right, it will be hard to debug without a broader knowledge of Nix. I'll admit Nix's has quite the learning curve, and I was more tempted to sneak around its uncompromising rigidity than when learning Haskell. But the bitter pill is worth it.
- qubitcoder 11y agoSimilar story here. I find I'm able to accomplish tasks which would otherwise be beyond my skill and intelligence. For example, even though C was the first language I learned, I can't imagine writing a parser in C after discovering the simplicity & readability of monadic parsing in Haskell. [1] Just compare that page with the parser/lexer for the Jq tool on the HN homepage (written in C). A few months ago, I needed to retrieve JSON data from a list containing dozens of URLs. Fortunately, the "async" package handles this beautifully: [2] pages <- mapConcurrently getURL ["url1", "url2", "url3",...] Once you learn the basic concepts of Haskell and get over the hump, you’re able do things with ease that would otherwise take many years to master in C++ [3]. Even the most advanced features of the language follow the same underlying principles & syntax. My advice to those wanting to learn Haskell is simply not to give up. Keep coming back to it. Practice. Read other’s code. Over time, things will begin to click. And once they do, you’ll wonder why you struggled so much in the first place. [1] https://www.fpcomplete.com/school/starting-with-haskell/libraries-and-frameworks/text-manipulation/attoparsec https://www.fpcomplete.com/school/starting-with-haskell/libr... [2] https://hackage.haskell.org/package/async-2.0.2/docs/Control-Concurrent-Async.html https://hackage.haskell.org/package/async-2.0.2/docs/Control... [3] http://chimera.labs.oreilly.com/books/1230000000929/index.html http://chimera.labs.oreilly.com/books/1230000000929/index.ht...