Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created March 7, 2019 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadronized/fe354a968ce4dd0a14499f903dca786a to your computer and use it in GitHub Desktop.
Save hadronized/fe354a968ce4dd0a14499f903dca786a to your computer and use it in GitHub Desktop.
-- Why not this implementation?
selectM :: (Monad f) => f (Either a b) -> f (a -> b) -> f b
selectM x y = do
e <- x
case e of
Left a -> fmap ($a) y
Right b -> fmap (const b) y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment