Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion _snippets/async_expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ code: |
return $"Validation error: {msg}"
}

processPersonAsync { Name = "Snowdrop"; Age = 13}
processPersonAsync { Name = "Snowdrop"; Age = 13 }
|> Async.RunSynchronously
---
## Async Programming made Easy
Expand Down
27 changes: 27 additions & 0 deletions _snippets/dotnet_ecosystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
order: 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this should be so high in the order

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the current order:

  • Concise like Python (HelloWorld.fs)
    • Concise syntax
    • Simple lists
    • String interpolation
    • Pipeline operator
  • Objects Made Simple (OOP.fs)
    • Seamless .NET integration
    • Rich interface system
    • Object expressions
    • Automatic property generation
    • Type extensions

If .NET was to be expanded on to show all the possibilities of the ecosystem, logically it would be placed in between Concise like Python and Objects Made Simple. It's originally the first bullet point of Objects Made Simple, after all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that perhaps everything related to interop should be placed next to the Fable sample though.

title: DotNet.fs
excerpt_separator: <!--more-->
code: |
// Example: Extracting information from text with regular expressions
open System.Text.RegularExpressions
let input = "Emails: user1@test.com, user2@domain.org, invalid-email"
let pattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b"
for matched in Regex.Matches(input, pattern) do
printfn $"Found email: {matched.Value}" // user1@test.com and user2@domain.org

// Example: Image processing
open SixLabors.ImageSharp // NuGet package: SixLabors.ImageSharp
open SixLabors.ImageSharp.Processing
use image = Image.Load "input.png"
image.Mutate(_.Resize(300, 200).Flip(FlipMode.Horizontal ||| FlipMode.Vertical) >> ignore)
image.Save "output.jpg"
---

## Full access to .NET ecosystem

F# has seamless .NET integration which lets you work with existing .NET libraries and frameworks. Anything written in C# can be used from F# and vice versa.
<!--more-->
- **[Web](https://dotnet.microsoft.com/en-us/apps/aspnet), [Mobile](https://dotnet.microsoft.com/en-us/apps/maui), [Desktop](https://dotnet.microsoft.com/en-us/apps/desktop), [Cloud](https://dotnet.microsoft.com/en-us/apps/cloud), [Microservices](https://dotnet.microsoft.com/en-us/apps/aspnet/microservices), [Artificial Intelligence](https://dotnet.microsoft.com/en-us/apps/ai), [Game Development](https://dotnet.microsoft.com/en-us/apps/games), and [Internet of Things](https://dotnet.microsoft.com/en-us/apps/iot)** frameworks are ready to be used.
- [**NuGet packages**](https://www.nuget.org), all hundreds of thousands of them, reduce your code complexity.
- **Mixing C# and F#** in the same solution is possible for incremental adoption.
2 changes: 1 addition & 1 deletion _snippets/fable.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ code: |
---
## F# for JavaScript and the Full Stack

F# is for both client and server. With [F# web technologies]({{ '/use/web-apps/' | relative_url }}), you can target JavaScript environments directly. This means you can use F# to build web applications, mobile apps, and even serverless functions that run in the cloud.
F# is for both client and server. With [F# web technologies]({{ '/use/web-apps/' | relative_url }}), you can target JavaScript environments directly without including the rest of .NET. This means you can use F# across both frontend and backend to build web applications, mobile apps, and even serverless functions that run in the cloud.
<!--more-->
- **Type-safe DOM manipulation** catches errors at compile time, not runtime
- **Seamless React integration** with hooks and modern patterns
Expand Down
1 change: 0 additions & 1 deletion _snippets/oop.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ code: |

F# is **functional first** and **immutable by default**, but it also provides pragmatic support for object programming.
<!--more-->
- **Seamless .NET integration** lets you work with existing .NET libraries and frameworks
- **Rich interface system** allows you to define clear contracts for your components
- **Object expressions** provide lightweight implementation of interfaces without defining full classes
- **Concise member syntax** keeps methods and properties clean and readable
Expand Down
8 changes: 5 additions & 3 deletions _snippets/sequence_expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ order: 15
title: SequenceExpressions.fs
excerpt_separator: <!--more-->
code: |
// This is an active pattern. It allows customized pattern matching.
Comment thread
Happypig375 marked this conversation as resolved.
Outdated
let (|Divides|_|) divisor x = x % divisor = 0
let rec fizzBuzzSeq n = seq {
match n with
| x when x % 15 = 0 -> "fizzbuzz"
| x when x % 3 = 0 -> "fizz"
| x when x % 5 = 0 -> "buzz"
| Divides 15 -> "fizzbuzz"
| Divides 3 -> "fizz"
| Divides 5 -> "buzz"
| _ -> n.ToString()

// Tail recursion makes this as efficient as a "while" loop
Expand Down
2 changes: 1 addition & 1 deletion _snippets/typeproviders.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ order: 14
title: TypeProviders.fs
excerpt_separator: <!--more-->
code: |
open FSharp.Data
open FSharp.Data // NuGet package: FSharp.Data

type PeopleDB = CsvProvider<"people.csv">

Expand Down