-
Notifications
You must be signed in to change notification settings - Fork 0
/
IteratorLib.hs
32 lines (26 loc) · 899 Bytes
/
IteratorLib.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module IteratorLib where
import System.Directory (Permissions(..))
import System.Time (ClockTime(..))
data Info = Info {
infoPath :: FilePath
, infoPerms :: Maybe Permissions
, infoSize :: Maybe Integer
, infoModTime :: Maybe ClockTime
} deriving (Eq, Ord, Show)
data Iterate seed = Done { unwrap :: seed }
| Skip { unwrap :: seed }
| Continue {unwrap :: seed }
deriving (Show)
type Iterator seed = seed -> Info -> Iterate seed
createIter :: (a -> Info -> Bool) ->
(a -> Info -> Bool) ->
(a -> a) ->
Iterator a
createIter stop skip transfer seed
| stop seed = Done seed
| skip seed = Skip seed
| otherwise = Continue $ transfer seed
noContextStop :: (a -> Bool) -> Iterator a
noContextStop stop seed
| stop seed = Done seed
| otherwise = Continue seed