Skip to content

Commit

Permalink
improve documentation of ZDD.fold and ZDD.fold' a little
Browse files Browse the repository at this point in the history
  • Loading branch information
msakai committed Oct 21, 2021
1 parent 783a159 commit c339123
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Data/DecisionDiagram/ZDD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ module Data.DecisionDiagram.ZDD
, mapDelete
, change

-- * Fold
, fold
, fold'

-- * Minimal hitting sets
, minimalHittingSets
, minimalHittingSetsToda
Expand All @@ -86,8 +90,6 @@ module Data.DecisionDiagram.ZDD

-- * Misc
, flatten
, fold
, fold'

-- * Conversion
, toListOfIntSets
Expand Down Expand Up @@ -566,6 +568,10 @@ fromListOfSortedList = unions . map f
f :: [Int] -> ZDD a
f = ZDD . foldr (\x node -> Branch x F node) T

-- | Fold over the graph structure of the ZDD.
--
-- It takes values for substituting 'empty' and 'base',
-- and a function for substiting non-terminal node.
fold :: b -> b -> (Int -> b -> b -> b) -> ZDD a -> b
fold ff tt br (ZDD node) = runST $ do
h <- C.newSized defaultTableSize
Expand All @@ -583,6 +589,7 @@ fold ff tt br (ZDD node) = runST $ do
return ret
f node

-- | Strict version of 'fold'
fold' :: b -> b -> (Int -> b -> b -> b) -> ZDD a -> b
fold' !ff !tt br (ZDD node) = runST $ do
h <- C.newSized defaultTableSize
Expand Down

0 comments on commit c339123

Please sign in to comment.