Rafter is a tiny framework for managing the lifecycle and dependencies of software components which have runtime state.
import Rafter
data Component1 = Component1 Int
data State1 = State1 Int deriving (Show)
instance Component Component1 State1 () where
init _ (Component1 c1) = pure $ State1 c1
data Component2 = Component2 Int
data State2 = State2 Int deriving (Show)
instance Component Component2 State2 State1 where
init (State1 s1) (Component2 c2) = pure $ State2 (c2 + s1)
-- >>> result = start (Component1 1, Component2 0)
-- (State1 1,State2 1)