News for hackers. Stuff that matters.
Re:Replacing Throwing Exceptions with Notification in Valida... by tel on Sunday December 14, 2014 @09:44PM (#8750466)
This pattern is totally embedded into the non-monadic applicative Either sometimes called Validation

    data Validation e a 
      = Collect e 
      | Value a 
      deriving Functor

    instance Monoid e => Applicative (Validation e) where
      pure a = Value a
      Collect le <*> Collect re = Collect (le <> re)
      Collect e  <*> _          = Collect e
      _          <*> Collect e  = Collect e
      Value f    <*> Value a    = Value (f a)
There is no monad instance for this which lets us scoot forward through a computation and and all of the errors at once.
Re:Replacing Throwing Exceptions with Notification in Valida... by HolyHaddock on Monday December 15, 2014 @04:29AM (#8751229)
This is worth understanding, and works out a lot better in practice than having to pass in ad-hoc collection builders as equally ignorable "out-params" or exceptions.