Created
May 17, 2025 12:09
-
-
Save mypy-play/a8bd7ec1fde101f29deadca7c9a65833 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from typing import TypeVar | |
T = TypeVar("T") | |
type Monad[T] = T | None | |
def monadic() -> Monad[int]: | |
if random.random() > 0.5: | |
return 1 | |
return None | |
monadic() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment