shrun
Safe HaskellNone
LanguageGHC2021

Shrun.IO.Handle

Description

Provides types for typical IO processes.

Synopsis

Read handle result

data ReadHandleResult Source #

Result from reading a handle. The ordering is based on:

ReadNoData < ReadErr < ReadSuccess

The Semigroup instance is based on this ordering, taking the greatest element. For identical constructors, the left argument is taken.

Constructors

ReadErr (NonEmpty UnlinedText)

Error encountered while trying to read a handle.

ReadSuccess (NonEmpty UnlinedText)

Successfully read data from the handle.

ReadErrSuccess (NonEmpty UnlinedText) (NonEmpty UnlinedText)

Error encountered while trying to read a handle, but also have a successful previous read.

ReadNoData

Successfully read no data from the handle.

Reading

readHandle :: forall (p :: HandleMode) m. (CanRead p, HasCallStack, MonadCatch m, MonadHandleReader m, MonadIORef m, MonadTime m) => Maybe BufferParams -> Int -> Handle p -> m (Double, ReadHandleResult) Source #

Attempts to read from the handle.

readHandleRaw :: forall (p :: HandleMode) m. (CanRead p, HasCallStack, MonadCatch m, MonadHandleReader m) => Int -> Handle p -> m (Either (NonEmpty UnlinedText) ByteString) Source #

Attempts to read from the handle. Returns Left error or Right success.

readAndUpdateRefFinal Source #

Arguments

:: (HasCallStack, MonadIORef m) 
=> IORef (Maybe UnlinedText)

Previous read.

-> ByteString

Current read.

-> m ReadHandleResult

Result.

Intended for a final read that handles previous read data.