-
Use Onion architecture
- Dependencies go inwards. That is, the Core domain doesn't know about outside layers
-
Use pipeline model to implement workflows/use-cases/stories
- Business logic makes decisions
- IO does storage with minimal logic
- Keep Business logic and IO separate
-
Keep IO at edges
| type Json = | |
| | Null | |
| | Bool of bool | |
| | Number of float | |
| | String of string | |
| | Array of Json list | |
| | Object of (string * Json) list | |
| type Bracket = Open | Close |
| // This is am example of an immediate write / random access cursor for Excel with basic formatting options. | |
| // Implementation is based on a concrete, non generic writer monad with no payload ("do!"" only) (only state). | |
| // Instead of directl writing to excel, an alternatives would be a random acces to a | |
| // copy-on-write list (or even a mutable array) and then bulk-write the result to excel in one shot. | |
| // When only forward access would have been required, a simple seq expression with yields would have been enough. | |
| // Anyway, it is a demonstration on how to "hide" pseudo-mutable state that is passed through a computation. | |
| // | |
| // I personally use it for generating reports based on various data sources. |
| open SharedMemory | |
| open MBrace.FsPickler | |
| module Rpc = | |
| type RpcContext<'command, 'message> = | |
| { name: string; buffer: RpcBuffer; post: 'command -> Async<'message>} with | |
| interface IDisposable with | |
| member this.Dispose() = this.buffer.Dispose() | |
| let createHost name (handler : 'command -> Async<'message>) = |
Thanks to manofstick peer reviewing the blog post.
Full source code at github
For F# Advent 2021 I wrote a blog post exploring how F#6 [<InlineIfLambda>] can improve data pipeline performance.
I was thinking of other places where [<InlineIfLambda>] can help and decided to try to build a parser combinator library with [<InlineIfLambda>].
| (* | |
| An immutable R-Tree implementation in F#. | |
| Based on: https://github.com/swimos/swim-rust/tree/main/swim_utilities/swim_rtree (licensed on Apache 2.0) | |
| Author: Bartosz Sypytkowski <b.sypytkowski at gmail.com> | |
| *) | |
| namespace Demos.RTree |
This is an example on how to use WPF and F# to do some simple physics using Verlet Integration.
The program creates a system of particles and constraints. Particles have inertia and is affected by gravity but their motion is also contrained by the constraints.
I tried to annotate the source code to help guide a developer familiar with languages like C#. If you have suggestions for how to improve it please leave a comment below.
| module rec Dat | |
| open Browser.Types | |
| open Fable.Core | |
| open System | |
| [<ImportAll("dat.gui")>] | |
| let exports: IExports = jsNative | |
| [<AllowNullLiteral>] |