Skip to content

Instantly share code, notes, and snippets.

@matthewcrews
matthewcrews / gist:57e83a709d31a6c7fffdd293654c5709
Created January 4, 2024 19:16
Serialize/Deserialize Binary
open System
open Microsoft.FSharp.Core.LanguagePrimitives
type Weibull_Parameters =
{
Scale: float
Shape: float
}
// Writes the bytes of the parameters to the buffer and returns to new offset for writing
// more data.

Questions

  1. Where did your journey into software begin?
  2. What various jobs did you have on your journey before you arrived at F#?
  3. What value do you think OO languages have? What is the good we can take from them?
  4. When did you discover F#?
  5. What were the challenges for you when you learned F#?
  6. What do you think is the key benefit to coding in a functional style?
  7. Where do you think F# shines in comparison to other functional-first programming languages?
  8. What has life been like as an F# developer?
  9. At what point did you decide to strike out on your own with Compositional IT?
#r "nuget: MessagePack"
open System.IO
open System.Runtime.InteropServices
open MessagePack
open System
[<Struct; MessagePackObject>]
type Chicken =
{
{
"[odin]": {
"editor.tabSize": 4,
"editor.insertSpaces": false,
"editor.detectIndentation": false
},
"files.autoSave": "afterDelay",
"FSharp.addFsiWatcher": true,
"FSharp.fsiExtraParameters": [
"--optimize+",
open System
open System.Buffers
open System.Collections.Generic
open BenchmarkDotNet.Running
open BenchmarkDotNet.Attributes
[<Struct>]
type Entry =
{
I : int
type All = All
type SliceIndex2D<'a, 'b when 'a : equality and 'b : equality>(values: seq<'a * 'b>) =
let values = Array.ofSeq values
member s.Item
with get (k1: 'a, _: All) =
values
|> Seq.filter (fun (a, _) -> a = k1)

Tractor: A CLR Language for Numerical Computation

The original intention of the dotnet was to provide a runtime for many programming languages to run on. Two factors have kept that vision from fruition: tying .NET Framework to Windows and the dominance of C#.

Dotnet can now run on almost any modern system. A significant push has been made toward performance features for C# and the CLR. The intention is to close the performance gap between systems-level programming languages (C, C++, Rust, Zig, and Odin, to name a few) and what can be achieved on the dotnet platform.

A general-purpose language like C# and F# must support

Guiding Principles

@matthewcrews
matthewcrews / settings.json
Created September 1, 2022 21:23
VS Code Settings
{
"workbench.colorTheme": "GDScript",
"editor.tokenColorCustomizations": {
"[Dracula Soft]": {
"textMateRules": [
{
"scope": "keyword.fsharp",
"settings": {
"foreground": "#65d6ff8b",
}
open System
open System.Collections
open System.Collections.Generic
module private Helpers =
let inline computeBucketAndMask (itemKey: int<'Item>) itemCount =
if (uint itemKey) >= (uint itemCount) then
raise (IndexOutOfRangeException (nameof itemKey))
[<Struct;IsByRefLike>]
type StackStack<'T>(values: Span<'T>) =
[<DefaultValue>] val mutable private Count : int
member s.Push v =
if s.Count < values.Length then
values[s.Count] <- v
s.Count <- s.Count + 1
else
failwith "Exceeded capacity of StackStack"