module Database.PlistBuddy.Types
(
PlistBuddy(..)
, throwPlistError
, catchPlistError
, Plist(..)
, Value(..)
, PlistBuddyException(..)
, PlistError(..)
, Audit(..)
, Trail(..)
, AuditTrail(..)
) where
import Control.Concurrent
import Control.Exception
import Control.Monad.Reader
import Control.Monad.Except
import Data.Text(Text)
import Data.ByteString (ByteString)
import Data.IORef
import System.Process
import System.Posix.Pty
import Data.Time
import GHC.Generics
newtype PlistBuddy a = PlistBuddy (ExceptT PlistError (ReaderT Plist IO) a)
deriving (Functor,Applicative, Monad, MonadError PlistError, MonadReader Plist, MonadIO)
newtype PlistError = PlistError String
deriving (Show, Eq)
catchPlistError :: PlistBuddy a -> (PlistError -> PlistBuddy a) -> PlistBuddy a
catchPlistError = catchError
throwPlistError :: PlistError -> PlistBuddy a
throwPlistError = throwError
data Plist = Plist
{ plist_pty :: Pty
, plist_lock :: MVar ()
, plist_proc :: ProcessHandle
, plist_debug :: Bool
, plist_file :: FilePath
, plist_trail :: Trail -> IO ()
, plist_launder :: IO ()
, plist_dirty :: IORef (Maybe Bool)
}
data Value = String Text
| Array [Value]
| Dict [(Text,Value)]
| Bool Bool
| Real Double
| Integer Integer
| Date UTCTime
| Data ByteString
deriving (Show, Read, Generic)
data PlistBuddyException = PlistBuddyException String
deriving (Show, Generic)
instance Exception PlistBuddyException
data AuditTrail = AuditTrail ByteString [Trail] (Maybe ByteString)
deriving (Show,Read,Generic)
data Audit
= UTCTime :! Trail
deriving (Show,Read,Generic)
data Trail
= Save ByteString
| Revert
| Exit
| Clear Value
| Set [Text] Value
| Add [Text] Value
| Delete [Text]
| Start ByteString
deriving (Show,Read,Generic)