We are thrilled to announce the availability of Try WebSharper, a simple and fun way to create and share WebSharper snippets with others!
The code you share can be run (=>Run) right in your browser, and you get basic type checking with warnings and errors showing up as red/yellow squiggles. Currently, this takes a couple seconds to complete so it's not the most convenient way to experiment, but it will get a lot better soon.
We aim to keep this site current with upcoming WebSharper releases, so you can use it to experiment with even the newest WebSharper features, including reactive markup and templating via UI.Next.
Converting F# snippets to WebSharper
While Try WebSharper is intended primarily for sharing WebSharper snippets (e.g. F# snippets that produce web output), you can also convert simple F# snippets by following a few simple steps.
Say, you wanted to run the following:
1 2 3
open System sprintf "Time now is %s" (DateTime.Now.ToShortTimeString())
1 2 3 4 5 6 7 8
Note that you will always need to open
WebSharper for the
You may be tempted to throw away the name of the top-level binding, but this will yield no output due to
let _ = ... being interpreted as
Another thing you can do is to show it in the markup that is rendered from
index.html as your output. Note, that by default this document has a
div node with
id=main, which you can write to using the
AppendTo member on any
1 2 3 4 5 6 7 8 9
Here, you are opening
WebSharper.Html.Client for accessing client-side HTML functions like
1 2 3 4 5 6 7 8 9
So all in all, these should give you three different strategies to convert F# snippets into WebSharper ones.
Site features and plans
As a code snippets site, Try WebSharper has the usual toolset for snippets: you can create a new snippet by hitting the big red plus (+) button in the bottom right corner, fork an existing snippet (=>Fork), or save the one you are working on (=>Save).
We also added a basic set of examples (with more being moved from WebSharper examples), which you can find under the hamburger icon, along with any saved snippets you may have:
In future releases, we will be introducing additional functionality to help with "templating" basic snippets using any one of the above methods, spinning up snippets via GitHub gists, and lighting up much more refined code assistance services (code completion, type checking as you type, hover comments and signatures, etc.)