Morphir.SDK.FSharp 0.5.0-alpha.2

Prefix Reserved
This is a prerelease version of Morphir.SDK.FSharp.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Morphir.SDK.FSharp --version 0.5.0-alpha.2
                    
NuGet\Install-Package Morphir.SDK.FSharp -Version 0.5.0-alpha.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Morphir.SDK.FSharp" Version="0.5.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Morphir.SDK.FSharp" Version="0.5.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="Morphir.SDK.FSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Morphir.SDK.FSharp --version 0.5.0-alpha.2
                    
#r "nuget: Morphir.SDK.FSharp, 0.5.0-alpha.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Morphir.SDK.FSharp@0.5.0-alpha.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Morphir.SDK.FSharp&version=0.5.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Morphir.SDK.FSharp&version=0.5.0-alpha.2&prerelease
                    
Install as a Cake Tool

Morphir.SDK.FSharp

F# runtime library providing Morphir SDK types and functions for generated F# code.

Overview

Morphir.SDK.FSharp provides the F# runtime used by generated Morphir code. Its namespace and runtime assembly remain Morphir.SDK.

Installation

dotnet add package Morphir.SDK.FSharp

Migrating existing consumers

Replace the Morphir.SDK package reference with Morphir.SDK.FSharp, using the same release version. Keep open Morphir.SDK and existing generated source unchanged. Project-reference consumers use src/Morphir.SDK.FSharp/Morphir.SDK.FSharp.fsproj.

The legacy Morphir.SDK package remains installable. It depends on the exact matching canonical package version and contains no runtime assembly. Installing either package or both resolves the same Morphir.SDK.dll. Do not reference the legacy pack-only project as a runtime project dependency.

The migration preserves the Morphir.SDK.Order type identity, existing public entry points and F# aliases. Aliases such as Maybe<'a>, Dict<'k,'v>, LocalDate and LocalTime retain their FSharp.Core/BCL types. They do not become new CLR wrapper or forwarding types.

Select the FSharp.Core version required by the package. The captured baseline uses 11.0.100; a compiler's lower implicit dependency can otherwise cause NU1605 and runtime loading failures. For an SDK whose implicit version is lower:

<PropertyGroup>
  <FSharpCoreImplicitPackageVersion>11.0.100</FSharpCoreImplicitPackageVersion>
  <WarningsAsErrors>$(WarningsAsErrors);NU1605</WarningsAsErrors>
</PropertyGroup>

The bounded conformance contract and migration corrections are tracked in issue #465. Packaging identity preservation does not claim that behavior corrections replace old code already inlined into an existing binary.

Covered behavior changes

The package migration also corrects the cases admitted by the shared morphir-dotnet-sdk-v1 / dotnet-sdk-v1 contract. It does not certify every SDK operation or every host representation.

  • Dict.union left right now keeps left's value for a shared key. Previously the second dictionary won. For example, unioning [("rate", 1)] with [("rate", 9)] now yields [("rate", 1)]. Both operands remain unchanged.
  • Int32 Basics.add, subtract, multiply and negate report overflow instead of wrapping. The generic public entry points remain available.
  • Basics.remainderBy -1 System.Int32.MinValue and Basics.modBy with those operands return zero. Previously the host remainder instruction overflowed.
  • Basics.compare compares direct String operands by ordinal UTF-16 code units, without culture or normalization. For example, decomposed "e\u0301" sorts before precomposed "\u00e9"; they no longer compare equal through collation.
  • Decimal.toString uses invariant positional text and removes fractional trailing zeros. 1.50M becomes "1.5", and scaled zero becomes "0". Decimal.fromString parses this canonical representation first under every culture, then tries the caller's culture for other input. For example, under de-DE, both "1.5" and localized "1,5" mean 1.5M. Ambiguous dot-separated input follows canonical decimal-point semantics rather than localized grouping. Parsing remains a native API compatibility check outside the frozen inventory.
  • Additive Basics.round, floor, ceiling and truncate convert Float to Int32 with non-finite and overflow checks. Round resolves halves toward positive infinity: round -2.5 = -2.
  • Additive Decimal.div returns None for a zero divisor and Some quotient otherwise. Existing Decimal.divide still returns decimal and retains its existing zero-divisor exception behavior. Exact terminating Decimal96 division is covered; nonterminating or unrepresentable results are separate exclusions.

Already compiled inline calls can retain their old arithmetic, union or formatting behavior. Recompile consumers to use corrected inline bodies. Installing the canonical runtime alone preserves their type loading; it cannot replace code embedded in another assembly.

Features

  • Type Aliases: Morphir types mapped to idiomatic F# types (e.g., Maybe<'a> = Option<'a>)
  • Standard Library: F# SDK functions; the shared contract defines the bounded conformance inventory
  • Immutable Collections: Dict (Map), Set, List operations
  • Date/Time Support: LocalDate (DateOnly), LocalTime (TimeOnly)
  • AOT Compatible: No reflection, ready for Native AOT compilation

Modules

Core Types

  • Basics: Fundamental operations (Order type, comparison, arithmetic)
  • Maybe: Optional values (Option<'a> alias with helper functions)
  • Result: Error handling (Result<'v, 'e> with combinators)

Collections

  • List: List operations and extensions
  • Dict: Immutable dictionaries (Map<'k, 'v> alias)
  • Set: Set operations
  • Tuple: Tuple helper functions

Primitives

  • String: String manipulation functions
  • Int: Integer operations
  • Bool: Boolean logic
  • Char: Character operations
  • Decimal: Decimal arithmetic

Date/Time

  • LocalDate: Date without timezone (DateOnly alias)
  • LocalTime: Time without timezone (TimeOnly alias)

Usage Examples

Maybe (Option)

open Morphir.SDK

let user = { name = "Alice"; email = Some "alice@example.com" }

let emailDomain =
    user.email
    |> Maybe.map (String.split "@")
    |> Maybe.andThen List.last
    |> Maybe.withDefault "unknown"

Result

open Morphir.SDK

let validateAge age =
    if age < 0 then
        Result.err "Age cannot be negative"
    elif age > 150 then
        Result.err "Age is too high"
    else
        Result.ok age

let processAge =
    validateAge 25
    |> Result.map (fun age -> age + 1)
    |> Result.withDefault 0

List

open Morphir.SDK

let numbers = [1; 2; 3; 4; 5]

let result =
    numbers
    |> List.map (fun x -> x * 2)
    |> List.filter (fun x -> x > 5)
    |> List.sum
// result = 18

Dict

open Morphir.SDK

let scores =
    Dict.fromList [
        ("Alice", 95)
        ("Bob", 87)
        ("Charlie", 92)
    ]

let aliceScore = Dict.get "Alice" scores
// Some 95

let updatedScores = Dict.insert "David" 88 scores

LocalDate

open Morphir.SDK

let today = LocalDate.today()
let nextWeek = LocalDate.addDays 7 today
let formatted = LocalDate.toIsoString nextWeek
// "2025-01-07"

let parsed = LocalDate.fromIsoString "2025-12-31"
// Some (LocalDate(2025, 12, 31))

Relationship to morphir-elm

This library provides F# implementations of types and functions from morphir-elm's SDK. The API is designed to maintain semantic compatibility while leveraging F#'s native types and idioms.

Key Mappings

morphir-elm Morphir.SDK (F#) F# Native Type
Maybe a Maybe<'a> Option<'a>
Result e v F# Result<'v, 'e> Result<'v, 'e>
List a 'a list List<'a>
Dict k v Dict<'k, 'v> Map<'k, 'v>
Set a Set<'a> Set<'a>
LocalDate LocalDate DateOnly
LocalTime LocalTime TimeOnly

Design Principles

  1. Type Aliases Over Wrappers: Use F# built-in types directly when possible
  2. Zero-Cost Abstractions: No runtime overhead for type conversions
  3. Idiomatic F#: Follow F# conventions and naming patterns
  4. AOT Compatibility: No reflection or dynamic code generation
  5. Semantic Compatibility: Maintain morphir-elm behavior

Version Compatibility

  • Canonical package: Morphir.SDK.FSharp
  • Compatibility package: Morphir.SDK, at the matching version
  • .NET: 10.0+
  • F#: 9.0+
  • morphir-elm: Compatible with Morphir IR 2.x and 3.x

Contributing

This library is part of the morphir-dotnet project. For contributions, please see the main repository's CONTRIBUTING.md.

License

Apache License 2.0 - See LICENSE in the morphir-dotnet repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Morphir.SDK.FSharp:

Package Downloads
Morphir.SDK

Compatibility package for the Morphir F# runtime. Depends on Morphir.SDK.FSharp, which retains the Morphir.SDK namespace and runtime assembly identity.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0-alpha.3 49 11/14/2026
0.5.0-alpha.2 46 11/13/2026
0.5.0-alpha.1 46 11/13/2026
0.4.0-alpha.5 48 11/13/2026
0.4.0-alpha.4 50 11/10/2026
0.4.0-alpha.3 58 11/9/2026
0.4.0-alpha.2 59 11/8/2026
0.4.0-alpha.1 57 11/7/2026

### Fixed

- `morphirup setup --yes` and extension package installation work on macOS 15. Before, they failed with `extension.io_error: Cannot access '…/store/extensions/packages/sha256': native error 13.` macOS 15 refuses to rename a directory that is not writable, even when the directory stays in the same parent, and the installer sealed a package (mode 0555) before it published it with a rename. macOS 26 allows that rename, so the macos-latest jobs passed. The installer now seals the package's contents before publication and the package root after it, while it still holds the state lock. An installation of a package that is already in the store seals the root if a publication was interrupted before it did.
- Build: the release and its dry run also run the osx-arm64 setup journey on macOS 15 (`build-morphirup`, `os: macos-15`), beside macos-latest (macOS 26). That leg uploads nothing: the new `morphirup-build.yml` input `upload` (default `true`) is `false` for it, and the macos-latest leg still produces the osx-arm64 assets. Pull requests do not run it.

### Changed

- `morphirup setup` sets up from the [finos/morphir releases](https://github.com/finos/morphir/releases), the official place for Morphir releases, from the next release, `0.5.0-alpha.2`, on. It downloads from `https://github.com/finos/morphir/releases/download/v<version>/`, with the same `v<version>` tag and the same three redirect hosts (`github.com`, `release-assets.githubusercontent.com`, `objects.githubusercontent.com`, at most three redirects), and keeps its `release-checksum` assurance. There is no fallback to the finos/morphir-dotnet releases: a bundle whose asset URLs name finos/morphir-dotnet is refused. A release generation records `https://github.com/finos/morphir` as its repository; the candidate's `sourceRepository` still names finos/morphir-dotnet, where the code is built from.
- The composed local-toolchains family moves from `0.1.0-preview.4` to `0.1.0-preview.5` ([finos/morphir#1171](https://github.com/finos/morphir/pull/1171), merged as `00a48d4a`), which differs from preview.4 only in the release repository of the bundle's asset URLs and of the generation's `acquisition.repository`. The producer writes preview.5, and `morphirup` reads preview.5 only: candidates, bundles, receipts, selections and generations of preview.4 (written by 0.5.0-alpha.1) are not read and are not converted. `select`, `show` and `run` read only the preview.5 selection pointer: in a Home set up with preview.2, preview.3 or preview.4 they refuse with `local.setup_required`, which says to run `morphirup setup --yes` again (and then `select`, for a local candidate). Setup in that Home installs preview.5 beside the earlier generations without reading them, and replaces the selection pointer. A refused `setup`, `select` or `show` writes a preview.5 result. The historical preview.1 local route is unchanged.
- Build: finos/morphir can call `morphirup-build.yml` at a pinned commit of this repository, as it calls `cli-offering.yml`. The new inputs `repository` and `ref` (a full commit SHA) choose what the job checks out and builds, and the Windows source check compares the checkout with `ref`. With the new input `upload-host-offering: true`, a job that packs a toolchain (win-x64, win-arm64, or osx-arm64 with `toolchain: true`) also uploads its self-contained host as the artifact `morphir-dotnet-self-contained-<rid>`: the archive with its `.build-launch.json`, `.build-contents.json` and `.sha256`, the files `cli-offering.yml` uploads for that offering. The inputs default to empty and `false`, so `morphirup.yml` and `deployment.yml` work as before. The checkout no longer keeps the workflow token in the Git configuration.