Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions packages/morphir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,35 @@ dependencies and does no IO.
| `morphir.sdk.decimal` | `Morphir.SDK.Decimal` | `decimal.Decimal` |
| `morphir.sdk.int` | `Morphir.SDK.Int` | `Int8`, `Int16`, `Int32`, `Int64` (`NewType` over `int`) |
| `morphir.sdk.number` | `Morphir.SDK.Number` | `Number`, an exact rational |

Not included yet: `LocalDate`, `LocalTime`, `Instant`, `UUID`, `Regex`,
`Aggregate`, `Rule`, `Key`, `StatefulApp`, `ResultList` and `Json`.
| `morphir.sdk.local_date` | `Morphir.SDK.LocalDate` | `datetime.date`, no time zone |
| `morphir.sdk.local_time` | `Morphir.SDK.LocalTime` | `LocalTime`, milliseconds from the epoch |
| `morphir.sdk.instant` | `Morphir.SDK.Instant` | `Instant`, milliseconds from the epoch |
| `morphir.sdk.uuid` | `Morphir.SDK.UUID` | `uuid.UUID` |
| `morphir.sdk.regex` | `Morphir.SDK.Regex` | `Regex` over the `re` module |
| `morphir.sdk.aggregate` | `Morphir.SDK.Aggregate` | `Aggregation`, `Operator` |
| `morphir.sdk.rule` | `Morphir.SDK.Rule` | `Callable[[A], Maybe[B]]` |
| `morphir.sdk.key` | `Morphir.SDK.Key` | `int` and flat tuples |
| `morphir.sdk.stateful_app` | `Morphir.SDK.StatefulApp` | `StatefulApp` |
| `morphir.sdk.result_list` | `Morphir.SDK.ResultList` | `tuple[Result[E, A], ...]` |

This is every module of the `Morphir.SDK` package specification. The `Json`
modules of morphir-elm are not part of that specification and are not included.

Notes on the modules beyond elm/core:

- `instant.Instant` is its own class over a number of milliseconds, not an alias
of `datetime.datetime`, so a naive `datetime` cannot pass as an instant. Use
`instant.from_datetime` and `instant.to_datetime` to convert.
- `local_time.LocalTime` is a point in time, not a time of day. In Elm it is an
alias of `Time.Posix`, so it does not go around midnight.
- `regex` patterns use Python `re` syntax, which differs from JavaScript in
places (named groups are `(?P<name>...)`, `\d` and `\w` follow Unicode). The
module docstring lists the differences.
- `aggregate` leaves out the part of the Elm module that inspects Morphir IR
values (`constructAggregationCall`); the specification does not list it.
`aggregate.aggregate` yields its rows in ascending key order.
- `key.Key4` and larger are flat tuples. Elm nests them only because an Elm tuple
holds three elements at most; the order of two keys is the same.

### Conventions

Expand Down
62 changes: 46 additions & 16 deletions packages/morphir/src/morphir/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,32 @@
`Morphir.IR.SDK.*` package specification of finos/morphir-elm. The reference
behaviour is elm/core 1.0.5 plus the `Morphir.SDK.*` Elm runtime.

======== ====================== =========================================
Module Elm module Python data
======== ====================== =========================================
basics Morphir.SDK.Basics `int`, `float`, `bool`, `Order`
char Morphir.SDK.Char `str` with one code point
string Morphir.SDK.String `str`
list Morphir.SDK.List `tuple[A, ...]`
dict Morphir.SDK.Dict `Dict[K, V]`, sorted by key
set Morphir.SDK.Set `Set[A]`, sorted
maybe Morphir.SDK.Maybe `Just[A] | Nothing`
result Morphir.SDK.Result `Ok[A] | Err[E]`
tuple Morphir.SDK.Tuple `tuple[A, B]`
decimal Morphir.SDK.Decimal `decimal.Decimal`
int Morphir.SDK.Int `Int8`, `Int16`, `Int32`, `Int64`
number Morphir.SDK.Number `Number`, an exact rational
======== ====================== =========================================
============ ======================= ========================================
Module Elm module Python data
============ ======================= ========================================
basics Morphir.SDK.Basics `int`, `float`, `bool`, `Order`
char Morphir.SDK.Char `str` with one code point
string Morphir.SDK.String `str`
list Morphir.SDK.List `tuple[A, ...]`
dict Morphir.SDK.Dict `Dict[K, V]`, sorted by key
set Morphir.SDK.Set `Set[A]`, sorted
maybe Morphir.SDK.Maybe `Just[A] | Nothing`
result Morphir.SDK.Result `Ok[A] | Err[E]`
tuple Morphir.SDK.Tuple `tuple[A, B]`
decimal Morphir.SDK.Decimal `decimal.Decimal`
int Morphir.SDK.Int `Int8`, `Int16`, `Int32`, `Int64`
number Morphir.SDK.Number `Number`, an exact rational
local_date Morphir.SDK.LocalDate `datetime.date`
local_time Morphir.SDK.LocalTime `LocalTime`, milliseconds from the epoch
instant Morphir.SDK.Instant `Instant`, milliseconds from the epoch
uuid Morphir.SDK.UUID `uuid.UUID`
regex Morphir.SDK.Regex `Regex` over the `re` module
aggregate Morphir.SDK.Aggregate `Aggregation`, `Operator`
rule Morphir.SDK.Rule `Callable[[A], Maybe[B]]`
key Morphir.SDK.Key `int` and flat tuples
stateful_app Morphir.SDK.StatefulApp `StatefulApp`
result_list Morphir.SDK.ResultList `tuple[Result[E, A], ...]`
============ ======================= ========================================

Conventions:

Expand Down Expand Up @@ -50,31 +60,51 @@
"""

from morphir.sdk import (
aggregate,
basics,
char,
decimal,
dict,
instant,
int,
key,
list,
local_date,
local_time,
maybe,
number,
regex,
result,
result_list,
rule,
set,
stateful_app,
string,
tuple,
uuid,
)

__all__ = [
"aggregate",
"basics",
"char",
"decimal",
"dict",
"instant",
"int",
"key",
"list",
"local_date",
"local_time",
"maybe",
"number",
"regex",
"result",
"result_list",
"rule",
"set",
"stateful_app",
"string",
"tuple",
"uuid",
]
Loading
Loading