6-- Module : Streamly.FileSystem.Handle
7-- Copyright : (c) 2018 Composewell Technologies
10-- Maintainer : streamly@composewell.com
11-- Stability : experimental
14-- Read and write streams and arrays to and from file handles. File handle IO
15-- APIs are quite similar to "Streamly.Memory.Array" read write APIs. In that
16-- regard, arrays can be considered as in-memory files or files can be
17-- considered as on-disk arrays.
19-- Control over file reading and writing behavior in terms of buffering,
20-- encoding, decoding is in the hands of the programmer, the 'TextEncoding',
21-- 'NewLineMode', and 'Buffering' options of the underlying handle provided by
22-- GHC are not needed and ignored.
26-- > import qualified Streamly.FileSystem.Handle as FH
28-- For additional, experimental APIs take a look at
29-- "Streamly.Internal.FileSystem.Handle" module.
33-- In some cases the stream type based APIs in the
34-- "Streamly.Internal.FileSystem.Handle" module may be more efficient compared
35-- to the unfold/fold based APIs exposed from this module because of better
36-- fusion by GHC. However, with the streamly fusion GHC plugin (upcoming) these
37-- APIs would perform as well as the stream based APIs in all cases.
39-- IO APIs are divided into two categories, sequential streaming IO APIs and
40-- random access IO APIs.
42module Streamly.FileSystem.Handle
44 -- * Sequential/Streaming IO
45 -- | Stream data to or from a file or device sequentially. When reading,
46 -- the stream is lazy and generated on-demand as the consumer consumes it.
47 -- Read IO requests to the IO device are performed in chunks limited to a
48 -- maximum size of 32KiB, this is referred to as
49 -- 'Streamly.Internal.Memory.Array.Types.defaultChunkSize' in the
50 -- documentation. One IO request may or may not read the full
51 -- chunk. If the whole stream is not consumed, it is possible that we may
52 -- read slightly more from the IO device than what the consumer needed.
53 -- Unless specified otherwise in the API, writes are collected into chunks
54 -- of 'Streamly.Internal.Memory.Array.Types.defaultChunkSize' before they
55 -- are written to the IO device.
57 -- Streaming APIs work for all kind of devices, seekable or non-seekable;
58 -- including disks, files, memory devices, terminals, pipes, sockets and
59 -- fifos. While random access APIs work only for files or devices that have
60 -- random access or seek capability for example disks, memory devices.
61 -- Devices like terminals, pipes, sockets and fifos do not have random
64 -- ** Read From Handle
65 -- | 'TextEncoding', 'NewLineMode', and 'Buffering' options of the
66 -- underlying handle are ignored. The read occurs from the current seek
67 -- position of the file handle. The stream ends as soon as EOF is
73 , readChunksWithBufferOf
76 -- | 'TextEncoding', 'NewLineMode', and 'Buffering' options of the
77 -- underlying handle are ignored. The write occurs from the current seek
78 -- position of the file handle. The write behavior depends on the 'IOMode'
87import Streamly.Internal.FileSystem.Handle
88import Prelude hiding (read)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list