Skip to content

Instantly share code, notes, and snippets.

View Tarmil's full-sized avatar

Loïc Denuzière Tarmil

View GitHub Profile
module MergeSort
let sortBy cmp xs =
let rec sequences xs =
match xs with
| a :: b :: xs ->
if cmp a b > 0
then descending b [a] xs
else ascending b (fun ys -> a :: ys) xs
| xs -> [xs]
@Tarmil
Tarmil / Main.fs
Last active May 1, 2017 12:20 — forked from Youenn-Bouglouan/Main.fs
Websharper - issue with POST expecting a JSON body
// Issue decribed here: http://websharper.com/question/82758/post-endpoint-with-a-json-body-cannot-be-reached
namespace HelloWebSharper
open WebSharper.Html.Server
open WebSharper
open WebSharper.Sitelets
module Site =
@Tarmil
Tarmil / Setup.fsx
Created June 13, 2017 07:46
F# Web project on VS2017
(*
# Setup.fsx
Adds registry keys for proper F# Web project support.
**Problem**: pure-F# Web projects do not work well in Visual Studio by default,
in particular adding a new item to the project is not possible.
**Solution**: This will hopefully be addressed in future VS versions.
open WebSharper
open WebSharper.JavaScript
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Notation
[<JavaScript>]
module Client =
namespace Sample
open WebSharper
open WebSharper.JavaScript
open WebSharper.UI
open WebSharper.UI.Client
open WebSharper.UI.Html
open WebSharper.Highcharts
open WebSharper.JQuery
type User = { name: string; (* ... *) }
type UserId = int
type EndPoint<_> =
| [<EndPoint "GET /user/{id}">]
GetUser : id: UserId -> EndPoint<Json<User>>
| [<EndPoint "POST /user"; Json "userData">]
CreateUser : userData: User -> EndPoint<Json<UserId>>
@Tarmil
Tarmil / Directory.Build.targets
Last active November 20, 2019 13:38
Override NuGet/Paket package references with local projects
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Override NuGet (or Paket) references with a set of local projects.
Usage:
* Add this file at the root above all your projects, so that they all gain the capability to override a package.
* In a solution where you want to override a package, add a file Directory.Build.props like the following:
<?xml version="1.0" encoding="utf-8"?>
<Project>
namespace Avalonia.Media.TextFormatting.Unicode
open Avalonia.Utility
[<Struct; IsByRefLike>]
type CodepointEnumerator(text: ReadOnlySlice<char>) =
let mutable text = text
let mutable current = Codepoint.ReplacementCodepoint
namespace Avalonia.Media.TextFormatting.Unicode
open Avalonia.Utility
[<Struct; IsByRefLike>]
type CodepointEnumerator =
val mutable text : ReadOnlySlice<char>
val mutable current : Codepoint
open System.Text.Json
open System.Text.Json.Serialization
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
type MyRecord =
{
x: int
y: string
}