1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 09:55:52 +03:00

Define a Monad instance for Amb.

This commit is contained in:
Rob Rix 2017-08-03 17:02:47 -04:00
parent aeb4a65c61
commit 5ca85ec4ed

View File

@ -18,3 +18,8 @@ instance Applicative (Amb l) where
None l <*> _ = None l
_ <*> None r = None r
Some fs <*> Some as = Some (fs <*> as)
instance Monad (Amb l) where
return = pure
None a >>= _ = None a
Some as >>= f = foldr1 (<>) (f <$> as)