Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created May 17, 2025 12:09
Show Gist options
  • Save mypy-play/a8bd7ec1fde101f29deadca7c9a65833 to your computer and use it in GitHub Desktop.
Save mypy-play/a8bd7ec1fde101f29deadca7c9a65833 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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