Skip to content

Instantly share code, notes, and snippets.

@benjaminweb
Last active December 6, 2023 19:27
Show Gist options
  • Save benjaminweb/bcaccecbdde765e05360a452c3d5a074 to your computer and use it in GitHub Desktop.
Save benjaminweb/bcaccecbdde765e05360a452c3d5a074 to your computer and use it in GitHub Desktop.
-- (as mnemonics : `a :: a' and `amb :: a -> m b')
-- left identity
return a >>= amb = amb a
MkMaybeeState (\z -> (Just x, z)) >>= amb = MkMaybeeState $ \s0 -> case (\z -> (Just (a, z))) s0 of
(Just a, s1) -> let MkMaybeeState f' = amb a in f' s1
(Nothing, s1) -> (Nothing, s1)
MkMaybeeState (\z -> (Just x, z)) >>= amb = MkMaybeeState $ \s0 -> case (return a) s0 of
(Just a, s1) -> let MkMaybeeState f' = amb a in f' s1
(Nothing, s1) -> (Nothing, s1)
MkMaybeeState (\z -> (Just x, z)) >>= amb = MkMaybeeState $ \s0 -> case (return a) s0 of
(Just a, s1) -> let MkMaybeeState f' = MkMaybeeState (\z -> (Just x, z)) in f' s1
(Nothing, s1) -> (Nothing, s1)
MkMaybeeState (\z -> (Just x, z)) >>= amb = MkMaybeeState $ \s0 -> case (return a) s0 of
(Just a, s1) -> (\z -> (Just x, z)) s1
(Nothing, s1) -> (Nothing, s1)
MkMaybeeState (\z -> (Just x, z)) >>= amb = MkMaybeeState $ \s0 -> case (return a) s0 of
(Just a, s1) -> (Just x, s1)
(Nothing, s1) -> (Nothing, s1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment