LIB/GTK: use strict data types where possible

This commit is contained in:
Julian Ospald 2016-04-20 16:34:26 +02:00
parent 39bc0cba24
commit 064d5a1032
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 77 additions and 77 deletions

View File

@ -97,58 +97,58 @@ import System.Posix.Types
-- can be converted to a String with 'show'. -- can be converted to a String with 'show'.
data File a = data File a =
Failed { Failed {
path :: Path Abs path :: !(Path Abs)
, err :: IOError , err :: IOError
} }
| Dir { | Dir {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
} }
| RegFile { | RegFile {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
} }
| SymLink { | SymLink {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
, sdest :: File a -- ^ symlink madness, , sdest :: File a -- ^ symlink madness,
-- we need to know where it points to -- we need to know where it points to
, rawdest :: ByteString , rawdest :: !ByteString
} }
| BlockDev { | BlockDev {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
} }
| CharDev { | CharDev {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
} }
| NamedPipe { | NamedPipe {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
} }
| Socket { | Socket {
path :: Path Abs path :: !(Path Abs)
, fvar :: a , fvar :: a
} deriving (Show, Eq) } deriving (Show, Eq)
-- |Low-level file information. -- |Low-level file information.
data FileInfo = FileInfo { data FileInfo = FileInfo {
deviceID :: DeviceID deviceID :: !DeviceID
, fileID :: FileID , fileID :: !FileID
, fileMode :: FileMode , fileMode :: !FileMode
, linkCount :: LinkCount , linkCount :: !LinkCount
, fileOwner :: UserID , fileOwner :: !UserID
, fileGroup :: GroupID , fileGroup :: !GroupID
, specialDeviceID :: DeviceID , specialDeviceID :: !DeviceID
, fileSize :: FileOffset , fileSize :: !FileOffset
, accessTime :: EpochTime , accessTime :: !EpochTime
, modificationTime :: EpochTime , modificationTime :: !EpochTime
, statusChangeTime :: EpochTime , statusChangeTime :: !EpochTime
, accessTimeHiRes :: POSIXTime , accessTimeHiRes :: !POSIXTime
, modificationTimeHiRes :: POSIXTime , modificationTimeHiRes :: !POSIXTime
, statusChangeTimeHiRes :: POSIXTime , statusChangeTimeHiRes :: !POSIXTime
} deriving (Show, Eq, Ord) } deriving (Show, Eq, Ord)

View File

@ -55,75 +55,75 @@ import System.INotify.ByteString
-- runtime. -- runtime.
data MyGUI = MkMyGUI { data MyGUI = MkMyGUI {
-- |main Window -- |main Window
rootWin :: Window rootWin :: !Window
-- widgets on the main window -- widgets on the main window
, upViewB :: Button , upViewB :: !Button
, homeViewB :: Button , homeViewB :: !Button
, refreshViewB :: Button , refreshViewB :: !Button
, urlBar :: Entry , urlBar :: !Entry
, statusBar :: Statusbar , statusBar :: !Statusbar
, clearStatusBar :: Button , clearStatusBar :: !Button
, scroll :: ScrolledWindow , scroll :: !ScrolledWindow
, fprop :: FilePropertyGrid , fprop :: !FilePropertyGrid
-- sub-widgets -- sub-widgets
, menubar :: MenuBar , menubar :: !MenuBar
, rcmenu :: RightClickMenu , rcmenu :: !RightClickMenu
-- other -- other
, settings :: TVar FMSettings , settings :: !(TVar FMSettings)
} }
data MenuBar = MkMenuBar { data MenuBar = MkMenuBar {
menubarFileQuit :: ImageMenuItem menubarFileQuit :: !ImageMenuItem
, menubarFileOpen :: ImageMenuItem , menubarFileOpen :: !ImageMenuItem
, menubarFileExecute :: ImageMenuItem , menubarFileExecute :: !ImageMenuItem
, menubarFileNew :: ImageMenuItem , menubarFileNew :: !ImageMenuItem
, menubarEditCut :: ImageMenuItem , menubarEditCut :: !ImageMenuItem
, menubarEditCopy :: ImageMenuItem , menubarEditCopy :: !ImageMenuItem
, menubarEditRename :: ImageMenuItem , menubarEditRename :: !ImageMenuItem
, menubarEditPaste :: ImageMenuItem , menubarEditPaste :: !ImageMenuItem
, menubarEditDelete :: ImageMenuItem , menubarEditDelete :: !ImageMenuItem
, menubarViewTree :: ImageMenuItem , menubarViewTree :: !ImageMenuItem
, menubarViewIcon :: ImageMenuItem , menubarViewIcon :: !ImageMenuItem
, menubarHelpAbout :: ImageMenuItem , menubarHelpAbout :: !ImageMenuItem
} }
data RightClickMenu = MkRightClickMenu { data RightClickMenu = MkRightClickMenu {
rcMenu :: Menu rcMenu :: !Menu
, rcFileOpen :: ImageMenuItem , rcFileOpen :: !ImageMenuItem
, rcFileExecute :: ImageMenuItem , rcFileExecute :: !ImageMenuItem
, rcFileNewRegFile :: ImageMenuItem , rcFileNewRegFile :: !ImageMenuItem
, rcFileNewDir :: ImageMenuItem , rcFileNewDir :: !ImageMenuItem
, rcFileCut :: ImageMenuItem , rcFileCut :: !ImageMenuItem
, rcFileCopy :: ImageMenuItem , rcFileCopy :: !ImageMenuItem
, rcFileRename :: ImageMenuItem , rcFileRename :: !ImageMenuItem
, rcFilePaste :: ImageMenuItem , rcFilePaste :: !ImageMenuItem
, rcFileDelete :: ImageMenuItem , rcFileDelete :: !ImageMenuItem
, rcFileProperty :: ImageMenuItem , rcFileProperty :: !ImageMenuItem
} }
data FilePropertyGrid = MkFilePropertyGrid { data FilePropertyGrid = MkFilePropertyGrid {
fpropGrid :: Grid fpropGrid :: !Grid
, fpropFnEntry :: Entry , fpropFnEntry :: !Entry
, fpropLocEntry :: Entry , fpropLocEntry :: !Entry
, fpropTsEntry :: Entry , fpropTsEntry :: !Entry
, fpropModEntry :: Entry , fpropModEntry :: !Entry
, fpropAcEntry :: Entry , fpropAcEntry :: !Entry
} }
-- |FM-wide settings. -- |FM-wide settings.
data FMSettings = MkFMSettings { data FMSettings = MkFMSettings {
showHidden :: Bool showHidden :: !Bool
, isLazy :: Bool , isLazy :: !Bool
, iconSize :: Int , iconSize :: !Int
} }
data FMView = FMTreeView TreeView data FMView = FMTreeView !TreeView
| FMIconView IconView | FMIconView !IconView
type Item = File FileInfo type Item = File FileInfo
@ -131,17 +131,17 @@ type Item = File FileInfo
-- |This describes the contents of the current vie and is separated from MyGUI, -- |This describes the contents of the current vie and is separated from MyGUI,
-- because we might want to have multiple views. -- because we might want to have multiple views.
data MyView = MkMyView { data MyView = MkMyView {
view :: TVar FMView view :: !(TVar FMView)
, cwd :: MVar Item , cwd :: !(MVar Item)
, rawModel :: TVar (ListStore Item) , rawModel :: !(TVar (ListStore Item))
, sortedModel :: TVar (TypedTreeModelSort Item) , sortedModel :: !(TVar (TypedTreeModelSort Item))
, filteredModel :: TVar (TypedTreeModelFilter Item) , filteredModel :: !(TVar (TypedTreeModelFilter Item))
, operationBuffer :: TVar FileOperation , operationBuffer :: !(TVar FileOperation)
, inotify :: MVar INotify , inotify :: !(MVar INotify)
-- the first part of the tuple represents the "go back" -- the first part of the tuple represents the "go back"
-- the second part the "go forth" in the history -- the second part the "go forth" in the history
, history :: TVar ([Path Abs], [Path Abs]) , history :: !(TVar ([Path Abs], [Path Abs]))
} }