Skip to content

Fix extension docs #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/fsharp/language-reference/type-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ static member Method<T>(this T input, T other)
This approach is particularly useful when the generic type parameter is constrained. Further, you can now declare extension members like this in F# code and define an additional, semantically rich set of extension methods. In F#, you usually define extension members as the following example shows:

```fsharp
type seq<’T> with
open System.Collections.Generic

type IEnumerable<'T> with
/// Repeat each element of the sequence n times
member xs.RepeatElements(n: int) =
seq { for x in xs do for i in 1 .. n do yield x }
Expand All @@ -84,7 +86,7 @@ Consider the following declaration:
[<Extension>]
type ExtraCSharpStyleExtensionMethodsInFSharp () =
[<Extension>]
static member inline Sum(xs: seq<’T>) = Seq.sum xs
static member inline Sum(xs: IEnumerable<'T>) = Seq.sum xs
```

By using this declaration, you can write code that resembles the following sample.
Expand All @@ -102,4 +104,4 @@ In this code, the same generic arithmetic code is applied to lists of two types
## See Also
[F# Language Reference](index.md)

[Members](members/index.md)
[Members](members/index.md)