FSharpPlus


Other abstractions

Here are some other abstractions, not present in the diagram.

(see the examples)

Examples

#r @"../../src/FSharpPlus/bin/Release/netstandard2.0/FSharpPlus.dll"

open System
open FSharpPlus
open FSharpPlus.Data


// Indexable

let namesWithNdx = mapi (fun k v -> "(" + string k + ")" + v ) (Map.ofSeq ['f',"Fred";'p',"Paul"])
let namesAction = iteri (printfn "(%A)%s") (Map.ofSeq ['f',"Fred";'p',"Paul"])
let res119 = foldi (fun s i t -> t * s - i) 10 [3;4]
let res113 = foldi (fun s i t -> t * s - i) 2 [|3;4;5|]
let resSomeId20 = traversei (fun k t -> Some (10 + t)) (Tuple 10)


// Collection

let a = skip 3 [1..10]
let b = chunkBy fst [1, "a"; 1, "b"; 2, "c"; 1, "d"]


// Reducibles

let c = nelist {1; 2; 3}
let d = reduce (+) c

let resultList = nelist {Error "1"; Error "2"; Ok 3; Ok 4; Error "5"}
let firstOk = choice resultList


// Invariant Functor
type StringConverter<'t> = StringConverter of (string -> 't) * ('t -> string) with
    static member Invmap (StringConverter (f, g), f',g') = StringConverter (f' << f, g << g')

let ofString (StringConverter (f, _)) = f
let toString (StringConverter (_, f)) = f

let floatConv = StringConverter (float<string>, string<float>)

let floatParsed  = ofString floatConv "1.8"
let floatEncoded = toString floatConv 1.5

let intConv = invmap int<float> float<int> floatConv

let oneParsed  = ofString intConv "1"
let tenEncoded = toString intConv 10
namespace System
namespace FSharpPlus
namespace FSharpPlus.Data
val namesWithNdx: Map<char,string>
val mapi: mapping: ('K -> 'T -> 'U) -> source: 'FunctorWithIndex<'T> -> 'FunctorWithIndex<'U> (requires member MapIndexed)
<summary> Maps with access to the index. </summary>
<category index="16">Indexable</category>
val k: char
val v: string
Multiple items
val string: value: 'T -> string

--------------------
type string = String
Multiple items
module Map from FSharpPlus
<summary> Additional operations on Map&lt;'Key, 'Value&gt; </summary>

--------------------
module Map from Microsoft.FSharp.Collections

--------------------
type Map<'Key,'Value (requires comparison)> = interface IReadOnlyDictionary<'Key,'Value> interface IReadOnlyCollection<KeyValuePair<'Key,'Value>> interface IEnumerable interface IStructuralEquatable interface IComparable interface IEnumerable<KeyValuePair<'Key,'Value>> interface ICollection<KeyValuePair<'Key,'Value>> interface IDictionary<'Key,'Value> new: elements: ('Key * 'Value) seq -> Map<'Key,'Value> member Add: key: 'Key * value: 'Value -> Map<'Key,'Value> ...

--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val ofSeq: elements: ('Key * 'T) seq -> Map<'Key,'T> (requires comparison)
val namesAction: unit
val iteri: action: ('K -> 'T -> unit) -> source: 'FunctorWithIndex<'T> -> unit (requires member IterateIndexed)
<summary> Maps an action with access to an index. </summary>
<category index="16">Indexable</category>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val res119: int
val foldi: folder: ('State -> 'K -> 'T -> 'State) -> state: 'State -> source: 'FoldableWithIndex<'T> -> 'State (requires member FoldIndexed)
<summary> Left-associative fold of an indexed container with access to the index i. </summary>
<category index="16">Indexable</category>
val s: int
val i: int
val t: int
val res113: int
val resSomeId20: Tuple<int> option
val traversei: f: ('K -> 'T -> 'Applicative<'U>) -> t: 'Traversable<'T>> -> 'Applicative<'Traversable<'U>> (requires member TraverseIndexed)
<summary> Traverses an indexed container. Behaves exactly like a regular traverse except that the traversing function also has access to the key associated with a value. </summary>
<category index="16">Indexable</category>
val k: unit
union case Option.Some: Value: 'T -> Option<'T>
Multiple items
type Tuple = static member Create<'T1> : item1: 'T1 -> Tuple<'T1> + 7 overloads
<summary>Provides static methods for creating tuple objects.</summary>

--------------------
type Tuple<'T1> = interface IStructuralComparable interface IStructuralEquatable interface IComparable interface ITuple new: item1: 'T1 -> unit member Equals: obj: obj -> bool member GetHashCode: unit -> int member ToString: unit -> string member Item1: 'T1
<summary>Represents a 1-tuple, or singleton.</summary>
<typeparam name="T1">The type of the tuple's only component.</typeparam>


--------------------

--------------------

--------------------

--------------------

--------------------

--------------------

--------------------
type Tuple<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'TRest> = interface IStructuralComparable interface IStructuralEquatable interface IComparable interface ITuple new: item1: 'T1 * item2: 'T2 * item3: 'T3 * item4: 'T4 * item5: 'T5 * item6: 'T6 * item7: 'T7 * rest: 'TRest -> unit member Equals: obj: obj -> bool member GetHashCode: unit -> int member ToString: unit -> string member Item1: 'T1 member Item2: 'T2 ...
<summary>Represents an n-tuple, where n is 8 or greater.</summary>
<typeparam name="T1">The type of the tuple's first component.</typeparam>
<typeparam name="T2">The type of the tuple's second component.</typeparam>
<typeparam name="T3">The type of the tuple's third component.</typeparam>
<typeparam name="T4">The type of the tuple's fourth component.</typeparam>
<typeparam name="T5">The type of the tuple's fifth component.</typeparam>
<typeparam name="T6">The type of the tuple's sixth component.</typeparam>
<typeparam name="T7">The type of the tuple's seventh component.</typeparam>
<typeparam name="TRest">Any generic <see langword="Tuple" /> object that defines the types of the tuple's remaining components.</typeparam>


--------------------
Tuple(item1: 'T1) : Tuple<'T1>

--------------------
Tuple(item1: 'T1, item2: 'T2) : 'T1 * 'T2

--------------------
Tuple(item1: 'T1, item2: 'T2, item3: 'T3) : 'T1 * 'T2 * 'T3

--------------------
Tuple(item1: 'T1, item2: 'T2, item3: 'T3, item4: 'T4) : 'T1 * 'T2 * 'T3 * 'T4

--------------------
Tuple(item1: 'T1, item2: 'T2, item3: 'T3, item4: 'T4, item5: 'T5) : 'T1 * 'T2 * 'T3 * 'T4 * 'T5

--------------------
Tuple(item1: 'T1, item2: 'T2, item3: 'T3, item4: 'T4, item5: 'T5, item6: 'T6) : 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6

--------------------
Tuple(item1: 'T1, item2: 'T2, item3: 'T3, item4: 'T4, item5: 'T5, item6: 'T6, item7: 'T7) : 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7

--------------------
Tuple(item1: 'T1, item2: 'T2, item3: 'T3, item4: 'T4, item5: 'T5, item6: 'T6, item7: 'T7, rest: 'TRest) : Tuple<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'TRest>
val a: int list
val skip: count: int -> source: 'Collection<'T> -> 'Collection<'T> (requires member Skip)
<summary>Returns a collection that skips N elements of the original collection and then yields the remaining elements of the collection.</summary>
<category index="19">Collection</category>
<remarks>Throws <c>InvalidOperationException</c> when count exceeds the number of elements in the collection. <c>drop</c> returns an empty collection instead of throwing an exception.</remarks>
<param name="count">The number of items to skip.</param>
<param name="source">The input collection.</param>
<returns>The result collection.</returns>
<exception cref="System.ArgumentNullException">Thrown when the input collection is null.</exception>
<exception cref="System.InvalidOperationException">Thrown when count exceeds the number of elements in the collection.</exception>
val b: (int * (int * string) list) list
val chunkBy: projection: ('T -> 'Key) -> source: 'Collection<'T> -> 'Collection<'Key * 'Collection<'T>> (requires equality and member ChunkBy)
<summary>Applies a key-generating function to each element of a collection and yields a collection of keys tupled with values. Each key contains a collection of all adjacent elements that match to this key, therefore keys are not unique but they can't be adjacent as each time the key changes, a new group is yield.</summary>
<category index="19">Collection</category>
<remarks>The ordering of the original collection is respected.</remarks>
<param name="projection">A function that transforms an element of the collection into a comparable key.</param>
<param name="source">The input collection.</param>
<returns>The result collection.</returns>
val fst: tuple: ('T1 * 'T2) -> 'T1
val c: NonEmptyList<int>
Multiple items
val nelist: NelBuilder

--------------------
type nelist<'t> = NonEmptyList<'t>
<summary> A type alias for NonEmptyList&lt;'t&gt; </summary>
val d: int
val reduce: reduction: ('T -> 'T -> 'T) -> source: 'Reducible<'T> -> 'T (requires member Reduce)
<summary>Applies a function to each element of the reducible, threading an accumulator argument through the computation. Apply the function to the first two elements of the reducible. Then feed this result into the function along with the third element and so on. Return the final result. If the input function is <c>f</c> and the elements are <c>i0...iN</c> then computes <c>f (... (f i0 i1) i2 ...) iN</c>.</summary>
<category index="12">Reducible</category>
<param name="reduction">The function to reduce two reducible elements to a single element.</param>
<param name="source">The input reducible.</param>
<returns>The final reduced value.</returns>
val resultList: NonEmptyList<Result<int,string>>
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
val firstOk: Result<int,string>
val choice: x: 'Foldable<'Alternative<'T>> -> 'Alternative<'T>> (requires member Choice)
<summary> Reduces using alternative operator `&lt;|&gt;`. </summary>
<category index="23">Additional Functions</category>
't
Multiple items
union case StringConverter.StringConverter: (string -> 't) * ('t -> string) -> StringConverter<'t>

--------------------
type StringConverter<'t> = | StringConverter of (string -> 't) * ('t -> string) static member Invmap: StringConverter<'a> * f': ('a -> 'b) * g': ('b -> 'a) -> StringConverter<'b>
val f: (string -> 'a)
val g: ('a -> string)
val f': ('a -> 'b)
val g': ('b -> 'a)
val ofString: StringConverter<'a> -> (string -> 'a)
val toString: StringConverter<'a> -> ('a -> string)
val f: ('a -> string)
val floatConv: StringConverter<float>
Multiple items
val float: value: 'T -> float (requires member op_Explicit)

--------------------
type float = Double

--------------------
type float<'Measure> = float
val floatParsed: float
val floatEncoded: string
val intConv: StringConverter<int>
val invmap: f: ('T -> 'U) -> g: ('U -> 'T) -> source: 'InvariantFunctor<'T> -> 'InvariantFunctor<'U> (requires member Invmap)
<summary> Maps a pair of functions over an Invariant Functor </summary>
<category index="6">Contravariant/Bifunctor/Profunctor/Invariant</category>
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
val oneParsed: int
val tenEncoded: string