[Haskell-cafe] Categories (cont.)

Christopher Howard christopher.howard at frigidcode.com
Thu Dec 20 12:42:09 CET 2012


I've perhaps been trying everyones patiences with my noobish CT
questions, but if you'll bear with me a little longer: I happened to
notice that there is in fact a Category class in Haskell base, in
Control.Category:

quote:
--------
class Category cat where

A class for categories. id and (.) must form a monoid.

Methods

id :: cat a a

the identity morphism

(.) :: cat b c -> cat a b -> cat a c

morphism composition
--------

However, the documentation lists only two instances of Category,
functions (->) and Kleisli Monad. For instruction purposes, could
someone show me an example or two of how to make instances of this
class, perhaps for a few of the common types? My initial thoughts were
something like so:

code:
--------
instance Category Integer where

  id = 1

  (.) = (*)

-- and

instance Category [a] where

  id = []
  (.) = (++)
-------

But these lead to kind mis-matches.

-- 
frigidcode.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 553 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121220/99152000/attachment.pgp>


More information about the Haskell-Cafe mailing list