| Copyright | (c) Alias Qli 2022 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | 2576814881@qq.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
System.IO.Continuation
Description
This module implements continuation-based I/O as described in Haskell Report 1.2. It shares the same basic types as stream-based I/O.
Synopsis
- type SuccCont = Dialogue
- type StrCont = String -> Dialogue
- type StrListCont = [String] -> Dialogue
- type BinCont = Bin -> Dialogue
- type FailCont = IOError -> Dialogue
- done :: Dialogue
- readFile :: Name -> FailCont -> StrCont -> Dialogue
- writeFile :: Name -> String -> FailCont -> SuccCont -> Dialogue
- appendFile :: Name -> String -> FailCont -> SuccCont -> Dialogue
- readBinFile :: Name -> FailCont -> BinCont -> Dialogue
- writeBinFile :: Name -> Bin -> FailCont -> SuccCont -> Dialogue
- appendBinFile :: Name -> Bin -> FailCont -> SuccCont -> Dialogue
- deleteFile :: Name -> FailCont -> SuccCont -> Dialogue
- statusFile :: Name -> FailCont -> StrCont -> Dialogue
- readChan :: Name -> FailCont -> StrCont -> Dialogue
- appendChan :: Name -> String -> FailCont -> SuccCont -> Dialogue
- readBinChan :: Name -> FailCont -> BinCont -> Dialogue
- appendBinChan :: Name -> Bin -> FailCont -> SuccCont -> Dialogue
- statusChan :: Name -> FailCont -> StrCont -> Dialogue
- echo :: Bool -> FailCont -> SuccCont -> Dialogue
- getArgs :: FailCont -> StrListCont -> Dialogue
- getProgName :: FailCont -> StrCont -> Dialogue
- getEnv :: String -> FailCont -> StrCont -> Dialogue
- setEnv :: String -> String -> FailCont -> SuccCont -> Dialogue
- exit :: FailCont
- abort :: FailCont
- print :: Show a => a -> Dialogue
- prints :: Show a => a -> String -> Dialogue
- interact :: (String -> String) -> Dialogue
- type Dialogue = [Response] -> [Request]
- type Bin = ByteString
- type Name = String
- data IOError
- stdin :: Name
- stdout :: Name
- stderr :: Name
- stdecho :: Name
- runDialogue :: Dialogue -> IO ()
Continuation Types
type StrListCont = [String] -> Dialogue Source #
Transactions
Continuation-based IO is based on a collection of functions called transactions/
defined in a continuation style. Please refer to the corresponding constructors under
Request for documentations.
Other Functions
Re-exports
Types
type Bin = ByteString Source #
Bin is a datatype for binary values, as required by the report, and is implemented as a lazy ByteString.
This type synonym is described in Haskell Report 1.0, and exists for backward compatibility.
Constructors
| WriteError String | |
| ReadError String | |
| SearchError String | |
| FormatError String | Since we're using a modern device and the maximum line length and page length allowed on the channel have no bound, this error would never occur. |
| OtherError String |
Channels
Run the Program
runDialogue :: Dialogue -> IO () Source #
The central function to run a program.