Skip to content

Commit

Permalink
Convenience Functor instance for Result
Browse files Browse the repository at this point in the history
Summary: The Result type admits a Functor instance and I've found it useful.

Reviewed By: simonmar

Differential Revision: D41469853

fbshipit-source-id: 619941cf58e679dd2f7a483362d2c108e0aec452
  • Loading branch information
Josef Svenningsson authored and facebook-github-bot committed Nov 23, 2022
1 parent ef52a52 commit 6cd30c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Haxl/Core/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,11 @@ instance (Show a) => Show (Result u w a) where
show (Throw e) = printf "Throw(%s)" $ show e
show Blocked{} = "Blocked"

instance Functor (Result u w) where
fmap f (Done a) = Done (f a)
fmap _ (Throw exc) = Throw exc
fmap f (Blocked ivar cont) = Blocked ivar (f :<$> cont)

{- Note [Exception]
How do we want to represent Haxl exceptions (those that are thrown by
Expand Down

0 comments on commit 6cd30c0

Please sign in to comment.