Skip to content

Commit

Permalink
Update documentation to improve haddocks
Browse files Browse the repository at this point in the history
  • Loading branch information
adetokunbo committed Jan 16, 2024
1 parent 1aa57b0 commit a3292ea
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 40 deletions.
14 changes: 7 additions & 7 deletions src/System/MemInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ SPDX-License-Identifier: BSD3
Implements a command that computes the memory usage of some processes
-}
module System.MemInfo (
-- * implement the system command @printmem@
-- * Implement @printmem@
getChoices,
printProcs,

-- * read @MemUsage@ directly
-- * Read 'MemUsage'
LostPid (..),
NotRun (..),
readMemUsage,
readMemUsage',
readForOnePid,

-- * unfold @MemUsage@ in a stream
-- * Stream 'MemUsage' periodically
unfoldMemUsageAfter',
unfoldMemUsageAfter,
unfoldMemUsage,

-- * determine the process/program name
-- * Obtain the process/program name
nameFromExeOnly,
nameFor,
nameAsFullCmd,

-- * index by program name or by processID
-- * Index by pid or name
ProcName,
dropId,
withPid,

-- * print @MemUsage@
-- * Print 'MemUsage'
printUsage,
printUsage',

-- * re-export
-- * Convenient re-exports
mkReportBud,
ProcessID,
AsCmdName (..),
Expand Down
7 changes: 2 additions & 5 deletions src/System/MemInfo/Choices.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ Copyright : (c) 2022 Tim Emiola
Maintainer : Tim Emiola <[email protected]>
SPDX-License-Identifier: BSD3
Defines the command line flags used to control the behaviour of the core-mem
command
This module defines the command line flags used to control the behavior of the
@printmem@ command
-}
module System.MemInfo.Choices (
-- * data types
Choices (..),
cmdInfo,
getChoices,

-- * functions
) where

import Options.Applicative (
Expand Down
5 changes: 1 addition & 4 deletions src/System/MemInfo/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ Copyright : (c) 2022 Tim Emiola
Maintainer : Tim Emiola <[email protected]>
SPDX-License-Identifier: BSD3
This module contains functions for formatting parts of the memory report
This module provides functions that format the output of the @printmem@ command
-}
module System.MemInfo.Print (
-- * classes
AsCmdName (..),

-- * functions
fmtAsHeader,
fmtOverall,
fmtMemUsage,
Expand Down
30 changes: 17 additions & 13 deletions src/System/MemInfo/Proc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@ Copyright : (c) 2022 Tim Emiola
Maintainer : Tim Emiola <[email protected]>
SPDX-License-Identifier: BSD3
This module provides data types that model data from files in the @proc@
filesystem that track memory usage metrics, and combinators for parsing and
grouping the contents of those files.
This module provides data types that model data from files in the @Linux proc
filesystem@ that track memory usage, and combinators for parsing and grouping
the contents of those files.
-}
module System.MemInfo.Proc (
-- * data types
-- * Add-up process memory metrics
MemUsage (..),
ExeInfo (..),
PerProc (..),
StatusInfo (..),
BadStatus (..),

-- * functions
amass,

-- * Parse process memory metrics
PerProc (..),
parseFromSmap,
parseFromStatm,

-- * Parse \/proc\/\<pid\>\/exe
ExeInfo (..),
parseExeInfo,

-- * Parse \/proc\/<pid\>\/status
parseStatusInfo,
StatusInfo (..),
BadStatus (..),
) where

import qualified Data.Map as Map
Expand Down Expand Up @@ -58,14 +62,14 @@ instance Validity StatusInfo where
]


-- | Specifies why @'parseStatusInfo'@ might fail
-- | Indicates why @'parseStatusInfo'@ failed
data BadStatus
= NoCmd
| NoParent
deriving (Eq, Show)


-- | Parses the content of /proc/<pid>/status into a @'StatusInfo'@
-- | Parses the content of \/proc\/\<pid\>\/status into a @'StatusInfo'@
parseStatusInfo :: Text -> Either BadStatus StatusInfo
parseStatusInfo content =
let
Expand All @@ -83,7 +87,7 @@ parseStatusInfo content =
StatusInfo <$> name <*> ppId


-- | Parses the target of /proc/<pid>/exe into a @'ExeInfo'@
-- | Parses the target of \/proc\/\<pid\>\/exe into a @'ExeInfo'@
parseExeInfo :: Text -> ExeInfo
parseExeInfo x =
let eiTarget = takeTillNull x
Expand Down
30 changes: 19 additions & 11 deletions src/System/MemInfo/SysInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,32 @@ Copyright : (c) 2022 Tim Emiola
Maintainer : Tim Emiola <[email protected]>
SPDX-License-Identifier: BSD3
This module provides information about the system on which the memory is being
measured.
This module provides data types that
@'readKernelVersion'@ determines the system's linux @'KernelVersion'@
- define memory reports (@'ReportBud'@) and
- provide info about the system where the report will run (@'KernelVersion'@,
@'SwapFlaw'@ and @'RamFlaw'@).
along with functions that use these types.
-}
module System.MemInfo.SysInfo (
-- * data types
KernelVersion,
-- * define reports
ReportBud (..),
mkReportBud,

-- * indicate calculation flaws
RamFlaw (..),
SwapFlaw (..),

-- * functions
mkReportBud,
checkForFlaws,
fmtRamFlaws,
fmtSwapFlaws,
fickleSharing,

-- * system kernel version
KernelVersion,
parseKernelVersion,
readKernelVersion,
fickleSharing,
) where

import qualified Data.List.NonEmpty as NE
Expand Down Expand Up @@ -177,9 +183,11 @@ checkForFlaws bud = do
pure $ bud {rbRamFlaws, rbSwapFlaws}


{- | Construct a 'ReportBud' for the specified @ProcessIDs@
{- | Construct a @ReportBud@ from some @ProcessIDs@
Generates values for the other fields by checking the system
@Nothing@ is returned if the kernel version cannot be determined
The result is @Nothing@ only when the @KernelVersion@ cannot be determined
-}
mkReportBud :: NonEmpty ProcessID -> IO (Maybe ReportBud)
mkReportBud rbPids = do
Expand Down

0 comments on commit a3292ea

Please sign in to comment.