Skip to main content

\

Project description

oculist

Statically typed, purely functional lenses for Python.

Features

Quickstart

from dataclasses import dataclass

from oculist import Lens


@dataclass(frozen=True)
def Address:
    street: Lens[str] = Lens()


@dataclass(frozen=True)
def User:
    name: Lens[str] = Lens()  # 'Lens' is a descriptor
    address: Lens[Address] = Lens()


bob = User('bob', Address("Some st."))

alice = (
    bob
    > User.name << 'alice'  # Define transformations using << and apply using >
    | User.address * Address.street << 'Other st.' # Compose transformations with | and chain lenses with *
)

assert bob.name == 'bob' and alice.name == 'alice'  # original target is left untouched

Concepts

Lenses, Attributes and Setters

Special Lenses

List

Tuple

Dict

Set

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oculist-0.0.0.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

oculist-0.0.0-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file oculist-0.0.0.tar.gz.

File metadata

  • Download URL: oculist-0.0.0.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Darwin/23.1.0

File hashes

Hashes for oculist-0.0.0.tar.gz
Algorithm Hash digest
SHA256 f94675a1389f9bef0c806c6d4f5ef18287d66560203e48b3cb5bb14abd14deee
MD5 63243f9fa50c02d1132b0d3e1ded40ac
BLAKE2b-256 0fbcaccdaa0457ad08c1013ae1180cd4a2545e1400a9c48832f2bb3737620878

See more details on using hashes here.

File details

Details for the file oculist-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: oculist-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Darwin/23.1.0

File hashes

Hashes for oculist-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21abd970f8598989c824321d94b5c915158907b32f5bb0d0787b7233b4f46e08
MD5 de78f07bc982148f267b0b5793d03509
BLAKE2b-256 6a15947a879b505f0b2c5d19c65fa88cea57a035e1ce510a42dcd2f6c2bc41c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page