GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • License (Apache 2.0)
  • Release Notes
  • Source Repository
  • Tutorial
  • Extensions
  • Functions & Operators
  • Data Types
  • Abstractions
  • Computation Expressions
  • Lens
  • Parsing
  • Numerics
  • All Namespaces

This view

  • Original page
  • New address

GeezerVison is showing fsprojects.github.io — FSharpPlus

FSharpPlus


FSharpPlus

F#+ is a base library that aims to take F# to the next level of functional programming.

What if we imagine F# as more than it is?

F#+ builds upon FSharp, using generic programming techniques to help you avoid boiler plate code. However, by naming conventions and signatures it can be seen to 'enhance' rather than 'replace' existing patterns as much as possible.

The additions can be summarised as:

  • Extensions to core types, such as String.toLower

  • Generic Functions and Operators like map, which can be extended to support other types

  • Generic and customizable Computation Expressions, like monad

  • A generic Math Module

  • Abstractions that capture common FP patterns, such as the standard monads Cont, Reader, Writer, State and their Monad Transformers

  • Some new types that work well with the abstractions, such as NonEmptyList, DList and Validation

  • A polymorphic Lenses/Optics to easily read and update parts of immutable data

  • Generic methods that help you with parsing

Note, however, that F#+ does not go into solving a specific thing for a specific technology, such as JSON parsing.

Some functions are available as extension methods so are callable from C#. Note that this is not complete, or currently considered high priority.

Getting started is easy since you can start with enjoying some of the extensions and generic functions, but you will find other parts of F#+ unfold before you and become useful the deeper in you get.

Example 1

This example demonstrates using an extension function defined in this library.

#r @"nuget: FSharpPlus"
open FSharpPlus

let x = String.replace "old" "new" "Good old days"
// val x : string = "Good new days"

Example 2

This example demonstrates using a generic function defined in this library.

map string [|2;3;4;5|]
// val it : string [] = [|"2"; "3"; "4"; "5"|]

map ((+) 9) (Some 3)
// val it : int option = Some 12

open FSharpPlus.Data

map string (NonEmptyList.create 2 [3;4;5])
// val it : NonEmptyList<string> = {Head = "2"; Tail = ["3"; "4"; "5"];}

For a more hands on run through F#+ we recommend following the tutorial:

  • Tutorial contains a further explanation of this library.

Reference Documentation

  • Types contains detailed information about all the types provided in this library.

  • API Reference contains automatically generated documentation for all types, modules and functions in the library. This includes additional brief samples on using most of the functions.

Samples

This documentation is automatically generated from *.fsx files in the content folder. It can be useful to clone a local copy to review.

The API reference is automatically generated from Markdown comments in the library implementation.

Also of note is the Sample folder which contains sample scripts showing how to use F#+ in your code.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.

If you're adding a new public API, please also consider adding documentation. You might also want to read the library design notes to understand how it works.

The library is available under Apache License, Version 2.0, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.

namespace FSharpPlus
val x: string
Multiple items
module String from FSharpPlus
<summary> Additional operations on String </summary>

--------------------
module String from Microsoft.FSharp.Core
val replace: oldValue: string -> newValue: string -> source: string -> string
<summary> Replaces a substring with the given replacement string. </summary>
val map: f: ('T -> 'U) -> x: 'Functor<'T> -> 'Functor<'U> (requires member Map)
<summary>Lifts a function into a Functor.</summary>
<category index="1">Functor</category>
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
union case Option.Some: Value: 'T -> Option<'T>
namespace FSharpPlus.Data
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>
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.