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 -> String
(Int -> Event -> ShowS)
-> (Event -> String) -> ([Event] -> ShowS) -> Show Event
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> String
$cshow :: Event -> String
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
Show)
eventPath :: Event -> FilePath
eventPath :: Event -> String
eventPath (Added String
path UTCTime
_ Bool
_) = String
path
eventPath (Modified String
path UTCTime
_ Bool
_) = String
path
eventPath (Removed String
path UTCTime
_ Bool
_) = String
path
eventPath (Unknown String
path UTCTime
_ String
_) = String
path
eventTime :: Event -> UTCTime
eventTime :: Event -> UTCTime
eventTime (Added String
_ UTCTime
timestamp Bool
_) = UTCTime
timestamp
eventTime (Modified String
_ UTCTime
timestamp Bool
_) = UTCTime
timestamp
eventTime (Removed String
_ UTCTime
timestamp Bool
_) = UTCTime
timestamp
eventTime (Unknown String
_ UTCTime
timestamp String
_) = UTCTime
timestamp
eventIsDirectory :: Event -> Bool
eventIsDirectory :: Event -> Bool
eventIsDirectory (Added String
_ UTCTime
_ Bool
isDir) = Bool
isDir
eventIsDirectory (Modified String
_ UTCTime
_ Bool
isDir) = Bool
isDir
eventIsDirectory (Removed String
_ UTCTime
_ Bool
isDir) = Bool
isDir
eventIsDirectory (Unknown String
_ UTCTime
_ String
_) = 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