    {-# LINE 1 "src/System/INotify/Masks.hsc" #-}
    module System.INotify.Masks
        ( inAccess
        , inModify
        , inAttrib
        , inCloseWrite
        , inCloseNowrite
        , inOpen
        , inMovedFrom
        , inMovedTo
        , inMoveSelf
        , inCreate
        , inDelete
        , inDeleteSelf
        , inUnmount
        , inQOverflow
        , inIgnored
        , inClose
        , inMove
        , inOnlydir
        , inDontFollow
        , inMaskAdd
        , inIsdir
        , inOneshot
        , inAllEvents
        , maskIsSet
        , joinMasks
        , Mask
        ) where

    import Data.Bits
    import Data.Maybe
    import Foreign.C.Types

    data Mask
        = UserSpace CUInt
        | Extra     CUInt
        | Helper    CUInt
        | Special   CUInt
        | All       CUInt
        deriving (Mask -> Mask -> Bool
    (Mask -> Mask -> Bool) -> (Mask -> Mask -> Bool) -> Eq Mask
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Mask -> Mask -> Bool
    == :: Mask -> Mask -> Bool
    $c/= :: Mask -> Mask -> Bool
    /= :: Mask -> Mask -> Bool
    Eq,Eq Mask
    Eq Mask =>
    (Mask -> Mask -> Ordering)
    -> (Mask -> Mask -> Bool)
    -> (Mask -> Mask -> Bool)
    -> (Mask -> Mask -> Bool)
    -> (Mask -> Mask -> Bool)
    -> (Mask -> Mask -> Mask)
    -> (Mask -> Mask -> Mask)
    -> Ord Mask
    Mask -> Mask -> Bool
    Mask -> Mask -> Ordering
    Mask -> Mask -> Mask
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Mask -> Mask -> Ordering
    compare :: Mask -> Mask -> Ordering
    $c< :: Mask -> Mask -> Bool
    < :: Mask -> Mask -> Bool
    $c<= :: Mask -> Mask -> Bool
    <= :: Mask -> Mask -> Bool
    $c> :: Mask -> Mask -> Bool
    > :: Mask -> Mask -> Bool
    $c>= :: Mask -> Mask -> Bool
    >= :: Mask -> Mask -> Bool
    $cmax :: Mask -> Mask -> Mask
    max :: Mask -> Mask -> Mask
    $cmin :: Mask -> Mask -> Mask
    min :: Mask -> Mask -> Mask
    Ord)

    maskIsSet :: Mask -> CUInt -> Bool
    maskIsSet :: Mask -> CUInt -> Bool
    maskIsSet Mask
    mask CUInt
    cuint =
        Mask -> CUInt
    value Mask
    mask CUInt -> CUInt -> CUInt
    forall a. Bits a => a -> a -> a
    .&. CUInt
    cuint CUInt -> CUInt -> Bool
    forall a. Ord a => a -> a -> Bool
    > CUInt
    0

    value :: Mask -> CUInt
    value :: Mask -> CUInt
    value (UserSpace CUInt
    i) = CUInt
    i
    value (Extra CUInt
    i) = CUInt
    i
    value (Helper CUInt
    i) = CUInt
    i
    value (Special CUInt
    i) = CUInt
    i
    value (All CUInt
    i) = CUInt
    i

    instance Show Mask where
        show :: Mask -> String
    show Mask
    mask =
            Maybe String -> String
    forall a. HasCallStack => Maybe a -> a
    fromJust (Maybe String -> String) -> Maybe String -> String
    forall a b. (a -> b) -> a -> b
    $ Mask -> [(Mask, String)] -> Maybe String
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup Mask
    mask [
                (Mask
    inAccess, String
    "IN_ACCESS"),
                (Mask
    inModify, String
    "IN_MODIFY"),
                (Mask
    inAttrib, String
    "IN_ATTRIB"),
                (Mask
    inClose,  String
    "IN_CLOSE"),
                (Mask
    inCloseWrite, String
    "IN_CLOSE_WRITE"),
                (Mask
    inCloseNowrite, String
    "IN_CLOSE_NOWRITE"),
                (Mask
    inOpen, String
    "IN_OPEN"),
                (Mask
    inMove, String
    "IN_MOVE"),
                (Mask
    inMovedFrom, String
    "IN_MOVED_FROM"),
                (Mask
    inMovedTo, String
    "IN_MOVED_TO"),
                (Mask
    inMoveSelf, String
    "IN_MOVE_SELF"),
                (Mask
    inCreate, String
    "IN_CREATE"),
                (Mask
    inDelete, String
    "IN_DELETE"),
                (Mask
    inDeleteSelf, String
    "IN_DELETE_SELF"),
                (Mask
    inUnmount, String
    "IN_UNMOUNT"),
                (Mask
    inQOverflow, String
    "IN_Q_OVERFLOW"),
                (Mask
    inIgnored, String
    "IN_IGNORED"),
                (Mask
    inClose, String
    "IN_CLOSE"),
                (Mask
    inIsdir, String
    "IN_ISDIR"),
                (Mask
    inOneshot, String
    "IN_ONESHOT")]

    joinMasks :: [Mask] -> CUInt
    joinMasks :: [Mask] -> CUInt
    joinMasks = (CUInt -> CUInt -> CUInt) -> CUInt -> [CUInt] -> CUInt
    forall a b. (a -> b -> b) -> b -> [a] -> b
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr CUInt -> CUInt -> CUInt
    forall a. Bits a => a -> a -> a
    (.|.) CUInt
    0 ([CUInt] -> CUInt) -> ([Mask] -> [CUInt]) -> [Mask] -> CUInt
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Mask -> CUInt) -> [Mask] -> [CUInt]
    forall a b. (a -> b) -> [a] -> [b]
    map Mask -> CUInt
    value

    inAccess :: Mask
    inAccess :: Mask
    inAccess = CUInt -> Mask
    UserSpace CUInt
    1
    inModify :: Mask
    inModify :: Mask
    inCreate :: Mask
    inModify = CUInt -> Mask
    UserSpace CUInt
    2
    inAttrib :: Mask
    inAttrib :: Mask
    inDelete :: Mask
    inAttrib = CUInt -> Mask
    UserSpace CUInt
    4
    inCloseWrite :: Mask
    inCloseWrite :: Mask
    inDeleteSelf :: Mask
    inCloseWrite = UserSpace CUInt
    8

    {-# LINE 83 "src/System/INotify/Masks.hsc" #-}
    inCloseNowrite :: Mask
    inCloseNowrite = UserSpace 16
    inOpen :: Mask
    inOpen = UserSpace 32
    inMovedFrom :: Mask
    inMovedFrom = UserSpace 64
    inMovedTo :: Mask
    inMovedTo = UserSpace 128

    {-# LINE 84 "src/System/INotify/Masks.hsc" #-}
    inCreate :: Mask
    inCreate = UserSpace 256
    inDelete :: Mask
    inDelete = UserSpace 512
    inDeleteSelf :: Mask
    inDeleteSelf = UserSpace 1024
    inMoveSelf :: Mask
    inMoveSelf = UserSpace 2048

    {-# LINE 85 "src/System/INotify/Masks.hsc" #-}

    inUnmount :: Mask
    inUnmount = Extra 8192
    inQOverflow :: Mask
    inQOverflow = Extra 16384
    inIgnored :: Mask
    inIgnored = Extra 32768

    {-# LINE 87 "src/System/INotify/Masks.hsc" #-}

    inClose :: Mask
    inClose = Helper 24
    inMove :: Mask
    inMove = Helper 192

    {-# LINE 89 "src/System/INotify/Masks.hsc" #-}

    inOnlydir :: Mask
    inOnlydir = Special 16777216
    inDontFollow :: Mask
    inDontFollow = Special 33554432
    inMaskAdd :: Mask
    inMaskAdd :: Mask
    inMaskAdd = CUInt -> Mask
    Special CUInt
    536870912
    inIsdir :: Mask
    inIsdir :: Mask
    inIsdir = CUInt -> Mask
    Special CUInt
    1073741824

    {-# LINE 91 "src/System/INotify/Masks.hsc" #-}
    inOneshot :: Mask
    inOneshot = Special 2147483648

    {-# LINE 92 "src/System/INotify/Masks.hsc" #-}

    inAllEvents :: Mask
    inAllEvents = All 4095

    {-# LINE 94 "src/System/INotify/Masks.hsc" #-}