module System.FSNotify.Types
( act
, ActionPredicate
, Action
, WatchConfig(..)
, Debounce(..)
, DebounceData(..)
, DebouncePayload
, Event(..)
, EventChannel
, eventPath
, eventTime
, eventIsDirectory
, IOEvent
) where
import Control.Concurrent.Chan
import Data.IORef (IORef)
import Data.Time (NominalDiffTime)
import Data.Time.Clock (UTCTime)
import Prelude hiding (FilePath)
import System.FilePath
data Event =
Added FilePath UTCTime Bool
| Modified FilePath UTCTime Bool
| Removed FilePath UTCTime Bool
| Unknown FilePath UTCTime String
deriving (Event -> Event -> Bool
(Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Event -> Event -> Bool
$c/= :: Event -> Event -> Bool
== :: Event -> Event -> Bool
$c== :: Event -> Event -> Bool
Eq, Int -> Event -> ShowS
[Event] -> ShowS
Event -> FilePath
(Int -> Event -> ShowS)
-> (Event -> FilePath) -> ([Event] -> ShowS) -> Show Event
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> FilePath
$cshow :: Event -> FilePath
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
Show)
eventPath :: Event -> FilePath
eventPath :: Event -> FilePath
eventPath (Added FilePath
path UTCTime
_ Bool
_) = FilePath
path
eventPath (Modified FilePath
path UTCTime
_ Bool
_) = FilePath
path
eventPath (Removed FilePath
path UTCTime
_ Bool
_) = FilePath
path
eventPath (Unknown FilePath
path UTCTime
_ FilePath
_) = FilePath
path
eventTime :: Event -> UTCTime
eventTime :: Event -> UTCTime
eventTime (Added FilePath
_ UTCTime
timestamp Bool
_) = UTCTime
timestamp
eventTime (Modified FilePath
_ UTCTime
timestamp Bool
_) = UTCTime
timestamp
eventTime (Removed FilePath
_ UTCTime
timestamp Bool
_) = UTCTime
timestamp
eventTime (Unknown FilePath
_ UTCTime
timestamp FilePath
_) = UTCTime
timestamp
eventIsDirectory :: Event -> Bool
eventIsDirectory :: Event -> Bool
eventIsDirectory (Added FilePath
_ UTCTime
_ Bool
isDir) = Bool
isDir
eventIsDirectory (Modified FilePath
_ UTCTime
_ Bool
isDir) = Bool
isDir
eventIsDirectory (Removed FilePath
_ UTCTime
_ Bool
isDir) = Bool
isDir
eventIsDirectory (Unknown FilePath
_ UTCTime
_ FilePath
_) = Bool
False
type EventChannel = Chan Event
data WatchConfig = WatchConfig
{ WatchConfig -> Debounce
confDebounce :: Debounce
, WatchConfig -> Int
confPollInterval :: Int
, WatchConfig -> Bool
confUsePolling :: Bool
}
data Debounce
= DebounceDefault
| Debounce NominalDiffTime
| NoDebounce
type IOEvent = IORef Event
data DebounceData = DebounceData NominalDiffTime IOEvent
type DebouncePayload = Maybe DebounceData
type ActionPredicate = Event -> Bool
type Action = Event -> IO ()
act :: ActionPredicate
act :: Event -> Bool
act Event
_ = Bool
True