git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Added rules to the Semigroupoid and Category classes, partially addressing #852
c37a697JP Smith
prelude/prelude.purs+22
@@ -61,6 +61,14 @@ module Prelude
61 infixr 9 >>>
61 infixr 9 >>>
62 infixr 9 <<<
62 infixr 9 <<<
63
63
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+ -- |
64 class Semigroupoid a where
72 class Semigroupoid a where
65 (<<<) :: forall b c d. a c d -> a b c -> a b d
73 (<<<) :: forall b c d. a c d -> a b c -> a b d
66
74
@@ -70,6 +78,20 @@ module Prelude
70 (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
78 (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
71 (>>>) f g = g <<< f
79 (>>>) f g = g <<< f
72
80
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+ -- |
73 class (Semigroupoid a) <= Category a where
95 class (Semigroupoid a) <= Category a where
74 id :: forall t. a t t
96 id :: forall t. a t t
75
97