You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--| The `MonadOr` type class has no members of its own but extends-- | `MonadZero` with an additional law:-- |-- | - Left catch: `(return a) <|> b = return a`classMonadZerom<=MonadOrm
But it adding MonadOr will introduce other issue: some structures could conform to MonadOr and MonadPlus and adding empty MonadOr will make it impossible to express that. See example from MonadPlus reform proposal#Instances of both
instanceMonadPlusMaybewhere
mplus (Just a) Nothing=Just a
mplus Nothing (Just a) =Just a
mplus _ _ =NothinginstanceMonadOrMaybewhere-- this is same as definition in Alternative
morelse (Just a) _ =Just a
morelse _ b = b
instanceMonadOr[]where
morelse [] b = b
morelse a b = a
instanceMonadPlus[]where-- this is same as definition in Alternative
mplus =(++)
If we add MonadOr it should have function with different name then <|>, haskell proposal uses morelse. but except this, we should also add a function to MonadPlus too, as pointed above some structures supports both (Maybe or List).
Yes, I think we can safely say at this point that this class isn't in enough demand to deserve a spot in the core libraries, so I'm going to close this for now.
Uh oh!
There was an error while loading. Please reload this page.
it would be nice to add
MonadOr
typeclass:For example IO could be an instance of
MonadOr
.But it adding MonadOr will introduce other issue: some structures could conform to MonadOr and MonadPlus and adding empty MonadOr will make it impossible to express that. See example from MonadPlus reform proposal#Instances of both
If we add MonadOr it should have function with different name then
<|>
, haskell proposal usesmorelse
. but except this, we should also add a function to MonadPlus too, as pointed above some structures supports both (Maybe or List).Related discussion in Fantasy Land
The text was updated successfully, but these errors were encountered: