Skip to content

Instantly share code, notes, and snippets.

View goswinr's full-sized avatar

Goswin Rothenthal goswinr

View GitHub Profile
@OnurGumus
OnurGumus / Dat.fs
Last active November 21, 2023 20:21
three.js fable
module rec Dat
open Browser.Types
open Fable.Core
open System
[<ImportAll("dat.gui")>]
let exports: IExports = jsNative
[<AllowNullLiteral>]
@mrange
mrange / 0_README.md
Last active August 10, 2022 19:24
Simple physics in F# and WPF

Simple physics in F# and WPF

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.

How to run

@Horusiath
Horusiath / RTree.fs
Last active October 26, 2022 13:55
RTree implementation for 2D spatial data
(*
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
@mrange
mrange / README.md
Last active January 20, 2022 20:33
Parsers combinators with F#6

Parsers combinators with F#6 [<InlineIfLambda>]

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>].

Fsharp goodies (Vol 1)

After the 'F# Compiler Community Session' I read the first 1K lines of SyntaxTree.fs. That's what I learned about the language.

  1. There is a byte string

    let a = "abc"B
    val a : byte [] = [|97uy; 98uy; 99uy|]
@isaacabraham
isaacabraham / 1-nav.html
Last active October 2, 2020 00:20 — forked from CallumVass/nav.fs
<aside class="relative bg-blue-700 lg:self-stretch lg:w-64 w-full shadow-xl flex flex-col">
<div class="p-6 flex justify-between">
<a href="..">
<img class="object-scale-down h-8 lg:h-32" src=".." alt=".. Logo"/>
</a>
<div class="block lg:hidden">
<button id="nav-toggle" class="flex items-center px-3 py-2 border rounded text-white border-white">
<svg class="fill-current h-3 w-3" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<title>Menu</title>
<path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"/>
@deviousasti
deviousasti / Rpc.fs
Last active August 23, 2022 15:04
Fast inter-process RPC using shared memory
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>) =
@swlaschin
swlaschin / effective-fsharp.md
Last active March 8, 2024 03:10
Effective F#, tips and tricks

Architecture

  • 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

// 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.
@jdh30
jdh30 / JsonParser.fs
Last active January 30, 2024 14:06
Simple JSON parser written in F# using active patterns
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