Monad.Reader #13 is out!

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!

About Brent

Assistant Professor of Computer Science at Hendrix College. Functional programmer, mathematician, teacher, pianist, follower of Jesus.
This entry was posted in haskell, teaching, writing and tagged , , , . Bookmark the permalink.

10 Responses to Monad.Reader #13 is out!

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

  2. Shahbaz says:

    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!

  3. Paul says:

    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!

    • Brent says:

      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. =)

  4. leeduhem says:

    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 => …’

    • leeduhem says:

      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.

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

  6. 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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s