natefaubion / purescript-run

An extensible-effects implementation
MIT License
158 stars 14 forks source link

added effects for Either and Maybe #8

Closed dwhitney closed 7 years ago

dwhitney commented 7 years ago

Hi Nate, I love this library! I've used the equivalent in Scala and while it's nice to get the benefits that Free/Freer monads offer, it pales in comparison to this lib!

As discussed on Slack, I've added effects for Maybe and Either, which makes do blocks quite a bit more clean. Example:

maybeEitherProgram :: ∀ eff r. Run(maybe :: MAYBE, either :: (EITHER String), eff ∷ EFF (console ∷ CONSOLE | eff) | r) Unit
maybeEitherProgram = do
  i1 <- liftMaybe (Just 10)
  i2 <- liftEither (Right 20)
  liftEff $ (log $ "A MAYBE, EITHER and EFF program will log 30 (I hope): " <> (show (i1 + i2)))
dwhitney commented 7 years ago

well... looks like EXCEPT does all this. Is there a sad clown emoji?