vexceptt

A version of `ExceptT` that uses `Veither`, an extensible `Either`.


License
MIT
Install
psc-package install vexceptt

Documentation

purescript-VexceptT

A version of ExceptT that uses Veither instead of Either.

Inspired by and only slightly different in definition from ExceptV. However, VexceptT fully reimplements all API of ExceptT except for these type classes:

  • Alt
  • Plus
  • Alternative
  • MonadPlus

ExceptV vs VexceptT

-- # Main types compared
newtype ExceptV  e m a = ExceptV (m (Either (Variant e) a))
newtype VexceptT e m a = ExceptV (m (Veither         e  a))

-- # Underlying types compared
data Either l r 
    = Left l 
    | Right r

newtype Veither e r = Veither (Variant ("_" :: a | e))

-- pseudo-code
type Variant ("_" :: a) = {type: "_", value: a }

-- # Comparing how errors are stored at runtim
ExceptV  (pure (Left    (inj _sym error))) :: ExceptV  e m a
VexceptT (pure (Veither (inj _sym error))  :: VexceptT e m a

-- Dropping the `Either` removes one layer of boxing at runtime
pure (Left {type: "error", value: e})) :: ExceptV  e m a
pure (     {type: "error", value: e})  :: VexceptT e m a

-- # Comparing how success value are stored at runtime
ExceptV  (pure (Right                 a)  :: ExceptV  e m a
VexceptT (pure (Veither (inj _sym error)) :: VexceptT e m a

-- Unsure whether `Right a` is more performant than `{type: "_", value: a}`
pure (Right              a)) :: ExceptV  e m a
pure ({type: "_", value: a}) :: VexceptT e m a