Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created March 7, 2019 13:38
Show Gist options
  • 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