4-- Module : Streamly.FileSystem.Handle
5-- Copyright : (c) 2018 Composewell Technologies
8-- Maintainer : streamly@composewell.com
9-- Stability : experimental
12-- Read and write streams and arrays to and from file handles. File handle IO
13-- APIs are quite similar to "Streamly.Data.Array.Storable.Foreign" read write APIs. In that
14-- regard, arrays can be considered as in-memory files or files can be
15-- considered as on-disk arrays.
17-- Control over file reading and writing behavior in terms of buffering,
18-- encoding, decoding is in the hands of the programmer, the 'TextEncoding',
19-- 'NewLineMode', and 'Buffering' options of the underlying handle provided by
20-- GHC are not needed and ignored.
24-- > import qualified Streamly.FileSystem.Handle as FH
26-- For additional, experimental APIs take a look at
27-- "Streamly.Internal.FileSystem.Handle" module.
31-- In some cases the stream type based APIs in the
32-- "Streamly.Internal.FileSystem.Handle" module may be more efficient compared
33-- to the unfold/fold based APIs exposed from this module because of better
34-- fusion by GHC. However, with the streamly fusion GHC plugin (upcoming) these
35-- APIs would perform as well as the stream based APIs in all cases.
37-- IO APIs are divided into two categories, sequential streaming IO APIs and
38-- random access IO APIs.
40module Streamly.FileSystem.Handle
42 -- * Sequential/Streaming IO
43 -- | Stream data to or from a file or device sequentially. When reading,
44 -- the stream is lazy and generated on-demand as the consumer consumes it.
45 -- Read IO requests to the IO device are performed in chunks limited to a
46 -- maximum size of 32KiB, this is referred to as
47 -- 'Streamly.Internal.Data.Array.Storable.Foreign.Types.defaultChunkSize' in the
48 -- documentation. One IO request may or may not read the full
49 -- chunk. If the whole stream is not consumed, it is possible that we may
50 -- read slightly more from the IO device than what the consumer needed.
51 -- Unless specified otherwise in the API, writes are collected into chunks
52 -- of 'Streamly.Internal.Data.Array.Storable.Foreign.Types.defaultChunkSize' before they
53 -- are written to the IO device.
55 -- Streaming APIs work for all kind of devices, seekable or non-seekable;
56 -- including disks, files, memory devices, terminals, pipes, sockets and
57 -- fifos. While random access APIs work only for files or devices that have
58 -- random access or seek capability for example disks, memory devices.
59 -- Devices like terminals, pipes, sockets and fifos do not have random
62 -- ** Read From Handle
63 -- | 'TextEncoding', 'NewLineMode', and 'Buffering' options of the
64 -- underlying handle are ignored. The read occurs from the current seek
65 -- position of the file handle. The stream ends as soon as EOF is
71 , readChunksWithBufferOf
74 -- | 'TextEncoding', 'NewLineMode', and 'Buffering' options of the
75 -- underlying handle are ignored. The write occurs from the current seek
76 -- position of the file handle. The write behavior depends on the 'IOMode'
85import Streamly.Internal.FileSystem.Handle
86import 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