{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE Safe               #-}
module Lukko.Internal.Types where

import Control.Exception (Exception)
import Data.Typeable     (Typeable)

-- | Exception thrown by 'hLock' on non-Windows platforms that don't support
-- @flock@.
data FileLockingNotSupported = FileLockingNotSupported
  deriving (Typeable, Int -> FileLockingNotSupported -> ShowS
[FileLockingNotSupported] -> ShowS
FileLockingNotSupported -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileLockingNotSupported] -> ShowS
$cshowList :: [FileLockingNotSupported] -> ShowS
show :: FileLockingNotSupported -> String
$cshow :: FileLockingNotSupported -> String
showsPrec :: Int -> FileLockingNotSupported -> ShowS
$cshowsPrec :: Int -> FileLockingNotSupported -> ShowS
Show)

instance Exception FileLockingNotSupported

-- | Indicates a mode in which a file should be locked.
data LockMode = SharedLock | ExclusiveLock
  deriving (Typeable)

-- | Potentially availble lock methods.
data FileLockingMethod
    = MethodOFD      -- ^ open file descriptor locking
    | MethodFLock    -- ^ BSD @flock@
    | MethodWindows  -- ^ Windows locking
    | MethodNoOp     -- ^ No-Op (throws 'FileLockingNotSupported')
  deriving (Typeable, FileLockingMethod -> FileLockingMethod -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileLockingMethod -> FileLockingMethod -> Bool
$c/= :: FileLockingMethod -> FileLockingMethod -> Bool
== :: FileLockingMethod -> FileLockingMethod -> Bool
$c== :: FileLockingMethod -> FileLockingMethod -> Bool
Eq, Eq FileLockingMethod
FileLockingMethod -> FileLockingMethod -> Bool
FileLockingMethod -> FileLockingMethod -> Ordering
FileLockingMethod -> FileLockingMethod -> FileLockingMethod
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
min :: FileLockingMethod -> FileLockingMethod -> FileLockingMethod
$cmin :: FileLockingMethod -> FileLockingMethod -> FileLockingMethod
max :: FileLockingMethod -> FileLockingMethod -> FileLockingMethod
$cmax :: FileLockingMethod -> FileLockingMethod -> FileLockingMethod
>= :: FileLockingMethod -> FileLockingMethod -> Bool
$c>= :: FileLockingMethod -> FileLockingMethod -> Bool
> :: FileLockingMethod -> FileLockingMethod -> Bool
$c> :: FileLockingMethod -> FileLockingMethod -> Bool
<= :: FileLockingMethod -> FileLockingMethod -> Bool
$c<= :: FileLockingMethod -> FileLockingMethod -> Bool
< :: FileLockingMethod -> FileLockingMethod -> Bool
$c< :: FileLockingMethod -> FileLockingMethod -> Bool
compare :: FileLockingMethod -> FileLockingMethod -> Ordering
$ccompare :: FileLockingMethod -> FileLockingMethod -> Ordering
Ord, Int -> FileLockingMethod
FileLockingMethod -> Int
FileLockingMethod -> [FileLockingMethod]
FileLockingMethod -> FileLockingMethod
FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
FileLockingMethod
-> FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: FileLockingMethod
-> FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
$cenumFromThenTo :: FileLockingMethod
-> FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
enumFromTo :: FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
$cenumFromTo :: FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
enumFromThen :: FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
$cenumFromThen :: FileLockingMethod -> FileLockingMethod -> [FileLockingMethod]
enumFrom :: FileLockingMethod -> [FileLockingMethod]
$cenumFrom :: FileLockingMethod -> [FileLockingMethod]
fromEnum :: FileLockingMethod -> Int
$cfromEnum :: FileLockingMethod -> Int
toEnum :: Int -> FileLockingMethod
$ctoEnum :: Int -> FileLockingMethod
pred :: FileLockingMethod -> FileLockingMethod
$cpred :: FileLockingMethod -> FileLockingMethod
succ :: FileLockingMethod -> FileLockingMethod
$csucc :: FileLockingMethod -> FileLockingMethod
Enum, FileLockingMethod
forall a. a -> a -> Bounded a
maxBound :: FileLockingMethod
$cmaxBound :: FileLockingMethod
minBound :: FileLockingMethod
$cminBound :: FileLockingMethod
Bounded, Int -> FileLockingMethod -> ShowS
[FileLockingMethod] -> ShowS
FileLockingMethod -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileLockingMethod] -> ShowS
$cshowList :: [FileLockingMethod] -> ShowS
show :: FileLockingMethod -> String
$cshow :: FileLockingMethod -> String
showsPrec :: Int -> FileLockingMethod -> ShowS
$cshowsPrec :: Int -> FileLockingMethod -> ShowS
Show)