Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [f#]

F# is a succinct, expressive, and efficient functional and object-oriented language for .NET

10
votes
0answers
141 views

Encoding the problem domain of products and prices into the typesystem in F#

I'm trying to design a model for purchasing amounts of products in F#, following the ideas for designing for correctness (source). The idea is to use the type system to capture the different legal ...
7
votes
0answers
86 views

Agent-based Immutable Map

I am in the process of removing the last few pieces of mutable state from an F#-based distributed system. Some of the remaining mutable state is a ...
5
votes
0answers
274 views

Backtracking solver for n queens problem and knight's tour

Playing with https://ocaml.org/learn/tutorials/99problems.html#Miscellaneous-Problems I wrote a backtracking solver for the n queens problem, then the knight's tour, and realised I could generalise ...
5
votes
0answers
275 views

A* Algorithm in F#

Inspired by this post I looked up A* on wikipedia and went on with my own implementation as seen below where I try to mimic the pseudocode on Wikipedia but in a recursive manner. I would like any ...
4
votes
0answers
56 views

Hierarchy (Family Tree) Domain Model

I'm wanting to model a family tree in the F# type system. The basic requirements: A family tree is made up of family members A ...
4
votes
0answers
240 views

Aggregation of values over a hierarchy

I have a number of objects of a type Workplace that exist in a hierarchy that is given by some properties (Department, ...
4
votes
0answers
323 views

F# and Rx code that throttles; can it be done without ref cells (and possibly with active patterns)?

I'm basically redoing a piece of reactive C# code posted in SO code in F#, please, see below. The translation is fairly literal, I've just written the infinite loop as a recursive function and ...
3
votes
0answers
91 views

Creation of matrix with specific attempts at the end

What I want to do is build a Slay-the-Spire-like Map. As you can see in the following image, the map is splitted in ISteps and ...
3
votes
0answers
84 views

Lock-free Immutable ConcurrentQueue

Similar to the code review I posted last week for an agent-based immutable replacement for ConcurrentDictionary, I have also created an agent-based immutable ...
3
votes
0answers
99 views

Queue-based fixed-duration memory cache

I used to use the MemoryCache in .Net but recently read about a DB using using a linked-list, which only had to check the prefix of the list in \$O(1)\$ complexity, to time values out, as opposed to ...
3
votes
0answers
52 views

Work environment simulator

This code attempts to solve a suggested challenge by myself a while back on meta, transcribed here for simplicity. Allocate resources efficiently on a work environment The company Code42Review ...
3
votes
0answers
121 views

F# Observable.subscribeWeakly implementation

In this SO question I needed an observable subscription function that can be used kind of like Observable.subscribe, but that does not keep a strong reference to ...
3
votes
0answers
102 views

Concurrency using immutability

I was watching the following video about software transactional memory(using a package that maintains an access log). At the moment I am trying to learn about concurrency with shared memory and ...
3
votes
0answers
93 views

F# implementation of the A* algorithm round 2

This is my second attempt at implementing the A* algorithm using F#, the first one is here. What I changed: I removed the Node class and added two records named ...
3
votes
0answers
58 views

SqlDataConnection update method

I'm using Microsoft's SqlDataConnection type provider. However, the only way I've seen to update a row in the database is to use something similar to this where it updates mutable values: ...
3
votes
0answers
149 views

DSL design for iOS Autolayout

I am building a small DSL for iOS' autolayout feature. Obviously I want to have a typesafe way to define autolayouts instead of doing VSL. I came up with the following: ...
3
votes
0answers
55 views

Retrieve records from the database based on a possible id

This code will retrieve all records from the database if the id is null or return records by the available id. Is there a way to combine the query instead of having two separate queries? ...
3
votes
0answers
61 views

Check the database for an order number

This code will check the database for an order number. If none exist it creates one. If one does exist then it will increment it by one and update the database. Is this the most efficient way to ...
2
votes
0answers
35 views

Creating idiomatic and efficient method to stream large JSON file

The purpose of the code is to efficiently stream JSON items from a large file. I am wondering if this is efficient and decently idiomatic. Not sure how I could eliminate the while loop either. ...
2
votes
0answers
80 views

Lexer function to handle the '/' character

I'm writing a toy compiler, which is in a very early stage of development. The lexer contains the following block of code: ...
2
votes
0answers
51 views

Business Rule DSL for Values in Domain-Driven Design

Following the patterns from the book Domain Modeling Made Functional, I am implementing a single-case union for the simple values in my domain model instead of using primitives. The union cases have ...
2
votes
0answers
83 views

Blocking Memory Queue

This is a FIFO blocking memory queue in F# to be used as a component in a logging library. ...
2
votes
0answers
135 views

AES256 + HMACSHA256 'secretbox'

I aim to create a few primitives for creating AES256-then-HMACSHA256 secured session state through cookies. What I've considered: HMAC instead of plain sha to avoid hash extension attacks input ...
2
votes
0answers
316 views

Polling, parsing, validating and handling data cleanly and efficiently

<edit: There's a major problem in the code. It is basically the one in the comment regarding backpressure. I'll rework the code within a a few days... It's time for a quick code review, good ...
1
vote
0answers
32 views

Blockchain implementation in F#: Wallet

Introduction This is Part 3 of my F# blockchain implementation. Previous parts: Block and Blockchain Transactions Code In this part I am implementing a wallet functionality. The code is based on a ...
1
vote
0answers
43 views

Blockchain implementation in F#: Transactions

Introduction This is Part 2 of my F# blockchain implementation. Previous parts: Block and Blockchain Code This time I am tackling transactions. The code is based on a JavaScript blockchain ...
1
vote
0answers
37 views

HTTP request call for a token

The following code seems to have several redundant Flush, Close and Abort statements despite ...
1
vote
0answers
72 views

Immutable Queue with Bulk-Enqueue

I recently needed a data structure with FIFO queue semantics that supported efficient bulk-insertion (often need to enqueue thousands of messages at once). I took a look at Purely Functional Data ...
1
vote
0answers
120 views

F# Operation Framework (Railway-Oriented Programming + Task/Async/Lazy)

I recently published the initial version of what is effectively my first open-source software package, a Railway-Oriented Programming Framework for F# that encapsulates Tasks, Async Workflows, and ...
1
vote
0answers
74 views

Thread-safe hashset that enumerates according to insertion order

According to the .NET documentation, HashSet<T> does not maintain order when enumerated so I implemented my own using F#. Can anyone help review if this is ...
1
vote
0answers
44 views

Creating and manipulating a map for a text based game F#

I have put my whole code so far below, but what I am most interested in is how best to implement the map and utilise it. Any tips on organising my code and keeping it clean would also be greatly ...
1
vote
0answers
85 views

F# Finding the powerset of a set

I have this function which takes a list as input and computes the powerset. ...
1
vote
0answers
149 views

Is This F# Recursive Example Tail Recursive?

I have a payment/lockbox file archiving utility that is called several times per day and with different parameters depending on the files that need archiving. I know I can flatten ...
1
vote
0answers
131 views

Simple INI and command-line parsing, functional programming edition

I'm in the beginning stages of rewriting the model layer of my VBA Sync Tool in F#, to better learn functional programming. So far I've defined: A public ...
1
vote
0answers
88 views

MailboxProcessor and prioritized messages

I'm trying to create an agent that holds on to Data and does further work with it upon receiving the Work message. ...
1
vote
0answers
134 views

Boiler-plate reduction or elimination layer for System.Data .net 4.0

I'd really like to get this to be as clean as possible such that the C# access to it looks succinct. To that end, I've made C# helper methods that abstract out things like ...