Skip to content

Instantly share code, notes, and snippets.

@OnurGumus
OnurGumus / ObserverScheduler.fs
Last active May 4, 2025 09:39
Akka ObservingScheduler
module ObservingScheduler
open System
open System.Threading
open Akka.Actor
open Akka.Configuration
open Akka.Event
open Akka.TestKit
@OnurGumus
OnurGumus / pubsub.fs
Last active May 2, 2025 11:32
akka.net pubsub
// See https://aka.ms/new-console-template for more information
using Akka.Actor;
using Akka.Streams;
using Akka.Streams.Dsl;
// Create an ActorSystem
using var system = ActorSystem.Create("StreamSystem");
// Create a Materializer
using var materializer = system.Materializer();
@OnurGumus
OnurGumus / Program.cs
Created March 7, 2025 06:28
marten snapshot
using Marten;
using Marten.Events.Aggregation;
using Marten.Events.Projections;
const string connectionString =
"PORT = 5432; HOST = localhost; TIMEOUT = 15; POOLING = True; DATABASE = 'marten_cqrs_test'; USER ID = 'test'";
var documentStore = DocumentStore.For(options =>
{
options.Connection(connectionString);
open FCQRS.Model.Data
open FCQRS.Model.Aether
open FCQRS.Model.Aether.Operators
open FsToolkit.ErrorHandling
module Domain =
type FirstName =
private
| FirstName of ShortString
@OnurGumus
OnurGumus / Aether4.fs
Last active February 1, 2025 09:30
AsyyncValidatedLens
module Aether
open System
// ----------------------------------------------------------------------------
// Optics
// ----------------------------------------------------------------------------
/// Lens from 'a -> 'b.
type Lens<'a,'b> =
@OnurGumus
OnurGumus / Aether3.fs
Last active January 31, 2025 12:40
Validates Lens 3
module Aether
open System
// Optics
/// Lens from 'a -> 'b.
type Lens<'a,'b> =
('a -> 'b) * ('b -> 'a -> 'a)
@OnurGumus
OnurGumus / Validated lens
Created January 31, 2025 08:47
Aether2.fs
module Aether
open System
// Optics
/// Lens from 'a -> 'b.
type Lens<'a,'b> =
('a -> 'b) * ('b -> 'a -> 'a)
@OnurGumus
OnurGumus / impl1.fs
Last active January 3, 2025 10:15
Lazy Tree - level order
// -----------------------------
// 1) Lazy List
// -----------------------------
type 'a lazyList =
| LNil
| LCons of Lazy<'a * 'a lazyList>
module LazyList =
let cons x xs = LCons(lazy (x, xs))
let empty<'a> : 'a lazyList = LNil
@OnurGumus
OnurGumus / Aether.fs
Last active December 3, 2024 09:27
Aether validation
module Aether
open System
// Optics
/// Lens from 'a -> 'b.
type Lens<'a,'b> =
('a -> 'b) * ('b -> 'a -> 'a)
@OnurGumus
OnurGumus / functor.fs
Created November 26, 2024 09:59
fable functor
type Functor = class end
let inline map (f: 'a -> 'b) (x: ^Functor) : ^Result =
((^Functor or ^Result or Functor) : (static member Map : ^Functor * ('a -> 'b) -> ^Result) (x, f))
type Functor with
static member inline Map (x: list<'a>, f: 'a -> 'b) : list<'b> =
List.map f x
static member inline Map (x: option<'a>, f: 'a -> 'b) : option<'b> =