haskell / mtl

The Monad Transformer Library
http://www.haskell.org/haskellwiki/Monad_Transformers
Other
362 stars 63 forks source link

add tryError, withError, handleError, mapError (#60) #66

Closed ddssff closed 5 years ago

ddssff commented 5 years ago

Fixes #60

chessai commented 5 years ago

This LGTM. @RyanGlScott any thoughts?

chessai commented 5 years ago

Oh, needs a changelog entry!

ddssff commented 5 years ago

I see there is another PR with tryError.

Lysxia commented 5 years ago

I see there is another PR with tryError.

No worries about that. That PR I wrote is really meant to do something else, so I can rebase it on top of this later. I thought I needed tryError to write some property but actually I don't anymore (because the property is invalid).

chessai commented 5 years ago

@ddssff the builds failed because older versions of base's Prelude do not export <$>. i think on all GHCs before 7.10.3 you need to import Data.Functor ((<$>))

ddssff commented 5 years ago

MIN_VERSION_base(4,8,0) if I'm not mistaken

chessai commented 5 years ago

yeah, something like

#if !MIN_VERSION_base(4,8,0)
import Data.Functor ((<$>))
#endif

Alternatively, we could just use fmap, which has been exported by the Prelude for all supported versions of base. This would remove that bit of CPP. I don't have strong opinions about that, though I do prefer the least amount of CPP possible.

ddssff commented 5 years ago

Oh frabjous day.

chessai commented 5 years ago

Thanks!