[Haskell-cafe] Re: what is inverse of mzero and return?

Jorge Adriano Aires jadrian at mat.uc.pt
Mon Jan 24 15:28:16 EST 2005

> Right, but we are dealing with the type system here. Remember Haskell
> monoids are functors on types, not on values ... (ie the base objects the
> 'category theory' is applied to are the types not the values)...
> Therefore we only consider the types when considering Monads.

How so? Functors map morphisms and objects from one category into another.

class Functor f where 
  fmap :: (a->b) -> f b -> f a 

We have the two maps there. 
- The type constructor, maps the objects  (types).
- The fmap higher order function, maps the morphisms (function between types).

Monads are, in particular, functors. So again, the type constructor maps the 
objects (types) and the mapping on morphisms (functions from one type to the 
other) is given by liftM (that is, fmap = liftM).

Like Ashley Yakeley said, we can have many different functions (morphism) 
between two types, namely IO a types.

> As such if you wished to consider the examples you gave distinct, the
> type system would need to distinguish side effects... 

Why? I don't see how side effects make any difference here... How do you 
distinguish morphisms f and g:

f,g :: Int -> Int
f n = 2*n
g n = 2+n


More information about the Haskell-Cafe mailing list