Table of contents
Collapse the table of content
Expand the table of content<'T,'U,'Del> Function (F#)

Den Delimarsky|Last Updated: 8/18/2017
1 Contributor

Returns a new event that passes values transformed by the given function.

Namespace/Module Path: Microsoft.FSharp.Control.Event

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


// Signature: : ('T -> 'U) -> IEvent<'Del,'T> -> IEvent<'U> (requires delegate)

// Usage: mapping sourceEvent


mapping Type: 'T -> 'U

The function to transform event values.

sourceEvent Type: IEvent<'Del,'T>

The input event.

Return Value

An event that passes the transformed values.


This function is named Map in the compiled assembly. If you are accessing the function from a language other than F#, or through reflection, use this name.


In this example, the event handler arguments are transformed into a more convenient format.

let form = new Form(Text = "F# Windows Form",
                    Visible = true,
                    TopMost = true)
    |> (fun evArgs -> (evArgs.X, evArgs.Y))
    |> Event.add ( fun (x, y) ->
        form.BackColor <- System.Drawing.Color.FromArgb(
            x, y, x ^^^ y) )


Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library VersionsF# Core Library Versions

Supported in: 2.0, 4.0, Portable2.0, 4.0, Portable, Portable

See Also

Control.Event Module (F#)

Microsoft.FSharp.Control Namespace (F#)

© 2020 Microsoft