Idris2/tests/idris2/interface/interface004/Do.idr
2023-09-07 14:57:22 +01:00

15 lines
307 B
Idris

public export
interface Do (0 m : Type) where
0 Next : m -> Type
bind : (x : m) -> Next x
public export
Monad m => Do (m a) where
Next x = {b : Type} -> (a -> m b) -> m b
bind x k = x >>= k
foo : Maybe Int -> Maybe Int -> Maybe Int
foo x y
= bind x (\x' =>
bind y (\y' => Just (x' + y')))