Reid Evans's blog articles

0
comment
on 7/31/2015 1:51 PM
When I started learning F# I had a hard time grokking how and when to use a Discriminated Union (Sum type). I had experience in several paradigms and languages, but had never seen or used this data construct. In this article we'll start with an Enum and then work our way into an example use case with a Discriminated Union enum HttpMethod { Get, Post } An Enum is basically a constrained type where an instance of the enum must be one of the specified values. For an instance to be of the type HttpM[...]
>> Read the full article
.
0
comment
on 7/17/2015 5:56 AM
In a previous post on F# data access I dropped a hint about a functional way of handling invalid arguments. The code in question looked like this. let insertLocation city state = if state |> String.length >= 2 then DataAccess.createLocation city state else raise (System.ArgumentException("Not a valid State")) If you're new to the functional paradigm you may not see any issue with this code. To explain why this isn't an ideal solution let's first look at a simpler function. let divide x[...]
>> Read the full article
.
0
comment
on 7/9/2015 2:09 PM
One of my biggest hurdles when starting with F# was how I should structure an actual application. There was documentation for individual libraries and scripts but not so much for app structure this post by Scott Wlaschin is fantastic, but is at a different level than I fully understood at that point in my F# journey. The goal of this post is to provide a bridge to help developers new to F#. Getting Started The first thing to do will be to create a new F# application. For this tutorial I'll use the F[...]
>> Read the full article
.
0
comment
on 6/30/2015 8:21 AM
I'm going about my business dealing with option types thinking I finally have a good handle on monad usage within F# when suddenly I receive the following error. This expression was expected to have type int but here has type 'a option My first thought is that I've neglected to use let! but looking at my code the error is in a completely unexpected place. type MaybeBuilder() = member this.Bind(m, f) = Option.bind f m member this.Return(x) = Some x let maybe = new MaybeBuilder() type So[...]
>> Read the full article
.
0
comment
on 4/23/2015 8:25 AM
In my previous post on getting into higher order functions I wrote about how I've been using higher order functions instead of foreach loops. All of the functions defined in that article were immutable, and had no side effects aside from returning data. In real life though, we're forced to deal with side effects all the time (logging, databases, DateTime.Now, etc). This separation was by design and is due to an old (in our industry anyway) principal known as Command Query Separation. Command Query Se[...]
>> Read the full article
.
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper