Skip to content

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

License

Notifications You must be signed in to change notification settings

JordanMartinez/purescript-vexceptt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published