MessagePack.FSharpExtensions 3.0.0

Install-Package MessagePack.FSharpExtensions -Version 3.0.0
dotnet add package MessagePack.FSharpExtensions --version 3.0.0
<PackageReference Include="MessagePack.FSharpExtensions" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MessagePack.FSharpExtensions --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MessagePack.FSharpExtensions, 3.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MessagePack.FSharpExtensions as a Cake Addin
#addin nuget:?package=MessagePack.FSharpExtensions&version=3.0.0

// Install MessagePack.FSharpExtensions as a Cake Tool
#tool nuget:?package=MessagePack.FSharpExtensions&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MessagePack.FSharpExtensions

NuGet Status

MessagePack.FSharpExtensions is a MessagePack-CSharp extension library for F#.

Usage

open System
open System.Buffers
open MessagePack
open MessagePack.Resolvers
open MessagePack.FSharp

[<MessagePackObject>]
type UnionSample =
  | Foo of XYZ : int
  | Bar of OPQ : string list

let convertAsMemory<'T> options (value: 'T) =
  let memory = ReadOnlyMemory(MessagePackSerializer.Serialize(value, options))
  MessagePackSerializer.Deserialize<'T>(memory, options)

let convertAsSequence<'T> options (value: 'T) =
  let sequence = ReadOnlySequence(MessagePackSerializer.Serialize(value, options))
  MessagePackSerializer.Deserialize<'T>(& sequence, options)

let dump = function
| Foo x ->
  printfn "%d" x
| Bar xs ->
  printfn "%A" xs

let resolver =
  Resolvers.CompositeResolver.Create(
    FSharpResolver.Instance,
    StandardResolver.Instance
)

let options = MessagePackSerializerOptions.Standard.WithResolver(resolver)

Foo 999
|> convertAsMemory options
|> dump

Bar ["example"]
|> convertAsSequence options
|> dump

Supported types

  • option
  • voption
  • list
  • map
  • set
  • Discriminated Union
  • Struct Discriminated Union

Records, Struct Records and Anonymous Records are serialized and deserialized using DynamicObjectResolver in MessagePack-CSharp.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MessagePack.FSharpExtensions:

Package Downloads
FSharpApiSearch

F# API search engine

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 99 9/25/2021
2.1.0 15,109 5/21/2020
2.0.0 198 5/20/2020
1.4.1 66,671 1/8/2019
1.4.0 10,333 10/9/2017
1.3.0 509 10/7/2017
1.2.0 1,107 7/5/2017
1.1.0 658 5/20/2017
1.0.0 580 3/30/2017
0.1.0 552 3/17/2017