def maybe(default, func, maybe_val):
    """Takes a default value, a function, and a Maybe value.
    If it's Nothing, return the default,
    else, return the function applied to the value."""
    if maybe_val.is_nothing:
        return default
    elif maybe_val.is_just:
        return func(maybe_val.value)