2020-08-15 15:27:27 +03:00
|
|
|
module Control.Category
|
|
|
|
|
|
|
|
import Data.Morphisms
|
|
|
|
|
|
|
|
|
|
|
|
public export
|
2021-02-10 11:08:16 +03:00
|
|
|
interface Category (0 cat : obj -> obj -> Type) | cat where
|
2020-08-15 15:27:27 +03:00
|
|
|
id : cat a a
|
|
|
|
(.) : cat b c -> cat a b -> cat a c
|
|
|
|
|
|
|
|
public export
|
|
|
|
Category Morphism where
|
|
|
|
id = Mor id
|
|
|
|
-- disambiguation needed below, because unification can now get further
|
|
|
|
-- here with Category.(.) and it's only interface resolution that fails!
|
|
|
|
(Mor f) . (Mor g) = Mor $ Basics.(.) f g
|
|
|
|
|
|
|
|
public export
|
|
|
|
Monad m => Category (Kleislimorphism m) where
|
|
|
|
id = Kleisli (pure . id)
|
|
|
|
(Kleisli f) . (Kleisli g) = Kleisli $ \a => g a >>= f
|
|
|
|
|
|
|
|
infixr 1 >>>
|
|
|
|
|
|
|
|
public export
|
|
|
|
(>>>) : Category cat => cat a b -> cat b c -> cat a c
|
|
|
|
f >>> g = g . f
|