9 ms·
What I Wish I Knew When Learning Haskell
- mercurial 14y agoPretty comprehensive (including plenty of things I haven't had time to look at into more details yet). Bonus points for using applicative style, which makes it a lot easier (and clearer) to apply function to value inside monads.
- cies 14y agoI think these 3 slides really stand out, they show with how little code one can write serious software in Haskell... 1. ACID (acid-compliant persistance on Haskell data types, with indexes) http://dev.stephendiehl.com/hask/#(27) http://dev.stephendiehl.com/hask/#(27) 2. Pipes (program on streams of data) http://dev.stephendiehl.com/hask/#(30) http://dev.stephendiehl.com/hask/#(30) 3. Scotty (micro web-framework, a la Sinatra or Flask, on top of the super fast Warp server) http://dev.stephendiehl.com/hask/#(32) http://dev.stephendiehl.com/hask/#(32)
- cscheid 14y agoAbout your point 3), it's worth noting the "toHtml" call buried in that example. Haskell is both strongly and statically typed. That type boundary between strings and HTML output is enforced by the compiler, and it automatically (and provably!) prevents a metric crapload of injection attacks.
- deleted 14y ago[deleted]
- tel 14y agoTo bring this into sharper detail, notice that there's the "OverloadedStrings" compiler directive at the top of the file. That means that "hello " and "!" are of type Html, different from String. Strings can only be concatenated with Html after they've been escaped. For more elaboration, see http://blog.moertel.com/posts/2006-10-18-a-type-based-solution-to-the-strings-problem.html http://blog.moertel.com/posts/2006-10-18-a-type-based-soluti...
- freyrs3 14y agoHere's an example that brings together Aeson, Lens, Acid-State and Scotty together in one file. Haskell really does have some great offerings for building very solid and fast web applications. [1] https://github.com/sdiehl/haskell-warp-rest/blob/master/server.hs https://github.com/sdiehl/haskell-warp-rest/blob/master/serv...
- drhodes 14y agoThat url is 404, maybe this is the one? https://github.com/sdiehl/haskell-warp-rest/blob/master/warp_rest_example.hs https://github.com/sdiehl/haskell-warp-rest/blob/master/warp...
- avital 14y agoCan acid-state be ported to Javascript?
- arianvanp 14y agoyou could try cross-compiling it with Fay or UHC (haskell to javascript compilers)
- boothead 14y agoYou'd probably need one of the more heavyweight options (e.g. GHCJS). Fay doesn't understand typeclasses afaik, so it's not really suitable for porting haskell libraries verbatim to the browser.
- cies 14y agoMaybe but it does not seem very obvious to do so to me.. I guess one is better off with using JS's localStorage from Fay[1] or Sunroof[2]. 1. http://fay-lang.org http://fay-lang.org 2. https://github.com/ku-fpg/sunroof-compiler/wiki/Tutorial https://github.com/ku-fpg/sunroof-compiler/wiki/Tutorial
- mercuryrising 14y agoHe's got some good stuff on his website (didn't get much from the slides as I've only dabbled in Haskell a couple times). http://www.stephendiehl.com/posts/essential_haskell.html http://www.stephendiehl.com/posts/essential_haskell.html http://www.stephendiehl.com/posts/types.html http://www.stephendiehl.com/posts/types.html
- sid6376 14y agoCan anyone point to a similar list for Scala? I am just getting started in Scala and would love such a list.
- egeozcan 14y agoI would suggest these for the starters: http://shuklan.com/haskell/ http://shuklan.com/haskell/
- mercuryrising 14y agoWow those are some awesome lectures. Thanks!!
- sordina 14y agoThis is very good. I'm getting a bunch of new tricks out of this even though I regularly use these libraries.
- kzrdude 14y agoSome of the slides need explanation. What is the value of -ddump-simpl as shown here? http://dev.stephendiehl.com/hask/#%2816%29 http://dev.stephendiehl.com/hask/#%2816%29
- freyrs3 14y agoIt dumps the internal Core representation of expression. It's closer to the lambda calculus ( System F ) and a good way to understand internals.
- ufo 14y agoAs freyrs points out, GHC "desugars" all Haskell code into a very small intermediate language that is similar to the System F lambda calculus. In the slide you linked you can kind of see that: you start with two doubles for 2 and 3 (created wit the `D#` function) and then you add them with the addition operator. Notice that this exposrs the implementation of typeclasses: the overloaded + operator is actually a function of three arguments and the first argument is the "vtable" that has the actual number operations. I don't know why he is doing all of this though. The slides themselves don't give much context...
- pervycreeper 14y agoIs there a recording of a talk to match these slides?
- yummyfajitas 14y agoThere is a great point buried in slide 8. The best way to learn to use monads is...Use monads in real code.
- theicfire 14y agoRecording would be great! I feel like I only got half of the (good) information without it.
- Kiro 14y agoI'm a PHP developer and I didn't understand one single thing in this presentation. Any reason I should learn Haskell?
- archivator 14y agoFunctional programming is a tool. It's a really powerful tool. Knowing really powerful tools helps you solve really difficult problems. Whether it's Haskell or some other purely functional language, I'm of the opinion that every programmer should have one in their toolset.
- kzrdude 14y agoIt's more than a tool, it's a different programming paradigm. It helps you to look at something in a different way. You can pick up a thing or two that are useful pracitices in other imperative programming languages, too.
- tkahn6 14y agoStart here: http://learnyouahaskell.com/chapters http://learnyouahaskell.com/chapters This is good too, but I found it somewhat dry: http://book.realworldhaskell.org/read/ http://book.realworldhaskell.org/read/ I think that learning Haskell will make you a better programmer. It's really a different way of doing things.
- nnq 14y agoIf PHP is what you use for work (I assume you haven't started programming with PHP, hopefully, so this means you also have knowledge of some C or C++ form long long ago, and of either Perl, Python, Java or C#), learn Scala or Clojure instead! If someone is using Haskell for web apps, he's either really in-love with the language (which is ok, I guess, we're all into different stuff...) and wants to use the "one true language" for everything, or he's engaging in a really hard-core form of intellectual masturbation!
- xaritas 14y agoIf you maintain code that is a gigantic ball of if-foreach-else-switch-is_null or your class hierarchy looks like something a Java developer would produce, and you are constantly thinking "there must be a better way," you might benefit from exploring Haskell or a language with some of its features. PHP is actually one of those languages, since it gained real support for first-class functions, anonymous functions and closures starting with 5.3 and improving with 5.4. So if you do learn Haskell you'll be able to directly apply some of its ideas to making your PHP more concise, easier to test, and less error prone. Check out the PHP Underscore library to provide some of the infrastructure: http://brianhaveri.github.io/Underscore.php/ http://brianhaveri.github.io/Underscore.php/ Haskell brings a lot more to the table than first class functions, and it may or may not be a good introduction to functional programming for you, but other functional(-ish) languages such as Scala or Clojure (or Scheme & other Lisps) will work well, too. Just give it time. It's worth the effort, but you're not going to magically transform your code into the Unicorn Monad overnight. If you do PHP you probably do a lot of JavaScript, too, so there is another language that supports getting into functional programming, and there is definitely a lot of interest in moving JavaScript in more classically functional direction. So you won't be blindsided by maps, folds and promises. I apologize if you already use first class functions like a boss and you were really asking if you needed static type inference. The answer is Maybe.
- thomasjames 14y agoDoes anyone know the best book for learning Haskell? I have heard it is good for just thinking about programming in new ways and keeping your mind agile. I can really only learn a language with a good structured book with exercises at the end of each chapter. Haven't found something definitive yet, but would be open to suggestions.
- jimmyjazz14 14y agoI think "Real World Haskell" is great. If you want a more simple introduction checkout "Learn You a Haskell for Great Good!".
- ericssmith 14y agoThe 'best' introductory book for learning Haskell is Graham Hutton's 'Programming in Haskell'. It focuses on the essentials of the language, and its clear, spare presentation is in the spirit of Haskell itself. And it is accessible to everyone.
- jhickner 14y ago+1 for this, also check out Graham's io9 video on the Counting Problem. The solution is beautiful and really got me excited about Haskell when I was first learning: http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/C9-Lectures-Dr-Graham-Hutton-Functional-Programming-Fundamentals-Chapter-11-of-13 http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Func...
- thomasjames 14y agoI was actually thinking of going with this since it seemed to focus on the foundations of lambda calculus and is also fairly condensed. I was thinking I might try "The Haskell School of Expression: Learning Functional Programming through Multimedia" as a follow up just cause it sounded satisfying.
- ericssmith 14y agoHudak's 'Haskell School of Expression' is also full of much Haskell wisdom and spirit.
- lobster_johnson 14y agoSlides don't work in Sarari on iOS. Is there a static version?
- freyrs3 14y agohttp://dev.stephendiehl.com/hask/flat.html http://dev.stephendiehl.com/hask/flat.html
- lobster_johnson 14y agoFinally a proper answer. Thanks!
- Evbn 14y agoThis is a tech forum. We do cool new stuff, not make stuff accessible to a wide audience using ancient technology from last week.
- lobster_johnson 14y agoiOS is ancient technology now? Is that why you [or whoever] downvoted me? What the hell?
- rtpg 14y agoI disagree completely with his analysis on monads. If you just present the abstract structure, you cannot understand why you even want (for example) the do notation as a language-level concept. I think this is more of a case of bad examples than anything. Trying to represnent monads via analogy works badly too though, because monads as used in haskell are more about programming pragmatics than modelling real world objects. The way to explain it should be : - Show real code - Explain why we use this structure to write our code .I think a good explanation is to ... in Jquery you do things like chaining to build things. $('selector').css('color','red').filter(someFilter).css('color','blue') Chaining APIs are useful because you're combining computation('chaining'), and you don't want to have to carry around a value everywhere. You want to do the same thing in Haskell obviously. Haskell doesn't have dot notation, so you can't do this style exactly. First idea would be to do something like let x=jQuery document selector in let y=css x 'color' 'red' in let z=filter y someFilter in ... This is a pain, especially considering that the 'chaining' here is mechanically obvious let [n+1] = f [n] [whatever] in let [n+2] = g [n+1] .... So monads, in the most pragmatic sense, allow you to represnt this form of computation. You end up with jQuery 'selector' >>= css 'color' 'red' >>= filter someSelector >>= css 'color' blue' You implicitly carry around your computation. ) In any case the Maybe monad is the worst example ever, just like how a singleton group is a bad example. Sure it's the 'simplest' , but it's far from the most typical
- freyrs3 14y agoThe problem with bringing jQuery into the discussion is that it's not a monad. Don Stewart explains this more elegantly than I can [1] but the crux of the argument is that chaining together computations is not enough to be a monad, one needs to prove that the monad laws hold. [1] http://stackoverflow.com/questions/10496932/is-jquery-a-monad/10499668#10499668 http://stackoverflow.com/questions/10496932/is-jquery-a-mona...
- sordina 14y agoThe majority of the 'proofs' I've seen that jQuery isn't a monad seem to either be probabalistic, or use the "Burden of Proof" argument to show that since nobody has proved that jQuery is a monad, we should assume that it isn't. I agree that jQuery probably isn't a monad, but it rubs me the wrong way that people aren't willing to say "It has yet to be determined if jQuery is a monad". Obviously it is trivial to show that it isn't a monad by the fact that javascript permits any action in pure code, but by the same token, unsafePerformIO proves that Haskell has no monads. I think it's fair to operate under a reasonable subset of jQuery functionality when asking the question.
- rtkwe 14y agoNothing like getting a pile of slides without any presenter notes or anything else helping to interpret the slides.
- mwerty 14y agoI first learnt Haskell ten years ago for a class. Mostly toy problems. Looking to get back into it. What books are good to learn to build actual apps - especially user input, UI, etc.?
- cies 14y agorealworldhaskell is good for general purpose. i think the yesod o'reilly book (free on yesodweb.com) is a very good one if you dont mind to make web apps.
- simpsond 14y agoThis post somehow triggered me to grab "Learn You a Haskell for Great Good" this morning and I have been gorging on it since then. I've had quite a few "holy shit" moments.
- yayitswei 14y agoI saw a blank page and immediately thought "how poetic".
- Uchikoma 14y ago"Haskell Propaganda: OOP programming couples code and data together in unnatural ways. Typeclasses are a better way of structuring logic." should be "Inheritance couples code and data together in unnatural ways. Typeclasses are a better way of structuring logic."
- papsosouid 14y agoHow so? An OOP language without inheritance would still be coupling code and data together "in unnatural ways". It is the object that is doing the coupling, not inheritance.