Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Smith TIHan

View GitHub Profile
View fsharp5.x.md

WIP F# 5.x Proposal Main Theme - Struct, ByRef, and Span updates

Language

  • Implicit conversion to inref<_> on method calls
  • Static local functions via static let
  • Local functions can have a byref-like parameter type
  • Unmanaged constraint relaxation
  • Add implicit conversion of types to Span / ReadOnlySpan on method calls. - needs proposal
  • Function pointer (delegate pointer) support - needs proposal - needed to support native and C# interop - might require FSharp.Core additions
View lexer.fs
module Lexer =
open System.Threading
open FSharp.Compiler.UnicodeLexing
open FSharp.Compiler.Range
open FSharp.Compiler.Ast
open FSharp.Compiler.Text
open FSharp.Compiler.Features
open FSharp.Compiler.Parser
open FSharp.Compiler.Lexhelp
@TIHan
TIHan / process.fs
Created Nov 11, 2018
F# Process - Kill Child when Parent Dies
View process.fs
/// https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed
module WindowsHelpers =
open System.Runtime.InteropServices
open FSharp.NativeInterop
type JobObjectInfoType =
| AssociateCompletionPortInformation = 7
| BasicLimitInformation = 2
| BasicUIRestrictions = 4
| EndOfJobTimeInformation = 6
View gist:059002027f168c86b6d4739d9d05c45b
/Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/fsharp/fsc.exe -o:obj/Debug/AndroidFSharpSandbox.dll
-g
--debug:full
--noframework
--define:DEBUG
--define:__XAMARIN_ANDROID_v1_0__;__MOBILE__;__ANDROID__;__ANDROID_1__;__ANDROID_2__;__ANDROID_3__;__ANDROID_4__;__ANDROID_5__;__ANDROID_6__;__ANDROID_7__;__ANDROID_8__;__ANDROID_9__;__ANDROID_10__;__ANDROID_11__;__ANDROID_12__;__ANDROID_13__;__ANDROID_14__;__ANDROID_15__;__ANDROID_16__;__ANDROID_17__;__ANDROID_18__;__ANDROID_19__;__ANDROID_20__;__ANDROID_21__;__ANDROID_22__;__ANDROID_23__;__ANDROID_24__;__ANDROID_25__
--optimize-
--tailcalls-
-r:/Users/williamsmith/Projects/AndroidFSharpSandbox/packages/FSharp.Core.4.1.17/lib/netstandard1.6/FSharp.Core.dll
-r:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Java.Interop.dll
View gist:c55e2aed0d8fab45db9dd98319c0fcf5
Tool /Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/fsharp/fsc.exe execution started with arguments: -o:obj/Debug/AndroidFSharpSandbox.dll
-g
--debug:full
--noframework
--define:DEBUG
--define:__XAMARIN_ANDROID_v1_0__
--define:__MOBILE__
--define:__ANDROID__
--define:__ANDROID_1__
--define:__ANDROID_2__
View Benchmark.cs
class Benchmark
{
[Test]
public void RunTypes()
{
var cache = typeof(string).Assembly.GetTypes().ToDictionary(x => x, x => x.Name.Length);
var sum = 0;
var sw = Stopwatch.StartNew();
var n = 1000000;
for (var i = 0; i < n; i++)
View style.fs
namespace Styles
// Style 1; OCaml Style
module Basketball =
type T =
{
Weight: int
}
@TIHan
TIHan / fixedStruct.fs
Created Feb 12, 2014
An unfinished type provider to handle fixed length types; it's broken. Do not use; but here for reference.
View fixedStruct.fs
module FSharp.BitMatch.TypeProvider
open System
open System.IO
open System.Reflection
open System.Windows.Input
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Reflection
open Microsoft.FSharp.Quotations
View FParsec.Binary.fs
module FParsec.Binary
open System
open System.Text
open System.Text.RegularExpressions
open FParsec
[<RequireQualifiedAccess>]
module File =
let readAllString path =
View wadParser.fs
module WadParser
open System
open System.IO
open System.Text
open System.Text.RegularExpressions
open FParsec
[<AutoOpen>]
module FParsec =
You can’t perform that action at this time.