Brian Berns

Brian Berns @shimmer

About: Functional programming enthusiast focused on F# .NET applications. #fsharp

Location:
US
Joined:
Dec 11, 2019

Brian Berns
articles - 28 total

The reverse state monad in F#

State monad recap We've seen previously that the state monad can be used to create...

Learn More 13 0Apr 3 '22

Applicatives in F#

Background Previously, we learned about applicative functors, which are souped-up functors...

Learn More 8 0May 13 '21

How to avoid the Visitor pattern in C#

Arithmetic expressions Let's say we want to represent a simple arithmetic expression in C#...

Learn More 24 5May 29 '20

Why algebraic effects matter in F#

Side effects Side effects are impossible to avoid in imperative code, but they can make re...

Learn More 16 5May 15 '20

The state monad in F#

This is a primer on implementing stateful computations in F# without violating functional purity....

Learn More 24 0May 3 '20

Monads for free in F#

If you dabble in Haskell or category theory, you might have heard of "free monads". But what exactly...

Learn More 39 5May 1 '20

Existential types in C# - Part 3

Recap In a previous article, we saw how to emulate first-class polymorphism by encapsulati...

Learn More 11 0Mar 19 '20

Existentially quantified types in C# - Part 2

As we discussed last time, an existentially quantified type is one that contains a hidden implementat...

Learn More 17 2Mar 16 '20

Existentially quantified types in C#

Emulating first-class polymorphism Last time, we talked about universally quantified types...

Learn More 28 2Mar 15 '20

Universally quantified types in C#

Generic types Generic types in C# are universally quantified. That means, for example, tha...

Learn More 9 13Mar 14 '20

Avoiding mutable classes in C#

GeoPoint Consider a class that represents a point on the surface of the earth, with the fo...

Learn More 32 1Feb 17 '20

How to avoid the Factory pattern in C#

Domain model classes Object-orientation is great when classes represent actual domain mode...

Learn More 81 20Feb 10 '20

Functional programming in C#

Functional programming relies on pure functions, which have no side-effects and always return the sam...

Learn More 56 1Feb 4 '20

Continuation passing style in C#

Last time, we investigated double negation in the Curry-Howard correspondence. We found that we can c...

Learn More 9 0Jan 28 '20

Double negation in C#

Let's take a look at another interesting aspect of the Curry-Howard correspondence using C#....

Learn More 17 8Jan 26 '20

Beautiful folds in F# - Part 3: Applicatives

Improved syntax The composableCombiner function that we ended up with last time works fine...

Learn More 9 2Jan 22 '20

Beautiful folds in F# - Part 2

When we left off, we had created a mechanism for applying multiple arbitrary functions to a sequence...

Learn More 6 0Jan 20 '20

Beautiful folds in F# - Part 1

Sequences F# sequences have some interesting behavior. Because they are "lazy", the elemen...

Learn More 15 0Jan 17 '20

Functors in F#

Functors are a popular topic in the functional programming world1, but some of what's been written is...

Learn More 10 4Jan 15 '20

The Curry-Howard Correspondence in C#: Part 2

This is a follow-up to my first article on the Curry-Howard correspondence. As before, all examples w...

Learn More 5 8Jan 10 '20

F# Tip 4: When (not) to use point-free style

Inspired by a blog post by Eirik Tsarpalis. Let's write a small F# function that safely takes the sq...

Learn More 8 1Jan 6 '20

Power series, power serious in F#

A power series is characterized by an infinite list of coefficients of powers of a variable, x: a₀...

Learn More 6 0Jan 4 '20

F# Tip 3: Recursive sequence expressions

F# sequence expressions are a great way to generate data in a loop. A simple sequence expression like...

Learn More 6 0Jan 2 '20

The Curry-Howard Correspondence in C#

It sounds crazy, but every time you instantiate a type in C#, you are proving a logical proposition....

Learn More 12 6Dec 31 '19

F# Tip 2: Use the pipe operator

F#'s pipe operator |> lets you chain function calls together easily: let car = Car.create Re...

Learn More 11 3Dec 29 '19

F# Tip 1: Don't use classes

If you're coming to F# from an object-oriented language like C#, you might be tempted to continue enc...

Learn More 11 2Dec 29 '19

Contravariants

Normal functors in Haskell are pretty easy to understand: class Functor f where fmap :: (a ->...

Learn More 7 0Dec 18 '19

Profunctors

I'm an F# developer reading a book called A Type of Programming, which is about Haskell and type theo...

Learn More 6 0Dec 17 '19