Skip to content

Instantly share code, notes, and snippets.

@mnebes
mnebes / chords.fsx
Created December 9, 2022 14:03
Chord progressions with F#
open System
type Interval =
| PerfectUnison
| MinorSecond
| MajorSecond
| MinorThird | AugmentedSecond // Enharmonically the same in 12TET
| MajorThird
| PerfectFourth
| DiminishedFifth | AugmentedFourth // Enharmonically the same in 12TET
@TheAngryByrd
TheAngryByrd / ParallelAsyncBuilder.fs
Last active January 10, 2022 14:44
Async computation allowing for parallel execution asyncs when using applicatives (and! syntax)
namespace AsyncHelpers
type Async =
static member map f x =
async.Bind(x, fun v -> async.Return(f v))
/// <summary>
/// Executes two asyncs concurrently and returns a tuple of the values
/// </summary>
/// <param name="a1">An async to execute</param>
namespace Fsion
open System.Threading
[<Struct;NoEquality;NoComparison>]
type Cancel =
private
| Cancel of bool ref * children: Cancel list ref
module internal Cancel =
module Blittable
type System.SByte with
static member IsBlittableMarker = ()
type System.Byte with
static member IsBlittableMarker = ()
type System.Int16 with
static member IsBlittableMarker = ()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@isaacabraham
isaacabraham / io-monad.fsx
Last active November 1, 2022 23:58
F# port of the first half of John De Goes "FP to the max" (https://www.youtube.com/watch?v=sxudIMiOo68)
#load @".paket\load\net452\FSharpPlus.fsx"
open FSharpPlus
open System
[<AutoOpen>]
module rec IO =
let run (IO computation) = computation()
type IO<'T> =
@alfonsogarciacaro
alfonsogarciacaro / Deploy.md
Last active March 3, 2023 09:50
Deploying an F# ASP.NET Core app (Giraffe) to Azure

Deploying an F# ASP.NET Core app to Azure

Last week I spent a lot of time trying to deploy an F# ASP.NET Core app (a Giraffe app, specifically) to Azure because the information to complete all the steps was scattered in several places. So I'm writing this hopefully it will save the pain to others :)

Preparation

The following steps are mostly taken from this guide and it's only necessary to do them once:

  1. Create an account in Azure (or use an existing one)
  2. Create a resource group (or use an existing one)
@ShalokShalom
ShalokShalom / compabilitylistforhaskell.md
Last active March 7, 2018 12:26 — forked from gusty/fsharpplus_haskell_compatibility.md
Haskell operator compatibility layer for F-Sharp
+----------------------+--------------------+--------------------+--------------------+
|      Operation       |      F-Sharp       |     Compability    |      Haskell       |
+======================+====================+====================+====================+
| List.append          |         @          |                    |        ++          |
+----------------------+--------------------+--------------------+--------------------+
| Function composition |       f << g       |       f . (g)      |       f . g        |
+----------------------+--------------------+--------------------+--------------------+
|                      |         =          |        ==          |        ==          |
+----------------------+--------------------+--------------------+--------------------+
@panesofglass
panesofglass / apply.fsx
Last active August 21, 2017 22:34
F# async applicative using a custom operation
open System
type FSharp.Control.AsyncBuilder with
[<CustomOperation("and!", IsLikeZip=true)>]
member __.Merge(x, y, f) =
async {
let! token = Async.CancellationToken
let! x' = Async.StartChildAsTask x
let! y' = Async.StartChildAsTask y
do System.Threading.Tasks.Task.WaitAll([|x';y'|], cancellationToken = token)