git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Added rules to the Semigroupoid and Category classes, partially addressing #852
commitc37a6979bf20c314806fe8d1884992a5a4413273 authorJP Smith <jp.smith@ilstu.edu> dateMon 23 Feb 2015, 14:25 (12 years ago) parentf4b3ae8
1 file changed+22
prelude/prelude.purs+22
prelude/prelude.purs+22
@@ -61,6 +61,14 @@ module Prelude
6161 infixr 9 >>>
6262 infixr 9 <<<
6363
64+ -- | Semigroupoids are Categories, less `id`, which is to say they consist of objects and
65+ -- | morphisms between them which can be composed.
66+ -- |
67+ -- | Semigroupoids should obey the following rule:
68+ -- |
69+ -- | Association
70+ -- | forall p q r. p <<< (q <<< r) = (p <<< q) <<< r
71+ -- |
6472 class Semigroupoid a where
6573 (<<<) :: forall b c d. a c d -> a b c -> a b d
6674
@@ -70,6 +78,20 @@ module Prelude
7078 (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
7179 (>>>) f g = g <<< f
7280
81+ -- | Categories consist of objects and composable morphisms between them, and as such are
82+ -- | semigroupoids, but unlike semigroupoids must have an identity element.
83+ -- |
84+ -- | Categories should obey the following rules.
85+ -- |
86+ -- | Association (as semigroupoids)
87+ -- | forall p q r. p <<< (q <<< r) = (p <<< q) <<< r
88+ -- |
89+ -- | Left Identity
90+ -- | forall p. id <<< p = p
91+ -- |
92+ -- | Right Identity
93+ -- | forall p. p <<< id = p
94+ -- |
7395 class (Semigroupoid a) <= Category a where
7496 id :: forall t. a t t
7597