Skip to content

Instantly share code, notes, and snippets.

@OnurGumus
OnurGumus / FreeMonad.fs
Created April 27, 2024 15:24
free monad
// Define the types for the inputs and outputs
type AccountID = AccountID of int
type Balance = Balance of decimal
type Deposit = Deposit of int * decimal
type NewBalance = NewBalance of decimal
type LogMessage = string
// Define mock implementations for the operations
let getAccountBalance (AccountID id) =
match id with
import { useRef, useState } from "react";
import ReactDOM from "react-dom";
import { createRoot } from 'react-dom/client'
import { Canvas, MeshProps, useFrame } from '@react-three/fiber'
import { Mesh } from "three";
import React from "react";
function Box(props) {
// This reference will give us direct access to the mesh
const mesh = useRef<Mesh>(null!)
namespace Lit
open System
open Fable.Core
open Fable.Core.JsInterop
open Fable.React
open Browser.Types
open Lit
/// <summary>
module Fable.Elmish.Nile
open Elmish
open FSharp.Control
open FSharp.Control.Core
[<RequireQualifiedAccess>]
module Program =
/// Uses `stream` to transform a stream of messages dispatched from the view
/// and a stream of updates to a stream of messages dispatched to `update`.
/// `stream` is only called once.
@OnurGumus
OnurGumus / serialzier.fs
Created April 30, 2023 08:32
custom thoth decoder
module Command.Serialization
open Command
open System
open Akkling
open Akkling.Persistence
open Akka.Cluster.Tools.PublishSubscribe
open Akka
open Akka.Cluster.Sharding
open Akkling.Cluster.Sharding
@OnurGumus
OnurGumus / Example.fs
Last active March 27, 2023 09:17
MSAL wrapper Fable
module Example
open Fable.Core
open Fable.Core.JsInterop
open Msal
open Configuration
open Account
open System.Collections.Generic
module private Internal =
@OnurGumus
OnurGumus / Lit.React.fs
Created February 13, 2023 09:20
Lit.React.fs
namespace Lit
open System
open Fable.Core
open Fable.Core.JsInterop
open Fable.React
open Browser.Types
open Lit
/// <summary>
@OnurGumus
OnurGumus / girafe_GWT.fs
Created January 15, 2023 15:24
private JWT auth
module GiraffeJWTAuthExample.App
open System
open System.IO
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Cors.Infrastructure
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging
@OnurGumus
OnurGumus / boxing.fs
Last active January 2, 2023 15:11
F# boxing equality
open System.Collections.Generic
[<Struct; CustomComparison; CustomEquality>]
type MyVal =
val X : int
new(x) = { X = x }
override this.Equals other =
match other with
| :? MyVal as y -> this.Equals y
@OnurGumus
OnurGumus / LCP.fs
Created August 21, 2022 21:57
pupeteersharp
// For more information see https://aka.ms/fsharp-console-apps
open PuppeteerSharp
open Newtonsoft.Json.Linq
let launchOptions =
LaunchOptions(
Headless = true,
Args =
[|