posted Oct 7, 2009 2:18 PM by Wei Hu
posted Mar 20, 2009 9:25 AM by Wei Hu
[
updated Mar 23, 2009 2:47 PM
]
A functor F: C->D between categories C and D maps any object A in C to F(A) in D, and maps any morphism f:A->B in C to F(f):F(A)->F(B) in D. Functors must obey two laws: F(idA) = idF(A), F(f . g) = F(f) . F(g). We say that functors preserve the structural properties of categories.
A functor F: A->A is called endofunctor.
The standard Functor type class in Haskell is not general enough. There, the type constructor is the action on objects (types), and fmap is the action on morphisms (functions). A generalized Functor' can be defined as: class Functor' arr arr' f where fmap' :: arr a b -> arr' (f a) (f b) instance (Functor f) => Functor' (->) (->) f where fmap' = fmap |
posted Mar 11, 2009 9:30 PM by Wei Hu
Given the definition, -- | Left-to-right Kleisli composition of monads. (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c) f >=> g = \x -> f x >>= g
The monad laws can be written as return >=> g == g g >=> return == g (g >=> h) >=> k == g>=> (h >=> k)
So, functions of type a -> m b are the arrows of a category with (>=>) as composition, and return as identity. |
posted Feb 22, 2009 2:06 AM by Wei Hu
[
updated Feb 28, 2009 9:16 PM
]
Suppose f is a map: A->B.
f is an isomorphism, if there is a map g : B->A, g.f = 1A and f.g = 1B.
g is called an inverse for f.
A map has at most one inverse.
If there is a map g: B->A, f.g = 1B, then g is a section for f, and f is a retraction for g.
If f has both a section s and a retraction r, then r = r.(f.s) = (r.f).s = s.
f is monoic, or a monomorphism, if for any T, and any pair of maps g, h: T->A, f.g = f.h implies g = h. If f has a retraction, then it can be proved that f is monoic.
f is epic, or an epimorphism, if for any T, and any pair of maps g, h: B->T, g.f = h.f implies g = h. If f has a section, then it can be proved that f is epic.
An endomap e is called idempotent if e.e = e.
A splitting of an idempotent e: B->B consists of another object A, and two maps s:A->B, r:B->A, such that r.s = 1 and s.r = e. For the category of Sets, such splitting always exists, as shown below.
|
posted Feb 13, 2009 8:11 PM by Wei Hu
[
updated Feb 22, 2009 2:06 AM
]
- An object in this category is a finite set.
- A map (function, transformation, operator, arrow, or morphism) maps one object to another. For the Set Category, a map is a standard function from the domain to the codomain.
- For each pair of maps, there is a composition map. In other words, the category needs to be closed under the composition operation.
- An endomap has the same domain and codomain.
- For each set A, there is a special endomap, called an identity map, so that for each a in A, f(a) = a. We denote it 1A. This definition is kinda specialized here. The real definition only requires 1A to obey the identity law, and nothing more. That is, the map is defined in terms of its relations with other maps, not with the set elements.
The identity map must obey the identity law. Compositions must obey the associative law. These two laws look just the same as the Monoid Law to me. These two laws automatically holds for the Set Category.
A singleton set is called 1. A point of a set X is a map 1 -> X. |
|