A Monadic Pratt Parser

Introduction I recently read Beautiful Code which contains articles from several well known programmers about the code they consider beautiful.  In Top Down Operator Precedence, Douglas Crockford discusses the Pratt Parser (named after Vaughan Pratt who wrote the paper on … Continue reading →

0

Functional stateful programming in F#

F# is a multi-paradigm language which lets you program in both a functional pure manner and a imperative mutational way.  With F#’s growing popularity many .NET programmers are trying out the language and are able to get started quickly because … Continue reading →

0

FastSharp 2.0

I just released a new version of my FastSharp program. Download it  or  View the source code This release contains some notable enhancements: Support for multiple languages C# Visual Basic F# Persistence of your current code language and snippet. This allows you to close FastSharp and start right back up from where you left off…

2

Regex based Lexer with F#

This lexer allows you to define your regular expression based rules in a very declarative way using F# computation expressions. open Lexer let definitions = lexerDefinitions { do! addNextlineDefinition “NEWLINE” @”(\n\r)|\n|\r” do! addIgnoreDefinition “WS” @”\s” do! addDefinition “LET” “let” do! addDefinition “ID” “(?i)[a-z][a-z0-9]*” do! addDefinition “FLOAT” @”[0-9]+\.[0-9]+” do! addDefinition “INT” “[0-9]+” do! addDefinition “OPERATOR” @”[+*=!/&|<>\^\-]+”…

2

Regex based Lexer with F#

This lexer allows you to define your regular expression based rules in a very declarative way using F# computation expressions. open Lexer let definitions = lexerDefinitions { do! addNextlineDefinition “NEWLINE” @”(\n\r)|\n|\r” do!… Continue reading →

0

A functional take on console program loop in F#

Often when learning a new technology I start with a simple console application in which the program is run in a loop it continues to prompt you for more input until you give some command like quit or exit or whatever you choose: Enter input: someInput someOutput Enter input: otherInput someoutPut Enter input: quit Thanks!…

1

Parameterized State Transformer Monad in F#?

I have have been playing around with F# and I decided to create a state monad.  This worked out really well since I was able to leverage the F# computation expressions.  I then decided to try to extend this and make it more general by creating a parameterized state transformer monad.  This is a state…

2

I started playing with F#…

I decided to do some Project Euler problems using F#.  So here is my first one, Problem # 31.  Nothing in this solution really shows off anything special about F# but you have to start somewhere 😉   1: #light 2:  3: let rec combos amt (denoms:int list) = 4: if amt = 0 then…

0