Operators.( >> )<'T1,'T2,'T3> Function (F#)

Composes two functions, the function on the left being applied first

Namespace/Module Path: Microsoft.FSharp.Core.Operators

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
( >> ) : ('T1 -> 'T2) -> ('T2 -> 'T3) -> 'T1 -> 'T3

// Usage:
func1 >> func2

Parameters

  • func1
    Type: 'T1 -> 'T2

    The first function to apply.

  • func2
    Type: 'T2 -> 'T3

    The second function to apply.

Return Value

The composition of the input functions.

Example

The following example demonstrates the use of the composition operator (>>).

let append1 string1 = string1 + ".append1"
let append2 string1 = string1 + ".append2"

// Composition of two functions.
let appendBoth = append1 >> append2
printfn "%s" (appendBoth "abc")

// Composition of three functions.
let append3 string1 = string1 + ".append3"
printfn "%s" ((append1 >> append2 >> append3) "abc")

// Composition of functions with more than one parameter.
let appendString (string1:string) (string2:string) = string1 + string2

let appendFileExtension extension =
    appendString "." >> appendString extension
printfn "%s" (appendFileExtension "myfile" "txt")
abc.append1.append2
abc.append1.append2.append3
myfile.txt

Platforms

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Core.Operators Module (F#)

Microsoft.FSharp.Core Namespace (F#)