Python port of Morphir - a library of tools for building and working with functional domain models.
Morphir enables you to write business logic once and use it across multiple platforms, languages, and runtimes. It provides a strongly-typed intermediate representation (IR) that captures the semantics of your domain model.
This monorepo contains two packages:
If you just need the Morphir library for your Python project:
pip install morphirOr with uv:
uv add morphirFor the full toolset including CLI commands:
pip install morphir-toolsOr with uv:
uv add morphir-toolsfrom morphir.ir import Type, Value
# Example usage will be added as the library developsmorphir.sdk is the Python runtime for the Morphir SDK, the standard library that
Morphir models compile against. It covers the core modules of the
Morphir.IR.SDK specification: basics, char, string, list, dict, set,
maybe, result, tuple, decimal, int and number. The behaviour follows
elm/core 1.0.5 and the Morphir.SDK Elm runtime.
from morphir.sdk import basics
from morphir.sdk import decimal as Decimal
from morphir.sdk import dict as Dict
from morphir.sdk import list as List
from morphir.sdk import maybe as Maybe
from morphir.sdk.maybe import Just, Nothing
# Elm argument order, data last, not curried
List.map(lambda n: n * 2, (1, 2, 3)) # (2, 4, 6)
Maybe.with_default(0, List.head(())) # 0
# Immutable Dict, sorted by structural comparable keys
prices = Dict.from_list(((("EUR", 2), 1.5), (("EUR", 1), 1.2)))
Dict.keys(prices) # (("EUR", 1), ("EUR", 2))
Dict.get(("EUR", 1), prices) # Just(value=1.2)
# Elm number rules
basics.round(2.5) # 3, not Python's 2
basics.integer_divide(-7, 2) # -3
Decimal.to_string(Decimal.add(Decimal.tenth(1), Decimal.tenth(2))) # "0.3"Names are the Elm names in snake_case (withDefault is with_default). See the
morphir package README for the
conventions and the list of departures from Elm.
- Python 3.14+
This project uses mise for tool management and uv for Python package management.
Install mise (if not already installed):
curl https://mise.run | sh- Clone the repository:
git clone https://github.com/finos/morphir-python.git
cd morphir-python- Install tools and dependencies:
mise install
uv sync --all-groups- Run the checks:
mise run check| Task | Description |
|---|---|
mise run lint |
Run ruff linter |
mise run format |
Run ruff formatter |
mise run typecheck |
Run mypy and pyright |
mise run test |
Run pytest unit tests |
mise run test-bdd |
Run behave BDD tests |
mise run test-all |
Run all tests |
mise run coverage |
Run tests with coverage |
mise run check |
Run all checks |
mise run build |
Build packages |
mise run clean |
Clean build artifacts |
This project follows functional programming principles:
- Immutability: Data structures are immutable by default
- Type Safety: Strict type annotations with mypy and pyright
- Algebraic Data Types: Using
@dataclass(frozen=True), Unions, and Protocols - Making Illegal States Unrepresentable: Domain modeling that prevents invalid states at compile time
- Core IR model implementation
- Morphir SDK runtime (
morphir.sdk) - core modules done - JSON serialization/deserialization
- Type checking and validation
- Code generation backends
- CLI tooling
For any questions, bugs or feature requests please open an issue. For anything else please send an email to morphir@finos.org.
To submit a contribution:
- Fork it (https://github.com/finos/morphir-python/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Read our contribution guidelines and Community Code of Conduct
- Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
NOTE: Commits and pull requests to FINOS repositories will only be accepted from those contributors with an active, executed Individual Contributor License Agreement (ICLA) with FINOS OR who are covered under an existing and active Corporate Contribution License Agreement (CCLA) executed with FINOS. Commits from individuals not covered under an ICLA or CCLA will be flagged and blocked by the FINOS Clabot tool (or EasyCLA). Please note that some CCLAs require individuals/employees to be explicitly named on the CCLA.
Need an ICLA? Unsure if you are covered under an existing CCLA? Email help@finos.org
- Morphir - The main Morphir project
- Morphir Elm - Elm implementation
- Morphir Scala - Scala implementation
Copyright 2026 FINOS
Distributed under the Apache License, Version 2.0.
SPDX-License-Identifier: Apache-2.0