Skip to content

Instantly share code, notes, and snippets.

@nojaf
nojaf / CE.fs
Created January 12, 2024 13:08
module CE
type DummyBuilder() =
member this.Zero() = List.empty
member this.Delay(f) = f ()
member this.Yield(x: int) = List.singleton (x + 1)
member this.YieldFrom(x: int list) = x
member this.Combine(a, b) = a @ b
let dummy = DummyBuilder()
@nojaf
nojaf / notes.md
Created September 21, 2022 14:39
The benefit of signature files in FCS FSharpChecker
[<Test>]
let ``compile FSharp.Core`` () =
let args = [|
@"-o:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSharp.Core.dll"
"-g"
"--debug:embedded"
@"--embed:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSCore.fs"
@"--embed:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\buildproperties.fs"
@"--embed:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSharp.Core.AssemblyInfo.fs"
@"--sourcelink:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSharp.Core.sourcelink.json"
@nojaf
nojaf / style.fsx
Created June 2, 2022 16:32
Compiling a Sass file using an F# script
#r "nuget: JavaScriptEngineSwitcher.ChakraCore.Native.win-x64"
#r "nuget: JavaScriptEngineSwitcher.ChakraCore, 3.18.2"
#r "nuget: DartSassHost, 1.0.0-preview7"
#r "nuget: FSharp.Control.Reactive, 5.0.5"
open System
open System.IO
open DartSassHost
open DartSassHost.Helpers
open JavaScriptEngineSwitcher.ChakraCore
// #Regression #NoMono #NoMT #CodeGen #EmittedIL
// Regression test for FSharp1.0:6389 - Nullary union cases improperly constrain generic type parameters
type Weirdo = | C
let f C = 0 // parameter name is C
let g () =
let C = 1
let f C = C // what is parameter name here? Do we even care?
()
module Hookrouter
open Fable.Core
open Fable.Core.JsInterop
open Fable.React
open Fable.React.Props
open System.Text.RegularExpressions
type InterceptedPath =
string option
@nojaf
nojaf / GraphQL.fs
Created July 15, 2019 12:29
Boilerplate for GraphQL F# implementation.
module GraphQL.Web
open Microsoft.AspNetCore.Http
open System.IO
open Ronnies.Server.Schema
open Microsoft.AspNetCore.Authentication.JwtBearer
open Microsoft.AspNetCore.Authentication
open FSharp.Data.GraphQL.Execution
open Newtonsoft.Json
open Newtonsoft.Json.Linq
@nojaf
nojaf / App_1.fsx
Last active June 19, 2019 17:27
Fable Hello world in 2019
#load ".paket/load/main.group.fsx"
printfn "Fable compiled this"
@nojaf
nojaf / console.js
Created March 1, 2018 21:39
Temptation Island
var vs = document.querySelectorAll("video"); for(let i = 0;i< vs.length;i++){ vs.item(i).playbackRate = 1.4; }
@nojaf
nojaf / main.fs
Created February 20, 2018 10:40
F# Cheatsheet
// Alias tuple
type XmlAddition =
| XmlElementAddition of parent: XPath * childNodeIndex:int * element: XElement
| XmlTextAddition of parent:XPath * textContent: string
| XmlAttributeAddition of node:XPath * attributeName:string * attributeValue:string