Skip to content

Commit

Permalink
Add documentation for fork and loop
Browse files Browse the repository at this point in the history
  • Loading branch information
satnam6502 committed May 24, 2024
1 parent 91233fb commit 0fb747c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Lava.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- Stability: experimental
-- Portability: portable
--
-- A DSL for digital hardware design in Haskell.
-- The Lava module provides a DSL for digital hardware design.
--

module Lava (module Lava.Combinators,
Expand Down
7 changes: 6 additions & 1 deletion src/Lava/Combinators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ where
import Control.Monad.Fix (MonadFix)
import Control.Monad ((>=>))

-- | Fork captures sharing.
-- | Fork captures sharing. The input wire `a` is split
-- into two wires, each containing the value of `a`.
fork :: Monad m => a -> m (a, a)
fork a = return (a, a)

-- | Loop is used to bend a wire `feedback` from the output of a circuit
-- and feed it back as in input to a circuit. This requires
-- the feedback path to contain at least one state (delay)
-- element, otherwise the output will not terminate.
loop :: MonadFix m => ((a, feedback) -> m (b, feedback)) ->
a -> m b
loop circuit a
Expand Down

0 comments on commit 0fb747c

Please sign in to comment.