Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Haskell
Wiki community
Recent changes
Random page
HaskellWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
User:Michiexile/MATH198/Lecture 7
(section)
User page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
User contributions
Logs
View user groups
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Algebraic objects in categories=== We recall the definition of a monoid: '''Definition''' A ''monoid'' is a set <math>M</math> equipped with an operation <math>\mu: M\times M\to M</math> that we call ''composition'' and an operation <math>e: 1\to M</math> that we call the identity, such that * <math>M \circ 1_M \times M = M \circ M \times 1_M</math> (associativity) * <math>M \circ 1_M \times e = M \circ e\times 1_M = 1_M</math> (unity) If we have a ''monoidal category'' - a category <math>C</math> with a bifunctor <math>\otimes: C\times C\to C</math> called the ''tensor product'' which is associative (up to natural isomorphisms) and has an object <math>I</math> acting as a unit (up to natural isomorphisms) for the tensor product. The product in a category certainly works as a tensor product, with a terminal object acting as a unit. However, there is often reason to have a non-commutative tensor product for the monoidal structure of a category. This makes the category a ''cartesian monoidal category''. For, say, abelian groups, or for vector spaces, we have the ''tensor product'' forming a non-cartesian monoidal category structure. And it is important that we do. And for the category of endofunctors on a category, we have a monoidal structure induced by composition of endofunctors: <math>F\otimes G = F\circ G</math>. The unit is the identity functor. Now, we can move the definition of a monoid out of the category of sets, and define a generic ''monoid object'' in a monoidal category: '''Definition''' A ''monoid object'' in a monoidal category <math>C</math> is an object <math>M</math> equipped with morphisms <math>\mu: M\otimes M\to M</math> and <math>e: 1\to M</math> such that * <math>M \circ 1_M \otimes M = M \circ M\otimes 1_M</math> (associativity) * <math>M \circ 1_M \otimes e = M \circ e\otimes 1_M = 1_M</math> (unity) As an example, a monoid object in the cartesian monoidal category <math>Set</math> is just a monoid. A monoid object in the category of abelian groups is a ring. A monoid object in the category of abelian groups, with the tensor product for the monoidal structure is a ''ring''. And the composition <math>UF</math> for an adjoint pair is a monoid object in the category of endofunctors on the category. The same kind of construction can be made translating familiar algebraic definitions into categorical constructions with many different groups of definitions. For ''groups'', the corresponding definition introduces a diagonal map <math>\Delta: G\to G\times G</math>, and an inversion map <math>i: M\to M</math> to codify the entire definition. One framework that formalizes the whole thing, in such a way that the definitions themselves form a category is the theory of Sketches by Charles Wells. In one formulation we get the following definition: '''Definition''' A ''sketch'' <math>S = (G, D, L, K)</math> consists of a graph <math>G</math>, a set of diagrams <math>D</math>, a set <math>L</math> of cones in <math>G</math> and a set <math>K</math> of cocones in <math>G</math>. A ''model'' of a sketch ''S'' in a category <math>C</math> is a graph homomorphism <math>G\to C</math> such that the image of each diagram in <math>D</math> is commutative, each of the cones is a limit cone and each of the cocones is a colimit cocone. A ''homomorphism of models'' is just a natural transformation between the models. ---- We thus define a ''monad in a category <math>C</math>'' to be a monoid object in the category of endofunctors on that category. Specifically, this means: '''Definition''' A ''monad'' in a category <math>C</math> is an endofunctor <math>T: C\to C</math> equipped with natural transformations <math>\mu: T^2\to T</math> and <math>\eta: 1\to T</math> such that the following diagrams commute: [[Image:MonadAssociative.png]] [[Image:MonadUnit.png]] We can take this definition and write it out in Haskell code, as: <haskell> class Functor m => MathematicalMonad m where return :: a -> m a join :: m (m a) -> m a -- such that join . fmap return = id :: m a -> m a join . return = id :: m a -> m a join . join = join . fmap join :: m (m (m a)) -> m a </haskell> Those of you used to Haskell will notice that this is not the same as the <hask>Monad</hask> typeclass. That type class calls for a natural transformation <hask>(>>=) :: m a -> (a -> m b) -> m b</hask> (or <hask>bind</hask>). The secret of the connection between the two lies in the Kleisli category, and a way to build adjunctions out of monads as well as monads out of adjunctions.
Summary:
Please note that all contributions to HaskellWiki are considered to be released under simple permissive license (see
HaskellWiki:Copyrights
for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!
Cancel
Editing help
(opens in new window)
Toggle limited content width