@@ -57,6 +57,45 @@ testUnfold unf seed lst = runIdentity action
57testUnfoldD :: Unfold Identity a Int -> a -> [Int] -> Bool
57testUnfoldD :: Unfold Identity a Int -> a -> [Int] -> Bool
58testUnfoldD = testUnfold
58testUnfoldD = testUnfold
60+-------------------------------------------------------------------------------
61+-- Operations on input
62+-------------------------------------------------------------------------------
66+ let unf = UF.lmapM (\x -> modify (+ 1) >> return x) (UF.singleton id)
67+ in testUnfoldAD unf 0 1 1 [1]
71+ let unf = UF.supply (UF.singleton id) 1
72+ in testUnfold unf undefined ([1] :: [Int])
76+ let unf = UF.supplyFirst (UF.singleton id) 1
77+ in testUnfold unf 2 ([(1, 2)] :: [(Int, Int)])
81+ let unf = UF.supplySecond (UF.singleton id) 1
82+ in testUnfold unf 2 ([(2, 1)] :: [(Int, Int)])
86+ let unf = UF.discardFirst (UF.singleton id)
87+ in testUnfold unf ((1, 2) :: (Int, Int)) [2]
91+ let unf = UF.discardSecond (UF.singleton id)
92+ in testUnfold unf ((1, 2) :: (Int, Int)) [1]
96+ let unf = UF.swap (UF.singleton id)
97+ in testUnfold unf ((1, 2) :: (Int, Int)) [(2, 1)]
60-------------------------------------------------------------------------------
99-------------------------------------------------------------------------------
61-- Stream generation
100-- Stream generation
62-------------------------------------------------------------------------------
101-------------------------------------------------------------------------------
@@ -211,8 +250,30 @@ outerProduct =
211 lst = [(a, b) :: (Int, Int) | a <- [0 .. 10], b <- [0 .. 20]]
250 lst = [(a, b) :: (Int, Int) | a <- [0 .. 10], b <- [0 .. 20]]
212 in testUnfold unf ((0, 0) :: (Int, Int)) lst
251 in testUnfold unf ((0, 0) :: (Int, Int)) lst
253+-------------------------------------------------------------------------------
255+-------------------------------------------------------------------------------
263+ prop "supply" supply
264+ prop "supplyFirst" supplyFirst
265+ prop "supplySecond" supplySecond
266+ prop "discardFirst" discardFirst
267+ prop "discardSecond" discardSecond
270+-------------------------------------------------------------------------------
272+-------------------------------------------------------------------------------
214main :: IO ()
274main :: IO ()
215−main = hspec $
275+main = hspec $ do
216 describe "Unfold tests" $ do
277 describe "Unfold tests" $ do
217 prop "fromStream" fromStream
278 prop "fromStream" fromStream
218 prop "nilM" nilM
279 prop "nilM" nilM