Any programming languages based on lambda calculus (Haskell, (OCa)ML, Clean, Coq, Agda) forms a category -- in many different ways, in fact. One way is to have an object for each type of the language and a morphism for each well-typed expression with exactly one free variable. If the programming language has linear types then this category will not have a terminal object, since such an object would imply the ability to "discard" a value of any type.
Linear types are extremely useful in giving pure functional programming languages the ability to express side-effecting operations. Loosely, you have a linear type called "world"; every impure function both takes and returns a value of that type (and perhaps other values too). Since you can't duplicate or discard a "world", its handling imposes a deterministic evaluation order on all of the impure functions, and program transformations will not alter this order. The aggregate result of the side effects can then be reasoned about (formally, even).
No comments:
Post a Comment