Skip to content

Instantly share code, notes, and snippets.

@panesofglass
panesofglass / Actor.fs
Created September 21, 2020 16:47 — forked from bent-rasmussen/Actor.fs
Experimental high performance actor implementation for F# using channel and task computation expression.
// NOTE: import this Nuget package: TaskBuilder.fs (written using 2.1.0)
//
// Tested in LINQPad (hence Dump method usage).
open System
open System.Collections
open System.Collections.Generic
open System.Diagnostics
open System.Linq
open System.Threading
@panesofglass
panesofglass / python.fsx
Created April 26, 2020 13:55 — forked from nasser/python.fsx
Python from F#
// make sure codegen.py (https://github.com/CensoredUsername/codegen/blob/master/codegen.py) is in the same folder
// and you've added the IronPython package
open System.IO
open IronPython.Hosting
open IronPython.Runtime
open Microsoft.FSharp.Reflection
let engine = Python.CreateEngine()
@panesofglass
panesofglass / mixed-applicative-mondaic-result-ce.fsx
Created March 19, 2020 21:19 — forked from cartermp/mixed-applicative-mondaic-result-ce.fsx
Shows mixing of monadic and applicative CEs with a result builder
type ResultBuilder() =
member _.MergeSources(t1: Result<'T,'U>, t2: Result<'T1,'U>) = Result.zip t1 t2
member _.BindReturn(x: Result<'T,'U>, f) = Result.map f x
member _.Return (value: 'T) : Result<'T, 'TError> = Ok value
member _.ReturnFrom (result: Result<'T, 'TError>) : Result<'T, 'TError> = result
member this.Zero () : Result<unit, 'TError> = this.Return ()
@panesofglass
panesofglass / Thermometer.ts
Created February 5, 2020 16:18 — forked from spatney/Thermometer.ts
Custom Visual for Power BI: Thermometer
module powerbi.visuals {
export interface ViewModel {
value: number;
color?: string;
min?: number;
max?: number;
}
export class Thermometer implements IVisual {
public static capabilities: VisualCapabilities = {
@panesofglass
panesofglass / Fiber.fs
Created December 8, 2019 02:53 — forked from Horusiath/Fiber.fs
Custom fibers implementation in F#
open System
open System.Threading
type FiberResult<'a> = Result<'a, exn> option
[<Sealed;AllowNullLiteral>]
type Cancel(parent: Cancel) =
let mutable flag: int = 0
let mutable children: Cancel list = []
new() = Cancel(null)
@panesofglass
panesofglass / README.md
Created June 18, 2018 21:46 — forked from shawnbot/README.md
d3 voronoi interpolation!
@panesofglass
panesofglass / free.fs
Created April 3, 2018 22:06 — forked from johnazariah/free.fs
Free Monad with Trampoline Infrastructure and Computation Builder
// F<'a> is any type with member 'map' of type ('a -> 'b) -> F<'a> -> F<'b>
type F<'a> = QIL<'a>
and S<'a> = F<Q<'a>>
and Q<'a> =
private
| Step of Step<'a>
| Bind of IBind<'a>
with
static member lift (k : F<'a>) : Q<'a> = Step (Suspend (fun () -> S<_>.map (Yield >> Step) k))
namespace WebSocket
// Appache 2.0 license
// References:
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py
// [4] WebSockets Organising body http://www.websocket.org/echo.html
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664
@panesofglass
panesofglass / 01_folds.fs
Created January 12, 2016 04:12 — forked from cloudRoutine/01_folds.fs
F# Transducers - they work for the most part
open System.Collections.Generic
open Microsoft.FSharp.Collections
[<RequireQualifiedAccess>]
module Folds =
// These are the fast implementations we actually want to use
namespace WebSocket
// Appache 2.0 license
// References:
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py
// [4] WebSockets Organising body http://www.websocket.org/echo.html
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664