Skip to content

Instantly share code, notes, and snippets.

jackfoxy / DecisionTables.fsx
Created Sep 18, 2020
A demo of decision tables using F# types and pattern matching
View DecisionTables.fsx
Decision Table Demo
MIT License, do with this what you will
A demo of decision tables using F# types and pattern matching, inspired by
The compiler service flags problematic (incomplete) decision tables.
View HtmlLinks.fsx
View MemoizedFibonacci.fsx
// Fibonacci
// not originally mine, can't remember where I got it
// State Monad combined with Continuation Monad (StateT Mondad transformer)
type StateContMonad<'s, 'a, 'r> =
StateContMonad of ('s -> ('s -> 'a -> 'r) -> 'r)
type StateContBuilder() =
member __.Return value =
StateContMonad (fun state k -> k state value)
View BadTab.fsx
//not tested as fsx, but insert into existing fs in a project and you should see error messages other than bad tab
//did not let me save gist with tabs
//so insert them yourself in some other editor in line 21
type Production =
Ident : int
Year: int
Month: int
OilProduced: float
WaterProduced: float
jackfoxy / FsharpConsoleApp.js
Created Jul 23, 2016
Visual Studio Macro learnings and questions
View FsharpConsoleApp.js
/// <reference path="C:\Users\Jack\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />
// Blog announcing new VS macro facility:
// Macros get saved to:
// <user>\AppData\Local\Microsoft\VisualStudio\14.0\Macros\Macros
// does not seem to be any way to change default folder. Roaming may also work, but I have not experimented with that.
// Tne open source project:
jackfoxy / gist:50ffcefb88f082c51bb1
Created Feb 29, 2016
SQLite cannot execute from F# FSI
View gist:50ffcefb88f082c51bb1
//Demo SQLite cannot run from FSI
//#load "load-references-debug.fsx"
#r "../../packages/Microsoft.Data.Sqlite.1.0.0-rc1-final/lib/net451/Microsoft.Data.Sqlite.dll"
open Microsoft.Data.Sqlite
let conn = new SqliteConnection(@"Data Source = :memory:")
jackfoxy / gist:6679238
Last active Dec 23, 2015
A sandbox for F# Type explorations
View gist:6679238
namespace TypeSystemSandbox
#load @"C:\FsEye\FsEye.fsx"
#I "C:\Packages"
open System
//constraints from "Constraints (F#)" MS F# Language Reference
jackfoxy / simpleForceReveal.fs
Created Nov 14, 2012
simplified forced door reveal for let's make a deal
View simpleForceReveal.fs
let forcedReveal doorWithPrize fstChoice =
match (doorWithPrize + fstChoice) with
|3 -> 3
|4 -> 2
|_ -> 1
jackfoxy / ForcedReveal.fs
Created Nov 13, 2012
forced door reveal for Monty Hall problem
View ForcedReveal.fs
let forcedReveal doorWithPrize fstChoice =
match doorWithPrize with
|1 -> if fstChoice = 2 then 3
else 2
|2 -> if fstChoice = 1 then 3
else 1
|_ -> if fstChoice = 1 then 2
else 1