Skip to content

Instantly share code, notes, and snippets.

open Akka.Actor
open Akka.Streams
open Akka.Streams.Dsl
open System
open System.Threading
[<EntryPoint>]
let main _ =
let sys = ActorSystem.Create "test"
let mat = ActorMaterializer.Create sys
let props (_scanType: ScanType) : Akka.Actor.Props =
props(
let rec start (ctx: Actor<obj>) (state: State) (msg: obj) =
match msg with
| LifecycleEvent PostStop -> kill state.Process
| :? Msg as msg ->
match msg with
| Start ->
Starter.start def |> Async.map Started |!> ctx.Self.Retype()
become (starting ctx state)
[<AutoOpen>]
module CResult =
open System.Diagnostics
[<Sealed>]
type CResultBuilder () =
static let zero = Ok ()
member inline __.Return value : Result<'T, 'Error> = Ok value
[<MemoryDiagnoser>]
type Betch() =
let s = "123 456"
[<Benchmark(Baseline = true)>]
member __.Array() =
let [|foo; bar|] = s.Split ' '
let _x =
match BigInteger.TryParse foo, Int32.TryParse bar with
| (true, x), (true, y) -> x, y
open Akka.Actor
open Akka.Streams
open Akkling.Streams
open System
type Image = Image of string
let imageJob delay jobName (Image image) =
async {
printfn "%s Started: %s" jobName image
let (|AP|_|) (x: int) = if x < 0 then None else Some()
let (|A|B|C|D|) (x: int) = if x = 1 then A elif x = 2 then B elif x = 3 then C else D
[<EntryPoint>]
let main argv =
match 0 with
| AP -> 0
| AP -> 0
| AP -> 0
| AP -> 0
case class Person(name: String, flag: Boolean)
def sortedKeyList(xs: List[List[Person]]) = {
xs.flatten
.map(_.name)
.distinct
.sortBy(identity)
.mkString(", ") match {
case "" => "<none>"
case s => s

Constracts

case class OfferSource(ref: SourceRef[Int])
case object RequestSource

Producer

akka {
  actor {
    provider = "cluster"
#![feature(universal_impl_trait)]
extern crate time;
extern crate regex;
extern crate itertools;
#[macro_use]
extern crate error_chain;
use time::{PreciseTime, Duration};
use std::io::prelude::*;
open System.Diagnostics
open System.Text.RegularExpressions
open System.IO
open System
let search file pattern =
let r = Regex(pattern, RegexOptions.ExplicitCapture ||| RegexOptions.Compiled ||| RegexOptions.IgnoreCase)
let delims = [|';'; '"'; ' '|]
[| for line in File.ReadLines file |> Seq.take 10_000_000 do
match r.Match line with