-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
package frege.control.Category | ||
inline (F.•, F.id) | ||
package frege.control.Category | ||
inline (F.id) | ||
where | ||
|
||
import frege.Prelude hiding (id, .) -- will not be necessary | ||
import frege.Prelude hiding (id) -- will not be necessary | ||
import frege.control.Semigroupoid | ||
|
||
private type F = (->) | ||
|
||
--- A class for categories. id and (.) must form a monoid. | ||
class Category f where | ||
class Category (Semigroupoid f) => f where | ||
--- the identity morphism | ||
id :: f a a | ||
|
||
--- morphism composition | ||
(.) :: f b c -> f a b -> f a c | ||
|
||
infixr 1 `>>>` | ||
infixr 1 `<<<` | ||
|
||
--- Right-to-left composition | ||
(<<<) :: Category f => f b c -> f a b -> f a c | ||
(<<<) = (.) | ||
|
||
--- Left-to-right composition | ||
(>>>) :: Category f => f a b -> f b c -> f a c | ||
f >>> g = g . f | ||
id :: f a a | ||
|
||
instance Category (->) where | ||
id = \x -> x | ||
|
||
f . g = \a -> f (g a) | ||
id = \x -> x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package frege.control.Semigroupoid | ||
inline (F.•) | ||
where | ||
|
||
import frege.Prelude hiding (.) | ||
|
||
private type F = (->) | ||
|
||
class Semigroupoid f where | ||
--- morphism composition | ||
(.) :: f b c -> f a b -> f a c | ||
|
||
infixr 1 `>>>` | ||
infixr 1 `<<<` | ||
|
||
--- Right-to-left composition | ||
(<<<) :: Semigroupoid f => f b c -> f a b -> f a c | ||
(<<<) = (.) | ||
|
||
--- Left-to-right composition | ||
(>>>) :: Semigroupoid f => f a b -> f b c -> f a c | ||
f >>> g = g . f | ||
|
||
instance Semigroupoid (->) where | ||
f . g = \a -> f (g a) |