erg_compiler 0.6.3

Centimetre: the Erg compiler
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# from typing import TypeVar, Union, _SpecialForm, _type_check

class Error:
    def __init__(self, message):
        self.message = message

# T = TypeVar("T")
# @_SpecialForm
def Result(self, parameters):
    """Result type.

    Result[T] is equivalent to Union[T, Error].
    """
    # arg = _type_check(parameters, f"{self} requires a single type.")
    return [arg, Error]

def is_ok(obj) -> bool:
    return not isinstance(obj, Error)