Skip to content
  • Michael Snoyman's avatar
    7ec3240e
    Fix general bracket for ExceptT/ErrorT (#60) · 7ec3240e
    Michael Snoyman authored and Ryan Scott's avatar Ryan Scott committed
    * Demonstrate broken ExceptT instance for MonadMask
    
    * Simplify generalBracket so it works for ExceptT
    
    The previous type signature was in fact invalid, as it did not allow for
    a valid instance for ExceptT (et al). In particular, in the case of a
    non-exceptional Left result, neither the release nor cleanup functions
    could be used, since:
    
    * No result value was available for release
    * No SomeException value was available for cleanup
    
    It appears that this less pleasing version of generalBracket is the only
    one that works for all the types we care about.
    
    Furthermore: once we accept this, we are now forced to perform some
    discarding of updated state and Monoid written values in the StateT,
    WriterT, and RWST instances. This seems inherent to making things
    compatible with ExceptT.
    
    An alternative to this is to simply remove the ExceptT and ErrorT
    instances, but that's contrary to what many users want it seems.
    
    * Doc cleanups @RyanGIScott's review
    7ec3240e
    Fix general bracket for ExceptT/ErrorT (#60)
    Michael Snoyman authored and Ryan Scott's avatar Ryan Scott committed
    * Demonstrate broken ExceptT instance for MonadMask
    
    * Simplify generalBracket so it works for ExceptT
    
    The previous type signature was in fact invalid, as it did not allow for
    a valid instance for ExceptT (et al). In particular, in the case of a
    non-exceptional Left result, neither the release nor cleanup functions
    could be used, since:
    
    * No result value was available for release
    * No SomeException value was available for cleanup
    
    It appears that this less pleasing version of generalBracket is the only
    one that works for all the types we care about.
    
    Furthermore: once we accept this, we are now forced to perform some
    discarding of updated state and Monoid written values in the StateT,
    WriterT, and RWST instances. This seems inherent to making things
    compatible with ExceptT.
    
    An alternative to this is to simply remove the ExceptT and ErrorT
    instances, but that's contrary to what many users want it seems.
    
    * Doc cleanups @RyanGIScott's review
Loading