Safe Haskell | Trustworthy |
---|
Sys
Contents
Description
This trusted module is Trustworthy, and so may be used by Safe
modules. It defines the type DCMVar
of labeled, mutable variables
whose labels come from DCLabel
. It also defined the type of labeled
IO/TCP handles, Handle
. It defines wrappers for a number of IO
functions. It defines functions for issuing fatal error messages and
exception handling. And it defines functions for testing if LIO guards
would succeed.
- type DCMVar a = LMVar DCLabel a
- type Handle = LObj DCLabel Handle
- hPutChar :: Handle -> Char -> DC ()
- hPutCharP :: DCPriv -> Handle -> Char -> DC ()
- hPutStr :: Handle -> String -> DC ()
- hPutStrP :: DCPriv -> Handle -> String -> DC ()
- hPutStrLn :: Handle -> String -> DC ()
- hPutStrLnP :: DCPriv -> Handle -> String -> DC ()
- hGetChar :: Handle -> DC Char
- hGetCharP :: DCPriv -> Handle -> DC Char
- hGetLine :: Handle -> DC String
- hGetLineP :: DCPriv -> Handle -> DC String
- hSetBuffering :: Handle -> BufferMode -> DC ()
- hSetBufferingP :: DCPriv -> Handle -> BufferMode -> DC ()
- hClose :: Handle -> DC ()
- hCloseP :: DCPriv -> Handle -> DC ()
- fatal :: String -> String -> DC a
- catchFatal :: String -> String -> String -> DC a -> DC a
- guardAlloc_Check :: DCLabel -> DC Bool
- guardWrite_Check :: DCLabel -> DC Bool
- guardAllocP_Check :: DCPriv -> DCLabel -> DC Bool
- guardWriteP_Check :: DCPriv -> DCLabel -> DC Bool
Types
type Handle = LObj DCLabel Handle
The LIO version of a IO/TCP handle: a labeled object whose value
has type Handle
.
Wrappers for IO Functions
hPutChar :: Handle -> Char -> DC ()
The LIO analogue of hPutChar
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hPutCharP :: DCPriv -> Handle -> Char -> DC ()
The version of hPutChar
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
hPutStr :: Handle -> String -> DC ()
The LIO analogue of hPutStr
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hPutStrP :: DCPriv -> Handle -> String -> DC ()
The version of hPutStr
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
hPutStrLn :: Handle -> String -> DC ()
The LIO analogue of hPutStrLn
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hPutStrLnP :: DCPriv -> Handle -> String -> DC ()
The version of hPutStrLn
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
The LIO analogue of hGetChar
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hGetCharP :: DCPriv -> Handle -> DC Char
The version of hGetChar
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
hGetLine :: Handle -> DC String
The LIO analogue of hGetLine
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hGetLineP :: DCPriv -> Handle -> DC String
The version of hGetLine
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
hSetBuffering :: Handle -> BufferMode -> DC ()
The LIO analogue of hSetBuffering
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hSetBufferingP :: DCPriv -> Handle -> BufferMode -> DC ()
The version of hSetBuffering
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
The LIO analogue of hClose
. Will raise the current
label to the handle's label; raises an exception if this isn't possible.
hCloseP :: DCPriv -> Handle -> DC ()
The version of hClose
that uses a privilege to limit the
raising of the current label: the goal is for the current label and
the handle's label to be equal, modulo the privilege.
Fatal Error Messages and Exception Handling
catchFatal :: String -> String -> String -> DC a -> DC a
returns a catchFatal
comp msgEx msgLab mDC
action that,
when run, saves the current label and clearance, and then runs m
.
If running m
raises an exception, then the DC
action issues the
error message msgEx
, attributed to program component comp
, on
the standard output, and then causes the program to exit with
failure status. Otherwise, if running m
changed the current label
or clearance, then the DC
action issues the error message
msgLab
, attributed to program component comp
, on the standard
output, and then causes the program to exit with failure
status. Otherwise, the DC
action returns the value returned by
m
.
Functions for Testing if LIO Guards Would Succeed
guardAlloc_Check :: DCLabel -> DC Bool
returns a guardAlloc_Check
labDC
action that tests whether
would succeed, were it run.
guardAlloc
lab
guardWrite_Check :: DCLabel -> DC Bool
returns a guardWrite_Check
labDC
action that tests whether
would succeed, were it run.
guardWrite
lab
guardAllocP_Check :: DCPriv -> DCLabel -> DC Bool
returns a guardAllocP_Check
priv labDC
action that tests whether
would succeed, were it run.
guardAllocP
priv lab
guardWriteP_Check :: DCPriv -> DCLabel -> DC Bool
returns a guardWriteP_Check
priv labDC
action that tests whether
would succeed, were it run.
guardWriteP
priv lab