Skip to content
Snippets Groups Projects
Commit 076c1a10 authored by Bodigrim's avatar Bodigrim Committed by Marge Bot
Browse files

documentation: more examples for Control.Category

parent fbbbd010
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,26 @@ infixr 1 >>>, <<<
-- f . g = \\x -> f (g x)
-- @
--
-- Isomorphisms form a category as well:
--
-- @
-- data Iso a b = Iso (a -> b) (b -> a)
--
-- instance Category Iso where
-- id = Iso id id
-- Iso f1 g1 . Iso f2 g2 = Iso (f1 . f2) (g2 . g1)
-- @
--
-- Natural transformations are another important example:
--
-- @
-- newtype f ~> g = NatTransform (forall x. f x -> g x)
--
-- instance Category (~>) where
-- id = NatTransform id
-- NatTransform f . NatTransform g = NatTransform (f . g)
-- @
--
-- Using the `TypeData` language extension, we can also make a category where `k` isn't
-- `Type`, but a custom kind `Door` instead:
--
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment