| | 291 | ====Restricted Monads==== |
| | 292 | |
| | 293 | '''Tom''': This way we can also make Set an instance of (C)Monad. I believe lots of people |
| | 294 | have been asking for this. |
| | 295 | |
| | 296 | {{{ |
| | 297 | |
| | 298 | class CMonad m where |
| | 299 | class Condition m :: * -> Class |
| | 300 | (>>=) :: (Condition a, Condition b) => m a -> (a -> m b) -> m b |
| | 301 | (>>) :: (Condition a, Condition b) => m a -> m b -> m b |
| | 302 | return :: Condition a => a -> m a |
| | 303 | fail :: Condition a => String -> m a |
| | 304 | |
| | 305 | instance CMonad [] where |
| | 306 | class Condition [] a |
| | 307 | ... |
| | 308 | |
| | 309 | instance CMonad Set where |
| | 310 | class Eq a => Condition Set a |
| | 311 | ... |
| | 312 | |
| | 313 | }}} |
| | 314 | |