Issue 13 of the Monad.Reader, which includes a revised version of the Typeclassopedia, is out. This version of the Typeclassopedia contains many updates and revisions. There are also three other great articles in this issue of the Monad.Reader, I hope you’ll check it out!

### Pages

### Categories

- abstraction AC announcement applicative art axiom of choice Beeminder Bell numbers blogging BlogLiterately category category theory collaborative editing combinatorial combinatorial species combinatorics constructive cycles darcs data diagrams differentiation dissertation drawing DSL EDSL feedback FringeDC functional functional programming functor GHC ghci grad school graphics hackathon Hac φ haskell ICFP isomorphism knowledge library list lists monad Monad.Reader monads monoid monoids music partitions patch theory pedagogy Philadelphia pictures preorder productivity programming QuickCheck reading release species talk text theory translation tutorial type-level type classes Typeclassopedia types unique UPenn workshop xmonad
### Archives

- June 2015 (3)
- May 2015 (2)
- April 2015 (1)
- March 2015 (1)
- August 2014 (3)
- June 2014 (2)
- May 2014 (2)
- January 2014 (2)
- October 2013 (1)
- August 2013 (1)
- July 2013 (1)
- May 2013 (1)
- April 2013 (3)
- March 2013 (2)
- January 2013 (2)
- December 2012 (2)
- November 2012 (4)
- October 2012 (3)
- August 2012 (4)
- July 2012 (5)
- June 2012 (1)
- March 2012 (1)
- January 2012 (1)
- November 2011 (4)
- October 2011 (3)
- September 2011 (2)
- August 2011 (2)
- July 2011 (2)
- June 2011 (1)
- May 2011 (6)
- April 2011 (2)
- March 2011 (1)
- February 2011 (3)
- January 2011 (1)
- December 2010 (2)
- November 2010 (3)
- October 2010 (1)
- September 2010 (1)
- August 2010 (3)
- July 2010 (2)
- June 2010 (3)
- May 2010 (3)
- April 2010 (3)
- March 2010 (2)
- February 2010 (1)
- January 2010 (1)
- December 2009 (2)
- October 2009 (3)
- September 2009 (2)
- August 2009 (4)
- July 2009 (7)
- June 2009 (1)
- May 2009 (2)
- April 2009 (1)
- March 2009 (2)
- February 2009 (3)
- January 2009 (3)
- December 2008 (2)
- September 2008 (2)
- August 2008 (1)
- July 2008 (3)
- June 2008 (1)
- April 2008 (4)
- March 2008 (4)
- February 2008 (4)
- January 2008 (2)
- December 2007 (4)
- October 2007 (2)
- September 2007 (2)
- August 2007 (3)
- June 2007 (2)

### Top Posts

### Blogroll

### Fun

### Personal

### Meta

Pingback: The Typeclassopedia — request for feedback « blog :: Brent -> [String]

I just read through (most) of the Typeclassopedia. As a newbie, I usually try to understand the syntax or monads in isolation. I liked how, not only did you provide a wonderful reference, but also intuitive descriptions and even pointed out where things are the way they are due to historical baggage. This was one of the more readable Monad.Readers (from a newbie’s perspective). Thanks!

Thanks! I’m very glad to hear you found it readable and useful.

I’ve read as far as the start of the section on Monoids, and what a gem it is; an indispensable guide. I appreciate your unifying perspective in particular, and the occasional references to category theory are helpful and generous.

I found your explanation of bind’s “commutativity” excellent, as I’ve always felt a horrible need to scrap my idea of what the c-word means means. The lucid definition of a monad using fish (>=>) nearly brought tears to my eyes :)

The only thing which still throws me is the casual reference to (->). (Mind you I have only recently found out that (,) is a function (though I still wonder why its brackets are always required in infix form)). Anyway, “comma” at least lives in the world of normal expressions, but I’ve only ever seen (->) in type declarations; and :t (->) gives an error :)

Enough already: a brilliant article, and the references will keep me busy too. Thanks!

Hi Paul, glad you’ve enjoyed it!

Part of your confusion, I think, stems from the fact that there are *two different* things called (,) (just like there are two different things called []). Think of it like this:

data (,) a b = (,) a b

The (,) on the left is a *type* constructor which takes two types and creates a new type (a,b). This (,) lives in the world of types. The (,) on the right is a *data* constructor which takes two values and creates a pair value. This is why you can write :t (,) at a ghci prompt. However, you should also try typing :k (,) at a prompt—this will tell you the kind of the type constructor (,) (kinds are just types for types =). Now, (->), on the other hand, is only a type constructor. If you write :k (->) you will see that it has the same kind as (,) (well, except you should imagine that ?? and ? are just *, the question marks are some sort of internal ghc something or other). It can only be applied to types: (->) Int Bool is a type. But the data constructor for (->) doesn’t have the same name, like with (,). In fact, the data constructor for (->) is called… lambda. =)

A great article and source of references, very useful.

I have the similar confusion as Pual about (->), after reading the sources of Control.Monad.Instances, I found myself just can’t understand how instance of Monad ((->) r) works:

instance Monad ((->) r) where

return = const

f >>= k = \ r -> k (f r) r

I guessed ‘return = const’ by type reference, but for (>>=) I can’t work it out this way…

BTW, a bug report:

In Listing 26: ‘instance Monoid a => …’ should be ‘instance Monoid e => …’

After treat lambda (abstraction) as data constructor of type constructor (->), I found I can understand definition of (>>=) in instance Monad ((->) r) by type inference:

(>>=) :: (Monad m) => m a -> (a -> m b) -> m b

let m = (->) r, so f :: m a = (->) r a, k :: (->) a (m b) = (->) a ((->) r b) = a -> r -> b, and suppose f r = a, k a r = b, then I have

f >>= k = \r -> k (f r) r

= \r -> k a r

= \r -> b

= (->) r b

= m b

Hem…a bit misuse of (->) and didn’t distinguish type variables and normal variables, but it works for me.

Nice! And thanks for the bug report.

Pingback: Understanding ‘instance Monad ((->) r)’ by type inference « Control.Monad.Reader

Pingback: Category Theory for the Mathematically Impaired: An Outline of A Short Reading List for “Mathematically-impaired Computer Scientists Trying to Learn Category Theory” « Monadically Speaking: Adventures in PLT Wonderland