Skip to content

Instantly share code, notes, and snippets.

// ==============================
// This gist is in response to
// http://programmers.stackexchange.com/questions/228939/how-to-improve-upon-blochs-builder-pattern-to-make-it-more-appropriate-for-use
//
// This is a simple bit of code to do the same thing using the Either monad (e.g. success/failure) and applicatives
// This code is (a) more generic (b) much shorter (c) more type safe
//
// Compare with the Java code at https://gist.github.com/swlaschin/9009343
// ==============================
// ==============================
// This gist contains the code from
// http://programmers.stackexchange.com/questions/228939/how-to-improve-upon-blochs-builder-pattern-to-make-it-more-appropriate-for-use
//
// Compare with the functional version at https://gist.github.com/swlaschin/9008814
// ==============================
// ==========================================
// UserConfig.java
//===================================
// Example of using DataTables in F#
//===================================
open System
open System.Data
//===================================
// General DataTable helpers
//
@swlaschin
swlaschin / 1-ConciseDDD.fsx
Created March 24, 2015 21:57
Code from O'Reilly webcast: "Domain Modelling with the F# Type System" http://www.oreilly.com/pub/e/3340
// ================================================
// DDD : Model a card game
// ================================================
(*
A card is a combination of a Suit (Heart, Spade) and a Rank (Two, Three, ... King, Ace)
A hand is a list of cards
A deck is a list of cards
A player has a name and a hand
A game consists of a deck and list of players
@swlaschin
swlaschin / AdditionPropertyCheck.fsx
Created July 4, 2015 07:46
Demonstration of using FsCheck to test "add" implementations
// =================================
// Demonstration of using FsCheck to
// test "add" implementations
//
// This is a more thorough version of the example
// in the talk at fsharpforfunandprofit.com/pbt
// =================================
System.IO.Directory.SetCurrentDirectory __SOURCE_DIRECTORY__
@swlaschin
swlaschin / typesafe-performance-with-compiler-directives-1.fsx
Created July 21, 2015 23:13
Demonstrates some techniques for performance improvements while remaining type-safe. Related blog post: http://fsharpforfunandprofit.com/posts/typesafe-performance-with-compiler-directives/
(*
typesafe-performance-with-compiler-directives-1.fsx
Demonstrates some techniques for performance improvements while remaining type-safe.
Related blog post: http://fsharpforfunandprofit.com/posts/typesafe-performance-with-compiler-directives/
See also the others in this series: "typesafe-performance-with-compiler-directives-XXX".fsx
*)
(*
RecursiveTypesAndFold-2b.fsx
Related blog post: http://fsharpforfunandprofit.com/posts/recursive-types-and-folds-2b/
*)
// ==============================================
// PART 2b - Understanding Folds
// ==============================================
(*
RecursiveTypesAndFold-3.fsx
Related blog post: http://fsharpforfunandprofit.com/posts/recursive-types-and-folds-3/
*)
// ==============================================
// PART 3 - Generic recursive types
// ==============================================
(*
RecursiveTypesAndFold-3b-tree.fsx
Related blog post: http://fsharpforfunandprofit.com/posts/recursive-types-and-folds-3b/
*)
// ==============================================
// PART 3b - Generic tree type
// ==============================================
(*
RecursiveTypesAndFold-3b-listing.fsx
Example: Creating a listing from a file system
Related blog post: http://fsharpforfunandprofit.com/posts/recursive-types-and-folds-3b/
*)
// ==============================================
// PART 3b - File System Listing