Metadata-Version: 2.1
Name: enum-adt
Version: 0.0.2
Summary: Enum Algebraic Data Types (ADTs) for Python
Author-Email: Frost Ming <me@frostming.com>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Project-URL: Repository, https://github.com/frostming/enum-adt
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# enum-adt

Enum Algebraic Data Types (ADTs) for Python.

## Installation

Run the following command to install the Python package on Python 3.8 or later:

```bash
pip install enum-adt
```

Or you can simply copy the `enum_adt.py` file anywhere in your project.

## Usage

```python
from enum_adt import ADT

class MyEnum(ADT):
    class Foo: ...

    class Bar:
        name: str

foo = MyEnum.Foo()
bar = MyEnum.Bar("bar")
assert isinstance(foo, MyEnum)
assert isinstance(bar, MyEnum)
```

Alternatively, you can use metaclass:

```python
from enum_adt import ADTMeta

class MyEnum(metaclass=ADTMeta):
    class Foo: ...

    class Bar:
        name: str
```

Each internal class will be created as a `dataclass` with the same attributes. You can customize the dataclass by passing arguments to the class:

*All enum variants get the same arguments.*

```python
from enum_adt import ADT

class MyEnum(ADT, frozen=True, kw_only=True):
    class Foo: ...

    class Bar:
        name: str
```

## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
