Skip to content

Instantly share code, notes, and snippets.

Lincoln Atkinson latkin

Block or report user

Report or block latkin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@latkin
latkin / extendAPIWithUnits.md
Last active Mar 31, 2016
How to extend a 3rd-party API with F# units of measure
View extendAPIWithUnits.md

Extending a 3rd-party API with F# units of measure

F# units of measure are nice, but what if I'm using a 3rd-party library which doesn't support UOM? I don't want to re-implement the library, but it would be nice to add the extra safety afforded by UOM. Can I somehow annotate the APIs of the 3rd party library with units?

Yes!

How to do it

Say you have some unit-free external library like this, which you can't modify:

@latkin
latkin / README.md
Last active Aug 29, 2015
Extended 'for' loops for F#
View README.md

Backing code and examples for two different mini-frameworks adding extended imperative-style for loops in F#.

Discussed in blog post here.

@latkin
latkin / readme.md
Last active Aug 29, 2015
Blog: Non-transitive dice
@latkin
latkin / speclet_scriptdebug.md
Last active Oct 25, 2015
F# Script Debugging Speclet
View speclet_scriptdebug.md

#F# Script Debugging

Adds supprt the to Visual F# tooling for rich debugging of F# scripts.

##Motivation F# developers love the low-overhead, iterative REPL experience they have today, but when scripts become larger and more complex, they become difficult to debug. There is no interaction whatsoever today between Editor + F# Interactive and the VS Ddbugger. Thus to debug complex scripts, devs must resort to one of:

  • printf debugging
  • Create a console app, paste in script code, F5-debug the console app
@latkin
latkin / test.fsx
Created Apr 22, 2015
Try block perf overhead
View test.fsx
#time ;;
let testNoTry () =
let mutable x = 0
for i in 1 .. 1000000000 do
x <- x + 1
x
let testTry () =
let mutable x = 0
@latkin
latkin / code.fsx
Last active Aug 29, 2015
Benchmark of groupBy perf
View code.fsx
open System.Collections.Generic
open System.Diagnostics
let groupBy keyMaker elements =
elements |> Seq.groupBy keyMaker |> Seq.length
let loopGroup keyMaker elements =
let d = Dictionary<string, seq<'a>>()
for p in elements do
let key = keyMaker p
@latkin
latkin / ops.fsx
Created Apr 30, 2015
Scoping nonstructural operators
View ops.fsx
[<AutoOpen>]
module Ops =
open NonStructuralComparison
let inline nsHash x = hash x
let inline nsCompare x = compare x
let inline (=&) a b = a = b
let inline (<>&) a b = a <> b
let inline (<&) a b = a < b
let inline (>&) a b = a > b
let inline (<=&) a b = a <= b
@latkin
latkin / code.fsx
Last active Aug 29, 2015
Seq.cache repro
View code.fsx
open System.Collections.Generic
let someDataSource = seq{ 1 .. 100 }
let ordersForTask = Dictionary<int, seq<int>>()
let getOrdersForTask task =
match ordersForTask.TryGetValue task with
| true, orders -> orders
| false, _ ->
let orders =
View code.fsx
open System
open System.Collections
open System.Collections.Generic
open System.Diagnostics
open System.Linq
module Algos =
//
// non-lazy solutions
//
@latkin
latkin / readme.md
Last active Aug 29, 2015
Blog: A handy Powershell filter for converting plain text to objects
You can’t perform that action at this time.