FSharp.Literals 2.2.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package FSharp.Literals --version 2.2.4                
NuGet\Install-Package FSharp.Literals -Version 2.2.4                
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="FSharp.Literals" Version="2.2.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FSharp.Literals --version 2.2.4                
#r "nuget: FSharp.Literals, 2.2.4"                
#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.
// Install FSharp.Literals as a Cake Addin
#addin nuget:?package=FSharp.Literals&version=2.2.4

// Install FSharp.Literals as a Cake Tool
#tool nuget:?package=FSharp.Literals&version=2.2.4                

FSharp.Literals

The package includes several features for literals:

  • To print values and types in F# source code style.

  • To get default value from type info.

Getting it over NuGet

Install-Package FSharp.Literals

The main usage

The basic usage is Literal.stringify<'t> (obj:'t):

open FSharp.Literals
Literal.stringify ([1], [true])

result is F# source code, it can be pasted directly into F# files.

[1], [true]

This code uses .NET and F# reflection to walk the structure of values so as to build a formatted representation of the value. You format structural types such as lists and tuples using the syntax of F# source code. Unrecognized values are formatted by calling the F# sprintf "%A" method for these values.

The overloads function as same output as Literal.stringify is:

open FSharp.Literals
Literal.stringifyDynamic typeof<int list * bool list> ([1], [true])

The basic usage is Literal.printTypeDynamic (ty:Type):

open FSharp.Literals

let ty = typeof<(string*int)*(float*bool)>
let y = Literal.printTypeDynamic ty
Should.equal y "(string*int)*(float*bool)"

You can also use shortcut methods same as this method:

let y = Literal.printType<(string*int)*(float*bool)>
Should.equal y "(string*int)*(float*bool)"

to print F# types using the syntax of F# source code. In order to please the C#-programmers, it's all this list<int> style instead of int list. You can also re-implement TypePrinter interfaces to custom printed result in your styles.

Note: Should.equal in library FSharp.xUnit.

default value

You often need to know the default values for a certain type. You can use function Literal.defaultValueDynamic:

let x = typeof<char>
let y = Literal.defaultValueDynamic x :?> char
should.equal y '\u0000'

You can also use shortcut methods same as this method:

let y = Literal.defaultValue<char>
should.equal y '\u0000'

It can resolve any type of default value, the system defines common composite types, even if the system is not defined types that you need, you can supplement the composite types that you need, the library provides a recursive framework.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on FSharp.Literals:

Package Downloads
FSharpCompiler.Lex

Lex are tools for generating lexical analyzer.

FSharpCompiler.Yacc

Yacc utility for.NET platform. Yacc are tools for generating parsers.

FSharpCompiler.Json

FSharpCompiler.Json is a JSON serializer for F#.

FSharp.ObjectCatalogViews

Print the SQL database as an F# record types.

FSharp.JLinq

`FSharp.JLinq` is a library to enhance JToken located in `Newtonsoft.Json.Linq`.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.15 336 10/18/2023
2.2.14 206 9/23/2023
2.2.13 185 9/17/2023
2.2.12 450 7/21/2023
2.2.11 3,829 10/19/2022
2.2.10 430 10/19/2022
2.2.9 16,226 3/8/2022
2.2.8 6,428 1/2/2022
2.2.7 487 12/31/2021
2.2.6 832 12/28/2021
2.2.5 3,001 10/28/2021
2.2.4 507 10/26/2021
2.2.3 4,378 7/18/2021
2.2.2 427 7/18/2021
2.2.1 1,360 6/15/2021
2.2.0 860 4/10/2021
2.1.4 3,817 3/10/2021
2.1.3 367 3/9/2021
2.1.2 390 3/7/2021
2.1.1 538 3/4/2021
2.1.0 379 3/3/2021
2.0.10 676 2/26/2021
2.0.9 1,183 2/20/2021
2.0.8 341 2/16/2021
2.0.7 528 2/13/2021
2.0.6 593 2/11/2021
2.0.5 2,164 1/4/2021
2.0.4 480 12/26/2020
2.0.3 428 11/27/2020
2.0.2 723 9/26/2020
2.0.1 491 8/19/2020
2.0.0 444 8/17/2020
1.0.0 597 6/14/2020

update HashSet.