dron
dron

Reputation: 61

Why define the unit natural transformation for a monad - isn't this implied by the definition of monad being an endofunctor?

  1. A monad is defined as an endofunctor on category C. Let's say, C has type int and bool and other constructed types as objects. Now let's think about the list monad defined over this category.

By it's very definition list then is an endofunctor, it maps (can this be interpreted as a function?) an int type into List[int] and bool to List[bool] of and maps (again a function?) a morphism int -> bool to List[int] -> List[bool]

So, far, it kind of makes sense. But what throws me into deep confusion is the additional definitions of natural transformations that need to accompany it: a. Unit...that transforms int into List[int] (doesn't the definition of List functor already imply this? This is one major confusion I have

b. Does the List functor always have to be understood as mapping from int to List[int] not from int to List[bool]?

c. Is the unit natural transformation int to List[int] different from map from int to List[int] implied by defining List as a functor? I guess this is just re-statement of my earlier question.

Upvotes: 5

Views: 406

Answers (2)

drr
drr

Reputation: 101

Well, what is really confusing is, functor F between Cat A and Cat B isdefined as:

a mapping:

  1. F maps A to F(A) --- does it mean new List()? or why not?
  2. and F maps F(f) : F(A) -> F(B)

This is how I see those as being defined in the books. Point #1 above (F maps A to F(A)) - that reads to me like a morphism to convert A into F(A). If that is the case, why do we need unit natural transformation, to go from A to F(A)?

What is very curious is that the functor definition uses the word map (but does not use the word morphism). I see that A to F(A) is not called a morphism but a map.

Upvotes: 0

Eduardo Pareja Tobes
Eduardo Pareja Tobes

Reputation: 3120

Unit is a natural transformation from the Identity functor on C to List; in general, a natural transformation a: F => G between two parallel functors F,G : X -> Y consists of

  1. for each object x: X of the domain, a morphism a_x : Fx -> Gx
  2. plus a naturality condition relating the action of F and G on morphisms

you should thought of a natural transformation as above as a way of "going" from F to G. Applying this to your unit for List situation, Unit specifies for each type X a function Unit_X : X -> List[X], and this is just viewing instances of your type as List[X] instances with one element.

I don't understand what you're asking exactly on b. but with respect to c. they're completely different things. There is no map from int to List[int] implied at the definition; what the definition gives you is, for each map f: X -> Y, a map List(f) : List[X] -> List[Y]; what Unit gives you is a way of viewing any type X as some particular kind of Lists of X's, those with one element.

Hope it helps; from the List[] notation you use, maybe you come from a Scala/Java background, if this is the case you may find this intro to category theory in Scala interesting: http://www.weiglewilczek.com/blog/?p=2760

Upvotes: 3

Related Questions