TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Functional Programming Patterns

257 pointsby iqueover 10 years ago

17 comments

telover 10 years ago
This is one of the reasons why Higher-Kinded Types are such a boon in the languages which have them. It allows you to translate &quot;patterns&quot; into straight-up libraries. This slideshow is good documentation for what the patterns are, but if you go use them in Haskell (e.g.) then you&#x27;ll start to see that libraries are designed to completely contain that pattern and ensure compatibility between your use of it and others.<p>Usually this is achieved by representing the pattern exactly in the language. Usually the patterns are just maths. Usually math happily quantifies over higher-kinded types. Thus, you really want HKTs in your language.<p>And to be fair, Haskell does not go tremendously far in this direction. The languages which will truly profit from this are still in gestation.
评论 #8677182 未加载
adwfover 10 years ago
I quite liked the types section, particularly the bit about making illegal states unrepresentable so you can enforce business rules, eg. validating email addresses.<p>One of the things I&#x27;m always thinking when people talk about the merits of various type systems and the problems they solve is: &quot;But I don&#x27;t have those problems&quot;. However, there are a few good examples in there that opened my eyes a little and I&#x27;ll give type-centric programming a go on my next project. Not necessarily solving problems that I have, but certainly presenting a different, hopefully clearer, way of writing some functionality.
virtualwhysover 10 years ago
Excellent presentation. Of the leading type safe functional languages (Haskell, F#, and OCaml) I find F# to be far and away the most accessible in terms of syntax and application.<p>Writing Scala in my day job currently (which, for the most part, I quite enjoy) but can see jumping ship if Microsoft&#x27;s move to Linux is successful. Being able to develop and deploy F# applications on Linux with full blown Type Providers and <i>decent</i> IDE support? Pretty compelling combo, and that&#x27;s just the tip of the iceberg.
评论 #8677058 未加载
评论 #8678434 未加载
评论 #8677042 未加载
评论 #8677436 未加载
skybrianover 10 years ago
These slides explain the usual functional patterns but it seems like a bit of a cheat, because it doesn&#x27;t really explain how to do anything hard (dealing with time, persistence, logging, and so on).<p>The comparison between Slides 81 and 82 is particularly unfair because the &quot;object soup&quot; actually does deal with the database, SMTP, and so on and the functional version doesn&#x27;t. If you add those in, you&#x27;re going to get something complicated: perhaps a bunch of monad transformers or some such?<p>Slide 104 is misleading. In an imperative language, you can write a decorator function that logs a function&#x27;s inputs and outputs, and it will have the same API. In a pure language, you can&#x27;t do that because a function that does I&#x2F;O has a different type. The flexibility or sloppiness (depending on your point of view) that allows you to do I&#x2F;O anywhere is really a feature of imperative languages rather than pure functional languages.
评论 #8678242 未加载
评论 #8678437 未加载
zniperrover 10 years ago
A good read, I especially like the parts about error handling and maps&#x2F;applicatives. They are well-illustrated and tackle some difficult common problems I had shortly after I started using functional languages.<p>The part about functors&#x2F;monads&#x2F;monoids is also nice, although I feel like it would be better with the accompanying talk to bind it together a bit more.
评论 #8676941 未加载
fbombover 10 years ago
The talk is here: <a href="https://skillsmatter.com/skillscasts/4971-domain-driven-design-with-scott-wlaschin" rel="nofollow">https:&#x2F;&#x2F;skillsmatter.com&#x2F;skillscasts&#x2F;4971-domain-driven-desi...</a>
评论 #8676942 未加载
taericover 10 years ago
Ok, I&#x27;m sure the slides get better as they go on. But what the hell? The difference between the patterns that are compared and contrasted are... well, tenuous, at best.<p>Seriously, it gives off the impression not that these are going to be better patterns. But that someone simply has a bias against &quot;patterns&quot; as they are promoted in Java and then rails against it saying that they are going back to the root of the word patterns. Ignoring that this is the same path.
estefanover 10 years ago
This a good read. I like the railway analogy.<p>&quot;Functional Programming in Scala&quot; is also well worth a read as well if you&#x27;re trying to learn FP... I&#x27;ve found it to be excellent, especially since it has lots of exercises to use for practice.
robert_tweedover 10 years ago
There&#x27;s a book with the same name plus &quot;... In Scala and Clojure&quot;. It is based on the wrong sort of patterns (trying to shoehorn GoF into FP). This presentation is much more what I had hoped that book was going to be.
KurtMuellerover 10 years ago
I am currently taking EdX&#x27;s Intro to Functional Programming mooc, taught by Erik Meijer (with his crazy shirts), which uses Haskell to teach functional programming concepts.<p>I am wondering if there are any other good resources for teaching the functional programming paradigms. Anybody care to recommend me some resources?<p>Also, I mainly work with Ruby and Javascript in my full time job. Currently, in school, I use Java (in the context of Android, which is on Java 6) and Objective-C (iOS programming). If anybody has any resources regarding functional programming and the previously mentioned languages, it would be most appreciated.<p>Thanks people!
评论 #8677466 未加载
评论 #8696311 未加载
评论 #8676927 未加载
评论 #8677332 未加载
fdsaryover 10 years ago
I thank the lord every day that the language I work in (Javascript) supports functions! I try to write pure functions as often as possible, so it&#x27;s easy to refactor the code when I come back three months later.<p>But is there, except for Clojurescript, any true (like Haskell) FP language for browsers? Something that has the tools, and community to back it, so it&#x27;s viable to actually make projects in it?
评论 #8676651 未加载
评论 #8676749 未加载
评论 #8676649 未加载
评论 #8676870 未加载
评论 #8676715 未加载
mercurialover 10 years ago
Interesting but not always correct.<p>Eg: slide 64 encourages the reader to &quot;Using sum vs inheritance&quot;, and then goes on to show the &quot;good&quot; algebraic datatypes (no behaviour, just data) vs the &quot;bad&quot;... multiple class implementing the same interface (which I wouldn&#x27;t call inheritance).
1971genocideover 10 years ago
I Really found the book &quot;Learn you a haskell&quot; to be an really fast way to get functional programming into production.<p>I did not however continue to use haskell since it doesnt have key libraries I need.<p>I instead adopted livescript,underscore into javascript and was good to go.
评论 #8678610 未加载
nathellover 10 years ago
For some reason, when I got to slide 16 I immediately thought &quot;Scala.&quot;
dschiptsovover 10 years ago
Some guy almost 20 years ago argued, that if you end up with a bunch of &quot;design patterns&quot; then your language is not good enough.)<p><a href="http://norvig.com/design-patterns/design-patterns.pdf" rel="nofollow">http:&#x2F;&#x2F;norvig.com&#x2F;design-patterns&#x2F;design-patterns.pdf</a>
评论 #8677013 未加载
评论 #8676993 未加载
评论 #8676965 未加载
k__over 10 years ago
lol, the Patterns of GoF seemed like those of tailoring to me.
ExpiredLinkover 10 years ago
Patterns exist to compensate for a programming language’s lack of expressiveness!
评论 #8676831 未加载
评论 #8677407 未加载