Skip to content

Instantly share code, notes, and snippets.

View GuuD's full-sized avatar

Illia Dulskyi GuuD

  • Kyiv, Ukraine
  • 01:08 (UTC +02:00)
View GitHub Profile
// step0: quick intro about paket, fake, |> operator and unit
// ------------------ begin ----------------
(*
The problem: lots of boilerplate code to make sure the exit code is being handled properly in our build script.
when we have more steps, the code will smell worse.
*)
// extend a type from another assembly with 'combine'
type List<'a> with
static member combine (f, x: List<'a>) : List<'a> = x @ [f]
// extend another type from another assembly with 'combine'
type System.Int32 with
static member combine (f, x: System.Int32) = x + f
// extend a type from this assembly with 'combine'
@GuuD
GuuD / inject.fs
Created August 19, 2022 16:20
Injecting dependency to Giraffe
let inject (handler : 'dep -> (HttpContext -> Task<HttpContext option>) -> (HttpContext -> Task<HttpContext option>)) next ctx =
let services = ctx.RequestServices
let dependency = services.GetRequiredService<'dep>()
handler dependency next ctx
module VList =
open System
open System.Collections.Generic
open FSharp.NativeInterop
open System.Runtime.CompilerServices
open System.Runtime.InteropServices
open System.Threading
[<Struct>]