Idris2/tests/idris2/interface004/Do.idr
Edwin Brady a972778eab Add test script
They don't all pass yet, for minor reasons. Coming shortly...
Unfortunately the startup overhead for chez is really noticeable here!
2020-05-19 18:25:18 +01:00

16 lines
304 B
Idris

public export
interface Do (m : Type) where
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')))