Category Theory in Computing

Table of Contents

1. Introduction

Category theory provides a unifying mathematical framework for understanding computation, types, and program structure through objects, morphisms, and their compositions (Lane 1971).

2. Fundamental Structures

3. Monad Structure

diagram-monad-operations.png

4. Categorical Patterns in Programming

5. Strange Loops and Self-Reference

diagram-strange-loop.png

6. Implementation in Scheme

6.1. Category as Record

(define-record-type <category>
  (make-category objects morphisms compose identity)
  category?
  (objects category-objects)
  (morphisms category-morphisms)
  (compose category-compose)
  (identity category-identity))

(define-record-type <functor>
  (make-functor source target fmap)
  functor?
  (source functor-source)
  (target functor-target)
  (fmap functor-fmap))

(define (functor-map F f)
  "Apply functor F to morphism f"
  ((functor-fmap F) f))

7. Applications

  • Type systems (Hindley-Milner as adjunction) (Lambek and Scott 1986)
  • Functional reactive programming
  • Database query optimization
  • Concurrent and distributed systems
  • Effect systems and algebraic effects (Plotkin and Power 2003)

8. References

Lambek, Joachim, and Philip J. Scott. 1986. Introduction to Higher Order Categorical Logic. Cambridge University Press.
Lane, Saunders Mac. 1971. Categories for the Working Mathematician. Vol. 5. Graduate Texts in Mathematics. Springer.
Plotkin, Gordon, and John Power. 2003. “Algebraic Operations and Generic Effects.” In Applied Categorical Structures, 11:69–94.