Skip to content

Instantly share code, notes, and snippets.

@OnurGumus
OnurGumus / kickstart_list.fs
Created October 5, 2019 14:56
kickstart list
open System.Collections.Generic
let csharpList = List<_>();
csharpList.Add(2);
printf "%A" <| csharpList.[0]
let numbers = [1;2;3]
@OnurGumus
OnurGumus / birthday_odds_1
Last active November 28, 2019 11:07
birthday_odds_1
open System
type Item = O = 0 | X = 1 | A = 2
let inline add char = function
| struct (Item.O,Item.O) -> struct (char, Item.O)
| x, Item.O -> x, char
| _, y -> y, char
@OnurGumus
OnurGumus / akkling.fs
Created December 6, 2019 06:58
Akkling Sharding hacks
open System
open Akka.Actor
open Akka.Configuration
open Akka.Cluster
open Akka.Cluster.Tools.Singleton
open Akka.Cluster.Sharding
open Akka.Persistence
open Akka.Persistence.Sqlite
@OnurGumus
OnurGumus / blog.fsx
Last active November 1, 2022 18:09
FSharp blog
open System.IO
#r "paket:
nuget Fake.IO.FileSystem
nuget Fake.Core.Trace
nuget FSharp.Data
nuget Fable.React
nuget FSharp.Literate
nuget Fake.Core.Target //"
#load ".fake/blog.fsx/intellisense.fsx"
@OnurGumus
OnurGumus / canopy.fsx
Created December 17, 2019 11:21
Canopy
#r "packages/Selenium.WebDriver/lib/netstandard2.0/WebDriver.dll"
#r "packages/canopy/lib/netstandard2.0/canopy.dll"
#r "packages/Newtonsoft.Json/lib/netstandard2.0/Newtonsoft.Json.dll"
//these are similar to C# using statements
open canopy.runner.classic
open canopy.classic
canopy.configuration.chromeDir <- @"."
@OnurGumus
OnurGumus / akka_test.fs
Created December 17, 2019 11:24
tickspec xunit wiring
open TickSpec
open Akkling
open Akkling.TestKit
open Akkling.Streams
open Akka.Streams
open Akka.TestKit.Xunit2
open CSVParser
open Swensen.Unquote
open System
@OnurGumus
OnurGumus / akkling_stream.fs
Created December 17, 2019 11:28
akkling-streams
let foreachAsync parallelCount action =
let asyncF =
fun input ->
async {
do! action input
return Akka.NotUsed.Instance
}
Flow.empty
|> Flow.asyncMap parallelCount asyncF
|> Flow.toMat Sink.ignore Keep.right
@OnurGumus
OnurGumus / fable_web_component.fs
Last active July 22, 2020 16:12
Fable Web components
module App
open Fable.Core
open Browser
open Browser.Types
open Fable.Core.JsInterop
open Fable.Core.JS
open Fable.Core.DynamicExtensions
[<AllowNullLiteral>]
type HTMLTemplateElement =
@OnurGumus
OnurGumus / State_monad_with_traversable.fs
Last active May 19, 2020 07:56
State monad with traversable
type State<'st,'a> =
| Ok of 'a * 'st
| Error of ErrorState
and ErrorState = string
type S<'st,'a> = 'st -> State<'st,'a>
and StateMonadBuilder() =
member b.Return(x) : S<_,_> = fun s -> Ok (x, s)
member b.ReturnFrom(x) = x
@OnurGumus
OnurGumus / Functional_excercise1
Created March 6, 2020 19:19
Functional_excercise_1
open System
type ReadInput = unit -> int
type ReadInputR = unit -> Result<int,string>
type Process = int -> int
type ProcessR = Result<int,string> -> Result<int,string>