mirror of
https://github.com/github/semantic.git
synced 2024-12-19 21:01:35 +03:00
Define a MonadError instance for Amb.
This commit is contained in:
parent
5ca85ec4ed
commit
9572b96fa4
@ -1,5 +1,7 @@
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
module Data.Amb where
|
||||
|
||||
import Control.Monad.Error.Class
|
||||
import Data.List.NonEmpty
|
||||
import Data.Semigroup
|
||||
|
||||
@ -23,3 +25,8 @@ instance Monad (Amb l) where
|
||||
return = pure
|
||||
None a >>= _ = None a
|
||||
Some as >>= f = foldr1 (<>) (f <$> as)
|
||||
|
||||
instance MonadError l (Amb l) where
|
||||
throwError = None
|
||||
None a `catchError` f = f a
|
||||
Some as `catchError` _ = Some as
|
||||
|
Loading…
Reference in New Issue
Block a user