1
1
mirror of https://github.com/coot/free-category.git synced 2024-11-23 09:55:43 +03:00

Updated README and documentation

This commit is contained in:
Marcin Szamotulski 2018-10-23 16:56:38 +02:00
parent de9bbe0b28
commit 99771692da
No known key found for this signature in database
GPG Key ID: 788D56E52D63FAA4
2 changed files with 11 additions and 1 deletions

View File

@ -2,3 +2,9 @@
[![Maintainer: coot](https://img.shields.io/badge/maintainer-coot-lightgrey.svg)](http://github.com/coot)
[![Travis Build Status](https://travis-ci.org/coot/free-category.svg?branch=master)](https://travis-ci.org/coot/free-category)
This package introduces variouos encodings of free categories in Haskell.
Free categories are useful to model state machines in a simple yet type safe
way. Read more [here](https://coot.me/posts/finite-state-machines.html) on
a simple example of a finite state machine encoded using a free category using
a simple GADT.

View File

@ -45,6 +45,9 @@ import Data.Semigroup.SSet (SSet (..))
--
-- prop> liftFree2 @Cat :: f a b -> Cat f ab
-- prop> foldNatFree2 @Cat :: Category d => (forall x y. f x y -> d x y) -> Cat f a b -> d a b
--
-- The same performance concerns that apply to @'Control.Monad.Free.Free'@
-- apply to this encoding of a free category.
data Cat :: (* -> * -> *) -> * -> * -> * where
Id :: Cat f a a
(:.:) :: f b c -> Cat f a b -> Cat f a c
@ -104,7 +107,8 @@ instance Category (C f) where
C bc . C ab = C $ \k -> bc k . ab k
-- |
-- Isomorphism between @'Cat'@ to @'C'@, which is a specialisation of @'hoistFreeH2'@.
-- Isomorphism between @'Cat'@ to @'C'@, which is a specialisation of
-- @'hoistFreeH2'@.
toC :: Cat f a b -> C f a b
toC = hoistFreeH2
{-# INLINE toC #-}