Functors, Applicatives, And Monads In Pictures - adit.io. Updated: May 20, 2013 Here's a simple value: And we know how to apply a function to this value: Simple enough.

Lets extend this by saying that any value can be in a context. For now you can think of a context as a box that you can put a value in: Now when you apply a function to this value, you'll get different results depending on the context. Data Maybe a = Nothing | Just a. Slamdata/purescript-halogen.

Haskell Matrices. A Monad in Practicality: Controlling Time - Soreλ\a's Basement. Concurrency is quite a big deal, specially these days where everything must be “web scale.”

There are several models of concurrency, each with their own pros and cons, in this article I present a composable alternative to the widespread non-blocking model of concurrency, which generally uses Continuation-Passing style where each computation accepts a “continuation” or “callback,” instead of returning the result of the computation to the caller.

In a language where some computations return a value to the caller and some take a continuation as an argument, we can’t really apply our well-established and general compositional operators, such as function composition, because the rules they rely on have been broken. This is why things may quickly descend into callback-hell and spaghetti of callsite-specific functionality — we lose all of the organisational patterns we are used to. Note: Previous knowledge of monads or category theory are not necessary to read this blog post. 1. 2. 2.1. Typeclassopedia. By Brent Yorgey, byorgey@cis.upenn.edu Originally published 12 March 2009 in issue 13 of the Monad.Reader.

Ported to the Haskell wiki in November 2011 by Geheimdienst. This is now the official version of the Typeclassopedia and supersedes the version published in the Monad.Reader. Please help update and extend it by editing it yourself or by leaving comments, suggestions, and questions on the talk page. The standard Haskell libraries feature a number of type classes with algebraic or category-theoretic underpinnings. The goal of this document is to serve as a starting point for the student of Haskell wishing to gain a firm grasp of its standard type classes. Have you ever had any of the following thoughts? What the heck is a monoid, and how is it different from a monad? If you have, look no further!

There are two keys to an expert Haskell hacker’s wisdom: Understand the types. The second key—gaining deep intuition, backed by examples—is also important, but much more difficult to attain. Merging, Folding, Monoids, and Foldable. I recently had need to merge a collection of sorted lists.

The task is simple enough, but as usual, in Haskell it was particularly pleasant, and lead to some interesting discoveries about folding and monoids. The code is available here, if you want to fiddle with it as you read. Start with simply merging two (presumed) sorted lists. The Implementation of Functional Programming Languages.

Patterns in Functional Programming. Prompted by some recent work I’ve been doing on reasoning about monadic computations, I’ve been looking back at the work from the 1990s by Phil Trinder, Limsoon Wong, Leonidas Fegaras, Torsten Grust, and others, on monad comprehensions as a framework for database queries.

The idea goes back to the adjunction between extension and intension in set theory—you can define a set by its extension, that is by listing its elements: or by its intension, that is by characterizing those elements: Expressions in the latter form are called set comprehensions. They inspired a programming notation in the SETL language from NYU, and have become widely known through list comprehensions in languages like Haskell. The structure needed of sets or of lists to make this work is roughly that of a monad, and Phil Wadler showed how to generalize comprehensions to arbitrary monads, which led to the “do” notation in Haskell. List comprehensions. Procrustean Mathematics. This post is a bit of a divergence from my norm.

I'm going to editorialize a bit about mathematics, type classes and the tension between different ways of fitting ideas together, rather than about any one algorithm or data structure. I apologize in advance for the fact that my examples are written from my perspective, and as I'm writing about them unilaterally my characterization is likely to be unfair. Something in here is likely to offend everyone. Generalized Abstract Nonsense The term "generalized abstract nonsense" was originally coined by Norman Steenrod as a term of endearment, rather than of denigration. e.g.

Now, some mathematicians like to refer to category theory as generalized abstract nonsense, not out of endearment, but because they do not find immediate value in its application. To me category theory serves as a road map to new domains. With this, I can work with them and derive useful results without caring about irrelevant details and dealing with rope burn. m <> _ = m Close. Typeclassopedia.

Parallelism. Generics. FRP. Monads. Monoids.