improve haddock documentation for StateMachine constructors

This commit is contained in:
Marco Perone 2023-03-16 11:15:17 +01:00 committed by Marco Perone
parent 68baaf0831
commit 2e90a50206
2 changed files with 15 additions and 2 deletions

View File

@ -18,9 +18,9 @@ import "base" Data.Void (Void)
class RenderableVertices a where
vertices :: [a]
-- | This is a newtype to be used with `deriving via`. If `a` has instances for
-- | This is a newtype to be used with `deriving via`. If @a@ has instances for
-- `Enum` and `Bounded`, then `AllVertices a` has an instance of
-- `RenderableVertices` which lists all the terms of type `a`.
-- `RenderableVertices` which lists all the terms of type @a@.
newtype AllVertices a = AllVertices a
instance (Enum a, Bounded a) => RenderableVertices (AllVertices a) where

View File

@ -26,7 +26,12 @@ import Prelude hiding ((.))
--
-- `StateMachineT` is a tree, where leaves are `BaseMachineT` and other nodes
-- describe how to combine the subtrees to obtain more complex machines.
--
-- Please refer to https://github.com/tweag/crem/blob/main/docs/how-to-create-a-machine.md
-- for a more complete discussion on the various constructors.
data StateMachineT m input output where
-- | `Basic` allows to interpret a `BaseMachineT` as a `StateMachineT`,
-- making the @topology@ type variable existential
Basic
:: forall m vertex (topology :: Topology vertex) input output
. ( Demote vertex ~ vertex
@ -38,23 +43,31 @@ data StateMachineT m input output where
)
=> BaseMachineT m topology input output
-> StateMachineT m input output
-- | `Sequential` adds categorical composition for `StateMachineT`
Sequential
:: StateMachineT m a b
-> StateMachineT m b c
-> StateMachineT m a c
-- | `Parallel` allows to process two machine simultaneously
Parallel
:: StateMachineT m a b
-> StateMachineT m c d
-> StateMachineT m (a, c) (b, d)
-- | `Alternative` allows to process one out of two machines depending on the
-- input
Alternative
:: StateMachineT m a b
-> StateMachineT m c d
-> StateMachineT m (Either a c) (Either b d)
-- | `Feedback` allows to compose two machine going in oppositive directions
-- and run them in a loop
Feedback
:: (Foldable n, Monoid (n a), Monoid (n b))
=> StateMachineT m a (n b)
-> StateMachineT m b (n a)
-> StateMachineT m a (n b)
-- | `Kleisli` allows to compose sequentially machines which emit multiple
-- outputs
Kleisli
:: (Foldable n, Monoid (n c))
=> StateMachineT m a (n b)