Skip to content

Instantly share code, notes, and snippets.

@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>]
@OnurGumus
OnurGumus / torch_bridge.fs
Last active May 2, 2022 13:08
torch bridge
let rec cross (left,right) =
match left with
| [] -> 0
| _ -> seq {
for x in right do
let newRight = right |> List.filter(fun a -> a <> x)
yield x + go(x::left, newRight) }|> Seq.min
and go (left,right) =
match left with
| [x] -> x
@OnurGumus
OnurGumus / stateles.fs
Created April 14, 2022 15:50
final_stateless
let y f =
let f' (x:obj -> _) = f (fun y -> x x y)
f' (fun x -> f' (x :?> _))
module AsyncResult =
open System.Threading.Tasks
open System
@OnurGumus
OnurGumus / game.fs
Created April 14, 2022 12:44
game.fs
let y f =
let f' (x:obj -> _) = f (fun y -> x x y)
f' (fun x -> f' (x :?> _))
module AsyncResult =
open System.Threading.Tasks
open System
let y f =
let f' (x:obj -> _) = f (fun y -> x x y)
f' (fun x -> f' (x :?> _))
module AsyncResult =
open System.Threading.Tasks
open System
@OnurGumus
OnurGumus / akkling_test.fs
Created April 12, 2022 19:28
akkling test
module BDD
open Akkling
open Akkling.Streams
open Akkling.TestKit
open Akka.Actor
open System
open Xunit
open Akkling.Streams.Operators
open Akka.Streams.Dsl
@OnurGumus
OnurGumus / steam.fs
Last active April 11, 2022 12:27
steams2
module Server.App
open System
open Akka.Streams
open Akka.Streams.Dsl
open Akkling
open Akkling.Streams
open Akkling.Streams.Operators
open Akka
@OnurGumus
OnurGumus / QS.ts
Last active April 7, 2022 15:39
qs
type Part<
P extends number,
A extends number[],
Left extends number[] = [],
Right extends number[] = [],
> = A extends []
? [P, Left, Right]
: A extends [infer F extends number, ...infer Rest extends number[]]
@OnurGumus
OnurGumus / sort.ts
Created April 7, 2022 08:16
ts_sort
// Type level bubble sort algorithm
// https://twitter.com/anuraghazra
type BubbleSort<
A extends any[],
Curr extends number = A["length"]
> = Curr extends 1
? A
: A extends [infer F, infer S, ...infer Rest]
? BubbleSort<
@OnurGumus
OnurGumus / ycomb.fs
Last active April 2, 2022 07:50
y comb
module FSharpX =
module Operators =
/// Inject a value into the monadic type
let inline returnM builder x = (^M: (member Return: 'b -> 'c) (builder, x))
let inline bindM builder m f = (^M: (member Bind: 'd * ('e -> 'c) -> 'c) (builder, m, f))
let inline liftM builder f m =
let inline ret x = returnM builder (f x)
bindM builder m ret