============
|build status|
Union types For python.
These appear other languages like Haskell (``Either``) and
Scala (``Union`` or ``\/``).
This extends to any arbirary set of types.
Examples
--------
Creating a union type
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> from uniontypes import Union
>>> u = Union[list, tuple, str]
>>> u
<class 'uniontypes.Union[list, tuple, str]'>
Creating boxed values
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> u([1, 2, 3])
Union[list, tuple, str][list] [1, 2, 3]
>>> u((1, 2, 3))
Union[list, tuple, str][tuple] (1, 2, 3)
>>> u('123')
Union[list, tuple, str][str] '123'
Accessing the inner wrapper types
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> u[list]
<class 'uniontypes.Union[list, tuple, str][list]'>
>>> u[tuple]
<class 'uniontypes.Union[list, tuple, str][tuple]'>
>>> u[str]
<class 'uniontypes.Union[list, tuple, str][str]'>
Class heirarchy
~~~~~~~~~~~~~~~
.. code-block:: python
>>> isinstance(u([1, 2, 3]), u)
True
>>> isinstance(u([1, 2, 3]), u[list])
True
>>> isinstance(u([1, 2, 3]), (u[tuple], u[str]))
False
Option Types
------------
.. code-block:: python
>>> from uniontypes import Option
>>> oint = Option[int]
>>> oint
<class 'uniontypes.Option[int]'>
>>> oint(1)
Option[int] 1
>>> oint(None)
Nothing
>>> oint(None) is oint.nothing
True
.. |build status| image:: https://travis-ci.org/llllllllll/uniontypes.svg?branch=master
:target: https://travis-ci.org/llllllllll/uniontypes
Metadata
Release files for uniontypes 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uniontypes-0.1.0.tar.gz | 3.6 kB | Without provenance | Details for uniontypes-0.1.0.tar.gz |
Release files / uniontypes-0.1.0.tar.gz
| Download URL | uniontypes-0.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
671dec4cbe1a1af6506f24a19f83b589aaa6ed1a78704e4bca7bb4b529e3e8a3
|
|
BLAKE2b-256 checksum How to use checksums |
0d09a2b47ceb2b926d6184c63cc60ca45b2c7edfbac1e9ac9a05b1d415c332d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for uniontypes 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.