9 ms·
Getting It Done with Haskell
- raarts 12y agoI've been looking at learning Haskell for al the obvious reasons, but I've been put off by all the lengthy and detailed introductions to the syntax, and math oriented examples, that seem written by theoreticists. What I would like (and in my opinion what Haskell needs to grow), is a more practical introduction, like doing a database conversion, or writing some network service. Syntax can be explained in passing. Does this exist?
- dllthomas 12y agoTry the WikiBook (http://en.wikibooks.org/wiki/Haskell http://en.wikibooks.org/wiki/Haskell). And if it doesn't present something well, fix it!
- rybosome 12y agoI was pretty impressed with the content in "Real World Haskell"[0], it's available online for free and for sale in print. I don't remember all of the practical examples, but off the top of my head, they include wiring up a pcre library by using FFI into C and reading a barcode from an image. This talk claims that the book is out of date; that's probably true, but I still found it to be valuable. [0] http://book.realworldhaskell.org http://book.realworldhaskell.org
- jsmeaton 12y agoI've just started with Learn You A Haskell [0] and I'm really enjoying it (and learning). It does focus a lot on the syntax and types at the beginning though - but I've found that a nice way to learn so far. [0] http://learnyouahaskell.com/ http://learnyouahaskell.com/
- zeckalpha 12y agoWhat syntax? Haskell has just about the simplest syntax.
- gizmo686 12y agoBut it has some obscure function names that look alot like syntax. (eg. "$", ".", ">>=" etc)
- jeorgun 12y agoI think that's raart's point. The syntax is really simple and easy to pick up, so all the tutorials focusing mainly on syntax and paying less attention to actually, well, getting things done, do the language a disservice.
- johan_larson 12y agoIn nearly every mainstream programming language, you call a function like this: f(a, b, c) But not in Haskell, where you do it like this: f a b c Of course, there is a reason for doing things this way in Haskell, namely making currying a natural part of the language. If f is a function of three variables, f a b binds values to the first two parameters, yielding a function of one variable. But it's still a change and a bit of a hurdle.
- gtani 12y agothere's lots of books, and a couple recent ones, listed here, depending on what you're looking for: http://www.reddit.com/r/haskell/comments/2cpr4z/recommended_reading_material/ http://www.reddit.com/r/haskell/comments/2cpr4z/recommended_... and FP complete have put a huge effort into putting up tutorials that you can run through interactively https://www.fpcomplete.com/ https://www.fpcomplete.com/
- kasbah 12y agoIts not databases or network services but Write Yourself a Scheme in 48Hrs [1] is a more practical intro. Aside from that I would recommend the cis194 Lectures [2] if you do feel ready to take a slightly more thorough top down approach. There are exercises for every almost every lecture and you can even peak at your digital neighbours to compare solutions [3]. [1]: https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_... [2]: http://www.seas.upenn.edu/~cis194/lectures.html http://www.seas.upenn.edu/~cis194/lectures.html [3]: https://github.com/search?q=cis194&type=Everything&repo=&langOverride=&start_value=1 https://github.com/search?q=cis194&type=Everything&repo=&lan...
- djur 12y agoThis is kind of the problem, though: Haskell is popular among people for whom "write Scheme in this language" is an example of a practical introduction. It frequently seems like a community of PLT experts talking with PLT apprentices, with the workaday concerns of 95% of practicing developers treated as an exercise to figure out on your own time. This isn't a criticism of Haskell or Haskellers. It's more an observation that the current makeup of the Haskell community might prove to be a drag on its appeal.
- kasbah 12y agoI guess so. I got a bit fed up with parsing text too and got side-tracked to more graphical things. Initially to Elm [1]. It's not exactly Haskell but Elm is a fun way to get into Functional and Functional Reactive programming while drawing some things on screen and making them move. There are probably more graphical tutorials for Haskell too. I recently found some good examples for Gloss [2] and am moving from Elm to that right now. There is an "Elm for Haskell" called HElm [3] too. [1]: http://elm-lang.org http://elm-lang.org [2]: http://gloss.ouroborus.net http://gloss.ouroborus.net [3]: http://helm-engine.org http://helm-engine.org
- coolsunglasses 12y agoI teach a lot of Haskell [1] and observe a lot of people teaching Haskell. Write Yourself a Scheme is not representative of how the Haskell community teaches Haskell. I can't even remember the last time it was cold-suggested to somebody. The last person I knew to do so, did so knowing they were going about it the "hard way". They also did it with the intent of actively upgrading/updating the code WYASI48H as they went into a more modern style. They gave a talk on it after. It's a good way to firm up your knowledge if it's the sort of project that interests you, but needs love and isn't a good introduction for most. [1]: https://github.com/bitemyapp/learnhaskell https://github.com/bitemyapp/learnhaskell
- kndyry 12y agoThis was me as well. I had tried several resources and books (including LYAH) and while I had enjoyed them, they hadn't seemed to "stick." I can't recall now where I saw Conrad Barski's tutorial [0] mentioned, perhaps here on HN, but I found his approach much more personally suitable. He steps the reader through writing a program that reads in and then divides an arbitrary park map into small, roughly equivalent picnic plots with colored SVG output along the way. The code takes center stage and is presented to the reader with the why and a good/bad analysis afterward. I'm not sure whether this is what you're after, but at the very least it's worth a glance. [0] http://lisperati.com/haskell/ http://lisperati.com/haskell/
- collyw 12y agoI'd like to see some practical software written in Haskell (probably database based like you suggest). It sounds great theoretically, but I haven never come across Haskell in the wild.
- codygman 12y agoWhat about html parsing/posting, api creation/consumption, and screen scraping? It's what I've used Haskell for the most and would be happy to make some introductory tutorials.
- Bootvis 12y agoI believe those could be very valuable. It's practical and doesn't have to be too complex and touches a number interesting topics.
- djur 12y agoYes, please. There's a dearth of this kind of material.
- codygman 12y agoAlright, I'll respond to you here again when I've wrote something.
- codygman 12y agoI didn't write it, but I came across something that might be of interest to you: http://pbrisbin.com/posts/writing_json_apis_with_yesod/ http://pbrisbin.com/posts/writing_json_apis_with_yesod/
- Bootvis 12y agoWow, thanks for the follow-up! I will have to check it out later. Thanks again.
- mattgreenrocks 12y agoI agree with you here. But I've found it semi-refreshing to be confronted with something that is different enough that I have to sit down with it regularly to practice. It isn't just another language, and it really isn't amenable to just fiddling with things until they work. That said, the gap from newbie to competent is big, an I feel like this is mostly a documentation issue. I've only started very recently and I have awhile to go. You can't expect to grok the implications of monads, laziness, immutability, and pure functional style immediately. But hat doesn't mean they aren't worthwhile, or interesting. Now if you'll excuse me, I need to harass, er, ask for help on some Haskell I'm stuck on. (BTW: the community is really helpful. There are no charlatans or self-promotional jerks like you'll find elsewhere.)
- deleted 12y ago[deleted]
- duckingtest 12y agoI was toying with Haskell a few years ago, and I found it unpractical. Sometimes it turns out you need to do something with IO somewhere, and now you have to change all the functions down the way to use it. Similar issue is lack of exceptions - Haskell just has a type enhanced version of 'return -1' from C. Exceptions should be completely separate from successful execution paths. Throwing exception from a pure function with type like Int -> Int requires changes in everything that uses it. Common Lisp's condition system is much, much better. The third issue I remember was that all fields' names are global. All of this makes it very hard to write the minimal working code now and extend it later. Instead, you have to provide scaffolding for possible future changes, or risk having to change everything. Maybe there's some True Way of using Haskell which doesn't suffer from these issues, but I haven't found it.
- mark_l_watson 12y agoI have been on a four year journey for learning Haskell so I understand where you are coming from. I have recently starting doing almost all of my NLP and semantic web/linked data experiments in Haskell and that has helped get me over a learning curve hump, a bit. One thing that helps me, when possible, is to get the pure code working before worrying about network and file IO, etc. Working on pure functional code is really nice. Monads still cause me some grief and I look for examples on the web of what I need to do, and modify them. I have given up the idea of ever becoming an expert in Haskell, but I am enjoying it and getting stuff done.
- michaelochurch 12y agoSometimes it turns out you need to do something with IO somewhere, and now you have to change all the functions down the way to use it. Similar issue is lack of exceptions - Haskell just has a type enhanced version of 'return -1' from C. Exceptions should be completely separate from successful execution paths. Throwing exception from a pure function with type like Int -> Int requires changes in everything that uses it. That's the price of static typing. There are a lot of tricks to make that more bearable (monads and do-notation) but, you're right, refactoring requires some work until you make all the type signatures work. Exceptions are a pain in Haskell. It's hard to get them to work in an intuitive way with laziness, and it's unclear how they'd interact with a type system. In an ideal world, Int -> Int would mean a function that can't throw an exception. Of course, there are very few people who want to live in a world where division has a type signature of Int -> Int -> Maybe Int, and it's not clear what else to do (but throw an exception, or hard-crash) in the case of unhandled division-by-zero. Haskell has an exception system but it's hard to use because of laziness and some other factors. The more idiomatic error handling is to use the Either type: Either l r = Left l | Right r where Left corresponds to the erroneous case and Right to the successful path. Either is a monad in the latter argument so you can use do notation to make it "look imperative". The third issue I remember was that all fields' names are global. They're specific to the module you're writing in. If you import a whole module (which you generally shouldn't, except in ghci) then you'll often have collisions. All of this makes it very hard to write the minimal working code now and extend it later. I wouldn't necessarily use Haskell for a small project. Python or Clojure are great tools, and dynamic typing (IMO) is perfectly fine until you get into thousands of LoC. Of course, if you like static typing (which I do) and want to learn more about it, you can certainly use Haskell for small projects and it will work just fine... but it's more efficient (if you're not familiar with Haskell) to use Python or Clojure. Maybe there's some True Way of using Haskell which doesn't suffer from these issues, but I haven't found it. It took me a while to "get" the elegance of Haskell. It forces you to program in a different way: small functions, minimal interleaving of stateful computations (IO) and stateless ones. It can be very concise and beautiful, but it's very different from other languages, even other high-power ones like Clojure.
- deleted 12y ago[deleted]
- a-saleh 12y agoWhen "Getting it Done with Haskell", how do you solve the JavaScript problem? :)
- DanWaterworth 12y agoThere are various Haskell-to-js compilers: ghcjs, uhc, etc. There's also idris and elm.
- octagonal 12y agoPurescript.
- johan_larson 12y agoThere's a page that describes a range of solutions: http://www.haskell.org/haskellwiki/The_JavaScript_Problem http://www.haskell.org/haskellwiki/The_JavaScript_Problem
- a-saleh 12y agoDo you use some of them in production? I.E. I have fooled around with elm, but that is about it.
- gohrt 12y agoAfter spending a day installing virtual machines and cabal sandboxes, my verdict: Until Haskell ecosystem stabilizes and it is possible to install a complex (many dependencies) library/tool without hitting cabal-version hell, nothing much will get done in Haskell. Highlights from my day, installing released packages on my Mac: 1. next goal: scion-browser (user goal) rejecting: scion-browser-0.3.1, 0.3.0, 0.2.19, 0.2.18, 0.2.17, 0.2.16, 0.2.15, 0.2.14, 0.2.13, 0.2.12, 0.2.11, 0.2.10, 0.2.9, 0.2.8, 0.2.7, 0.2.6, 0.2.5, 0.2.3, 0.2.2, 0.2.1, 0.1.3.4, 0.1.3.3, 0.1.3.2, 0.1.3.1, 0.1.3 (conflict: aeson => text==1.1.0.0/installed-9bd..., scion-browser => text==0.11.*) 2. cabal: The following packages are likely to be broken by the reinstalls: unordered-containers-0.2.4.0 case-insensitive-1.1.0.3 network-2.4.2.3 HTTP-4000.2.10 Use --force-reinstalls if you want to install anyway. 3. [2 of 7] Compiling Language.Haskell.BuildWrapper.GHCStorage ( src/Language/Haskell/BuildWrapper/GHCStorage.hs, dist/dist-sandbox-7b4470b7/build/Language/Haskell/BuildWrapper/GHCStorage.o ) src/Language/Haskell/BuildWrapper/GHCStorage.hs:305:32: Not in scope: data constructor ‘MatchGroup’ 4. Resolving dependencies... (searching the entire graph of dependencies, trying in vain for mny minutes, to find a set of package versions that are mutually compatible)