A type-safe set that contains at least one element.
open FSharpPlus
open FSharpPlus.Data
// you can construct a NonEmptySet by using NonEmptySet.Create
let set123 = NonEmptySet.Create(1, 2, 3)
let set4 = NonEmptySet.singleton 4
let set4' : NonEmptySet<int> = result 4
// union two NonEmptySets
let set1234 = NonEmptySet.union set123 set4
// in order to get back to a regular set you can then use NonEmptySet.toSet:
let set1234' = NonEmptySet.toSet set1234
let set12345 = set1234 |> NonEmptySet.add 5
let set12345' = NonEmptySet.unionMany (NonEmptyList.create set123 [set4; result 5])
printfn "%b" (NonEmptySet.isSubset set1234 set12345)
namespace FSharpPlus
namespace FSharpPlus.Data
val set123: NonEmptySet<int>
Multiple items
module NonEmptySet
from FSharpPlus.Data
<summary>
Basic operations on NonEmptySet
</summary>
--------------------
type NonEmptySet<'a (requires comparison)> =
private { Value: Set<'a> }
interface NonEmptySeq<'a>
interface IReadOnlyCollection<'a>
interface IEnumerable<'a>
interface IEnumerable
member Add: value: 'a -> NonEmptySet<'a>
member Contains: value: 'a -> bool
member IsProperSubsetOf: other: NonEmptySet<'a> -> bool
member IsProperSupersetOf: other: NonEmptySet<'a> -> bool
member IsSubsetOf: other: NonEmptySet<'a> -> bool
member IsSupersetOf: other: NonEmptySet<'a> -> bool
...
<summary>
A type-safe set that contains at least one element.
</summary>
static member NonEmptySet.Create: first: 'a * [<System.ParamArray>] rest: 'a array -> NonEmptySet<'a>
val set4: NonEmptySet<int>
val singleton: x: 'a -> NonEmptySet<'a> (requires comparison)
<summary>Builds a non empty set with a single element.</summary>
val set4': NonEmptySet<int>
Multiple items
val int: value: 'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> =
int
val result: x: 'T -> 'Functor<'T> (requires member Return)
<summary>
Lifts a value into a Functor. Same as return in Computation Expressions.
</summary>
<category index="2">Applicative</category>
val set1234: NonEmptySet<int>
val union: set1: NonEmptySet<'a> -> set2: NonEmptySet<'a> -> NonEmptySet<'a> (requires comparison)
<summary>Computes the union of the two sets.</summary>
<param name="set1">The first input set.</param>
<param name="set2">The second input set.</param>
<returns>The union of <c>set1</c> and <c>set2</c>.</returns>
val set1234': Set<int>
val toSet: NonEmptySet<'a> -> Set<'a> (requires comparison)
<summary>Builds a set from the given non empty set.</summary>
val set12345: NonEmptySet<int>
val add: value: 'a -> source: NonEmptySet<'a> -> NonEmptySet<'a> (requires comparison)
<summary>Returns a new set with an element added to the set. No exception is raised if
the set already contains the given element.</summary>
<param name="value">The value to add.</param>
<param name="source">The input set.</param>
<returns>A new set containing <c>value</c>.</returns>
val set12345': NonEmptySet<int>
val unionMany: sets: NonEmptyList<NonEmptySet<'a>> -> NonEmptySet<'a> (requires comparison)
<summary>Computes the union of a non empty list of sets.</summary>
<param name="sets">The sequence of sets to union.</param>
<returns>The union of the input sets.</returns>
Multiple items
module NonEmptyList
from FSharpPlus.Data
<summary>
Basic operations on NonEmptyList
</summary>
--------------------
type NonEmptyList<'t> =
{
Head: 't
Tail: 't list
}
interface NonEmptySeq<'t>
interface IReadOnlyList<'t>
interface IReadOnlyCollection<'t>
interface IEnumerable
interface IEnumerable<'t>
static member (+) : NonEmptyList<'a1> * x: NonEmptyList<'a1> -> NonEmptyList<'a1>
static member (<*>) : f: NonEmptyList<('T -> 'U)> * x: NonEmptyList<'T> -> NonEmptyList<'U>
static member (<.>) : f: NonEmptyList<('T -> 'U)> * x: NonEmptyList<'T> -> NonEmptyList<'U>
static member (=>>) : s: NonEmptyList<'a1> * g: (NonEmptyList<'a1> -> 'b) -> NonEmptyList<'b>
static member (>>=) : NonEmptyList<'a1> * f: ('a1 -> NonEmptyList<'b>) -> NonEmptyList<'b>
...
<summary>
A type-safe list that contains at least one element.
</summary>
val create: x: 'a -> xs: 'a list -> NonEmptyList<'a>
<summary>Builds a non empty list.</summary>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val isSubset: set1: NonEmptySet<'a> -> set2: NonEmptySet<'a> -> bool (requires comparison)
<summary>Evaluates to "true" if all elements of the first set are in the second</summary>
<param name="set1">The potential subset.</param>
<param name="set2">The set to test against.</param>
<returns>True if <c>set1</c> is a subset of <c>set2</c>.</returns>