-
Notifications
You must be signed in to change notification settings - Fork 290
Include a snippet on the power of .NET #1005
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
63700bf
b7a7f78
e4455e2
1289bff
2a9b303
3529707
6055e4a
86a9d72
fe92e1e
3d4b3d9
0e802b1
1983596
a03163b
609813b
9783bbe
36ca9ff
9e5fd2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,12 @@ | |
return $"Validation error: {msg}" | ||
} | ||
|
||
processPersonAsync { Name = "Snowdrop"; Age = 13} | ||
processPersonAsync { Name = "Snowdrop"; Age = 13 } | ||
|> Async.RunSynchronously | ||
--- | ||
## Async Programming made Easy | ||
|
||
F# async expressions provide a powerful way to handle asynchronous programming, making it more readable and maintainable. They allow you to write non-blocking code that looks like synchronous code, which is particularly useful for I/O-bound operations. | ||
Check failure on line 28 in _snippets/async_expressions.md
|
||
<!--more--> | ||
- **Async expressions** provide a clean syntax for defining asynchronous workflows | ||
- **Integration with existing libraries** makes it easy to use async expressions with other F# features | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
order: 1 | ||
title: DotNet.fs | ||
excerpt_separator: <!--more--> | ||
code: | | ||
// Example: Extracting information from text with regular expressions | ||
open System.Text.RegularExpressions | ||
let input = "Emails: [email protected], [email protected], invalid-email" | ||
Check failure on line 8 in _snippets/dotnet_ecosystem.md
|
||
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}" // [email protected] and [email protected] | ||
Check failure on line 11 in _snippets/dotnet_ecosystem.md
|
||
|
||
// 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. | ||
Check failure on line 23 in _snippets/dotnet_ecosystem.md
|
||
<!--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. | ||
Check failure on line 25 in _snippets/dotnet_ecosystem.md
|
||
- [**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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,11 @@ | |
--- | ||
## 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. | ||
Check failure on line 35 in _snippets/fable.md
|
||
<!--more--> | ||
- **Type-safe DOM manipulation** catches errors at compile time, not runtime | ||
- **Seamless React integration** with hooks and modern patterns | ||
- **Full npm ecosystem access** with clean TypeScript-like interop | ||
- **Simplified async programming** with F#'s computation expressions for promises | ||
|
||
F# brings its powerful type system and immutability to frontend development, eliminating common JavaScript bugs while maintaining full access to the JavaScript ecosystem. | ||
Check failure on line 42 in _snippets/fable.md
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,8 @@ | |
--- | ||
## Objects Made Simple | ||
|
||
F# is **functional first** and **immutable by default**, but it also provides pragmatic support for object programming. | ||
Check failure on line 43 in _snippets/oop.md
|
||
<!--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 | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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.