aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Circuit/Internal.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-04-07 20:16:02 +0100
committerYann Herklotz <git@ymhg.org>2019-04-07 20:16:02 +0100
commit7f32d8e4edd315ab4039432ca5b35c7eaa94f9ba (patch)
tree72ee33929209b42de6aad4a4e9e3a60962438a66 /src/VeriFuzz/Circuit/Internal.hs
parent4b5401ef3400413be0559dfa17718611822fc4c6 (diff)
downloadverismith-7f32d8e4edd315ab4039432ca5b35c7eaa94f9ba.tar.gz
verismith-7f32d8e4edd315ab4039432ca5b35c7eaa94f9ba.zip
Add partial documentation
Diffstat (limited to 'src/VeriFuzz/Circuit/Internal.hs')
-rw-r--r--src/VeriFuzz/Circuit/Internal.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/VeriFuzz/Circuit/Internal.hs b/src/VeriFuzz/Circuit/Internal.hs
index 8a4cf4a..3a7346f 100644
--- a/src/VeriFuzz/Circuit/Internal.hs
+++ b/src/VeriFuzz/Circuit/Internal.hs
@@ -23,12 +23,19 @@ import Data.Graph.Inductive (Graph, Node)
import qualified Data.Graph.Inductive as G
import qualified Data.Text as T
+-- | Convert an integer into a label.
+--
+-- >>> fromNode 5
+-- "w5"
fromNode :: Int -> T.Text
fromNode node = T.pack $ "w" <> show node
+-- | General function which runs 'filter' over a graph.
filterGr :: (Graph gr) => gr n e -> (Node -> Bool) -> [Node]
filterGr graph f = filter f $ G.nodes graph
+-- | Takes two functions that return an 'Int', and compares there results to 0
+-- and not 0 respectively. This result is returned.
only
:: (Graph gr)
=> gr n e
@@ -38,8 +45,11 @@ only
-> Bool
only graph fun1 fun2 n = fun1 graph n == 0 && fun2 graph n /= 0
+-- | Returns all the input nodes to a graph, which means nodes that do not have
+-- an input themselves.
inputs :: (Graph gr) => gr n e -> [Node]
inputs graph = filterGr graph $ only graph G.indeg G.outdeg
+-- | Returns all the output nodes to a graph, similar to the 'inputs' function.
outputs :: (Graph gr) => gr n e -> [Node]
outputs graph = filterGr graph $ only graph G.outdeg G.indeg