BM Category Theory 6: Functors & Examples

6.1 

Discrete Category:  no other Morphism except the Identity Morphism. 

Functor between 2 categories : preserve structures.

6.2 Examples of functors

In-lining & Refactoring (in Pure Function)

1. In-lining: function f = function g
Replace everywhere in the program each f by g.

2. Re-factoring: In the program: {expressions}
We can define a function h = {expresions}, then use h throughout.

class Functor f where
\boxed {fmap : : (a \to b) \to (f a \to f b)}

Examples of Functors:

1. List

2. Reader

Functor (esp. Endo-functor) can be viewed as a Container where you can opetate on its content. Eg. Functor List [1 ..] = container of 1 2 3 … infinity, operared on it by generating (lazily) the next number.

Illustrations of Functors and Monad (Endo-functors): a “wrapped container”.

http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html#functors

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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