RosettaCodeData/Task/Monads-Maybe-monad/Factor/monads-maybe-monad-1.factor
2023-07-01 13:44:08 -04:00

10 lines
317 B
Factor

USING: monads ;
FROM: monads => do ;
! Prints "T{ just { value 7 } }"
3 maybe-monad return >>= [ 2 * maybe-monad return ] swap call
>>= [ 1 + maybe-monad return ] swap call .
! Prints "nothing"
nothing >>= [ 2 * maybe-monad return ] swap call
>>= [ 1 + maybe-monad return ] swap call .