Skip to content

Instantly share code, notes, and snippets.

@ulysses4ever
Created June 29, 2018 10:59
Show Gist options
  • Save ulysses4ever/f0700faedb3dc2c47457a87ff1327e5a to your computer and use it in GitHub Desktop.
Save ulysses4ever/f0700faedb3dc2c47457a87ff1327e5a to your computer and use it in GitHub Desktop.
`Selective` exercise: `select` of `handle`
import Data.Either (either)
import Data.Functor ((<$>))
class Applicative f => Selective f where
handle :: f (Either a b) -> f (a -> b) -> f b
select :: Selective f =>
f (Either a b) -> f (a -> c) -> f (b -> c) -> f c
select e fa fb = handle (Left <$> e) (either <$> fa <*> fb)
main = undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment