# Pastebin aB77rjui import options proc mBind[T](o: Option[T], f: proc (value: T): T): Option[T] = if o.isSome: some f(o.get()) else: none T proc addOne(x: int): int = x + 1 let firstMaybe = some 1 afterBind = firstMaybe.mBind(addOne) assert afterBind.get == 2 let nothingMaybe = none int nothingAfterBind = nothingMaybe.mBind(addOne) assert nothingAfterBind == none int