Skip to content

Instantly share code, notes, and snippets.

@mrange
mrange / README.md
Last active May 26, 2022 02:46
# F# Advent 2021 Dec 08 - Fast data pipelines with F#6

F# Advent 2021 Dec 08 - Fast data pipelines with F#6

Thanks to Sergey Tihon for running F# Weekly and F# Advent.

Thanks to manofstick for trying out the code and coming with invaluable feedback. Cistern.ValueLinq is very impressive.

TLDR; F#6 enables data pipelines with up to 15x less overhead than LINQ

There were many interesting improvements in F#6 but one in particular caught my eye, the attribute InlineIfLambda.

@mrange
mrange / README.md
Last active March 11, 2022 10:02
[F#/OCaml] Implementing a data streams library using a bunch of one-liners

[F#/OCaml] Implementing a data streams library using a bunch of one-liners

A few years ago when I read the presentation motivating the design behind Nessos Streams I was struck by the beauty of simplistic push streams.

type PushStream<'T> = ('T -> bool) -> bool

LINQ (in .NET) is a pull stream, ie we pull values out of the stream by calling MoveNext + Current. One of the problems with pull streams is the constant checking "Are we done?" at each level in the stream.

@mrange
mrange / on-tail-recursion.md
Last active March 15, 2022 04:57
On the topic of tail calls in .NET

On the topic of tail calls in .NET

Let's say you have implemented a small data pipeline library to replace LINQ.

module TrivialStream =
  type Receiver<'T> = 'T            -> unit
  type Stream<'T>   = Receiver<'T>  -> unit

  module Details =
@mrange
mrange / 0_FsTransducer2.fs
Last active May 22, 2018 07:39
Another take at Transducers
module FsTransducers =
type Context =
{
mutable Continue : bool
}
static member New () : Context = { Continue = true }
type Initializer = Context -> unit
type Folder<'S, 'T> = 'S -> 'T -> 'S
type Completer<'S> = Context -> 'S -> 'S
type [<Struct>] Reducer<'S, 'T> = R of (Initializer*Folder<'S, 'T>*Completer<'S>)
let rec distribute e = function
| [] -> [[e]]
| x::xs' as xs -> (e::xs)::[for xs in distribute e xs' -> x::xs]
let rec permute = function
| [] -> [[]]
| e::xs -> List.collect (distribute e) (permute xs)
let generatePermutations r (vs : _ []) =
let inline swap f t =
module AnyTransformer =
type [<AbstractClass>] BadCause () =
class
abstract Describe : string
override x.ToString () = x.Describe
end
type [<Sealed>] MessageBadCause (msg: string) =
class
inherit BadCause ()
@mrange
mrange / mandelbrot.md
Last active May 10, 2022 13:44
The Computer Language Benchmarks Game - Mandelbrot

The Computer Language Benchmarks Game - Mandelbrot

Source code: https://github.com/mrange/benchmarksgame/tree/master/src/mandelbrot

  1. Update 2017-06-25 - Decided I could do a bit better with F# so I added an improved F# program that uses the .NET SSE
  2. Update 2017-07-01 - Reduced the overhead of bitmap allocation saving 9ms for 16000x16000 bitmaps
  3. Update 2017-07-06 - Improved the fast F# program by removing overy redundancy

Recently I discovered The Computer Language Benchmarks Game which intrigued me, especially the mandelbrot version.

@jchandra74
jchandra74 / PowerShell Customization.md
Last active March 1, 2024 01:02
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@enricosada
enricosada / fsharp and .net core sdk status.md
Last active March 29, 2020 13:13
.NET Core sdk, msbuild, fsharp, fsc, etc

.NET Core sdk, msbuild, fsharp, fsc, etc

How to finish/polish the integration between msbuild based .net core sdk and f# (fsc, FscTask, etc)

This doc contains current issues i known and a proposed solution (already implemented in a PR, and works) on how to fix these (obv ihmo).

AFAIK all the solution i choose are based on where dotnet/sdk, microsoft/msbuild and dotnet/cli are going with development, and updated to latest release (preview4), and vnext in development now.

TL;DR

@mrange
mrange / fsharp_advent_2016_12_10.md
Last active December 14, 2019 21:44
F# Advent 2016 (English) - December 10 - Implementing a persistent hash map.