eio-0.0.0.0: IO with Exceptions tracked on the type-level
Copyright(c) 2021 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellNone
LanguageHaskell2010

EIO

Description

IO with Exceptions tracked on the type-level

Synopsis

Main type

newtype EIO (exceptions :: [Type]) a Source #

Main type for IO that tracks exceptions on the type-level. Simply wraps IO and adds exceptions meta-information.

Since: 0.0.0.0

Constructors

EIO 

Fields

Instances

Instances details
Functor (EIO exceptions) Source # 
Instance details

Defined in EIO

Methods

fmap :: (a -> b) -> EIO exceptions a -> EIO exceptions b #

(<$) :: a -> EIO exceptions b -> EIO exceptions a #

runEIO :: EIO '[] () -> IO () Source #

Run the the EIO main with exception tracking.

Usually used in the main function like so:

import EIO (EIO)
import qualified EIO

main :: IO ()
main = EIO.runEIO safeMain

safeMain :: EIO '[] ()
safeMain = EIO.do
    ... your code ...

Since: 0.0.0.0

Basic API

throw :: forall e a. Exception e => e -> EIO '[e] a Source #

Throw exception.

Since: 0.0.0.0

catch :: forall e a e1 e2. Exception e => EIO e1 a -> (e -> EIO e2 a) -> EIO (Delete e (e1 <> e2)) a Source #

Catch exception and remove it from the list of handled exceptions.

Since: 0.0.0.0

QualifieDo interface

return :: forall a. a -> EIO '[] a Source #

Wrap a value into EIO without throwing any exceptions.

Since: 0.0.0.0

(>>=) :: forall e1 e2 a b. EIO e1 a -> (a -> EIO e2 b) -> EIO (e1 <> e2) b Source #

Bind the value inside the first action to the second one and combine thrown exceptions.

Since: 0.0.0.0

(>>) :: forall e1 e2 a b. EIO e1 a -> EIO e2 b -> EIO (e1 <> e2) b Source #

Run two actions sequentially and combine thrown exceptions.

Since: 0.0.0.0