##### Views

(Difference between revisions)

Hask refers to a category with types as objects and functions between them as morphisms. However, its use is ambiguous. Sometimes it refers to Haskell (actual Hask), and sometimes it refers to some subset of Haskell where no values are bottom and all functions terminate (platonic Hask). The reason for this is that platonic Hask has lots of nice properties that actual Hask does not, and is thus easier to reason in.

Actual Hask does not have sums, products, or an initial object, and
()
is not a terminal object. The Monad identities fail for almost all instances of the Monad class.
Why Hask isn't as nice as you'd thought.
Initial Object Terminal Object Sum Product
Definition There is a unique function
u :: Empty -> r
There is a unique function
u :: r -> ()
For any functions
f :: a -> r
g :: b -> r

there is a unique function

u :: Either a b -> r

such that:

u . Left = f
u . Right = g
For any functions
f :: r -> a
g :: r -> b

there is a unique function

u :: r -> (a,b)

such that:

fst . u = f
snd . u = g
Platonic candidate
u1 r = case r of {}
u1 _ = ()
u1 (Left a) = f a
u1 (Right b) = g b
u1 r = (f r,g r)
Example failure condition
r ~ ()
r ~ ()
r ~ ()
f _ = ()
g _ = ()
r ~ ()
f _ = undefined
g _ = undefined
Alternative u
u2 _ = ()
u2 _ = undefined
u2 _ = ()
u2 _ = undefined
Difference
u1 undefined = undefined
u2 undefined = ()
u1 _ = ()
u2 _ = undefined
u1 undefined = undefined
u2 undefined = ()
u1 _ = (undefined,undefined)
u2 _ = undefined
Result FAIL FAIL FAIL FAIL