Skip to content

Instantly share code, notes, and snippets.

@jbeeko
jbeeko / mini-CL.fsx
Last active June 16, 2020 04:47
A mini command-line program using F# 5.0 scripting
#! /usr/bin/env dotnet fsi --exec --langversion:preview
#r "nuget: Argu"
#r "nuget: FParsec"
// #I needed because of https://github.com/dotnet/fsharp/issues/9217
// Should be fixed for final release
#I "/Users/joergbeekmann/.nuget/packages/fparsec/1.1.1/lib/netstandard2.0"
open Argu
open FParsec
@Szer
Szer / lazy.fs
Last active February 4, 2020 14:53
Lazy Builder
[<AutoOpen>]
module LazyBuilder =
let inline force(x: Lazy<_>) = x.Force()
type LazyCont<'a> = LazyCont of (unit -> Lazy<'a>)
type LazyBuilder() =
member __.Return x = lazy x
member __.ReturnFrom (x: Lazy<_>) = x
member __.Bind(Lazy x, f) = f x
member __.Delay f = LazyCont f
member __.Run (LazyCont f) = Lazy.Create (f >> force)
type IBuilderResult = interface end
type ICombinable = inherit IBuilderResult
type INonCombinable = inherit IBuilderResult
type First =
| Payload of int
| Nested of ICombinable
interface ICombinable
type Second =
| Payload of string