This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PollingService | |
open System.Diagnostics | |
let poll interval work = | |
let sw = Stopwatch() | |
let rec loop() = | |
async { | |
sw.Restart() | |
work() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// And here is how both of them are composed in a higher level module so I can pass in another function without hard dependency for testing | |
let keys = [| "SOclient_id"; "SOscope"; "SOredirect_uri"|] | |
let queryParameters = readConfigApi keys readConfigurationValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. breaking CQS | |
var sor = new SimpleOrderRouting(); | |
var orderConfirmation = sor.Route(new OrderRequest(..)); | |
bool isOrderExecuted = orderConfirmation.ExecutionCompleted; | |
//2. adhering to CQS not blocking | |
var sor = new SimpleOrderRouting(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Define order types | |
type OrderRef = string // placeholder for a more complicated typ | |
type OrderItem = OrderItem of string | |
type PaymentReceipt = {OrderRef : OrderRef; PaidAmount : decimal} | |
// 2. define states | |
type EmptyState = NoItems of OrderRef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Udi style w Static Domain Events | |
var dispatcher = new RecordingDomainEventsDispatcher(); | |
DomainEvents.Dispatcher = dispatcher; | |
var customer = new Customer(new Address()); | |
customer.Move(new Address()); | |
Console.WriteLine("Customer moved: " + dispatcher.RecordedDomainEvent(new CustomerMoved())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 step. | |
type Order with | |
static member NewOrder = fun orderRef -> Order.Empty (NoItems orderRef) | |
// 2 step replace "=" with "with" in the first step | |
type Order = | |
| Empty of EmptyState | |
| PaymentExpected | |
| Payed | |
| Cancelled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec split<'T> (input: 'T array) size = | |
let rec loopOn (tail : 'T array) grouped = | |
let lastIndex = Array.length tail - 1 | |
let endindx = min (size - 1) lastIndex | |
let arrWrapper = (fun e -> [|e|]) | |
let newGroup = tail.[0..endindx] | |
|> List.ofArray | |
|> arrWrapper | |
|> Array.append grouped | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var p1 = startSriper.ToParser(); | |
var p2 = endSriper.ToParser(); | |
var composite = p1.Compose(p2); | |
var result2 = composite(content); | |
var parsers = from a in p1 | |
from b in p2 | |
select b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open Microsoft.FSharp.Core | |
// maybe there is a better way to simplify this | |
let private (|Greater|_|) descendent compareResult = | |
match compareResult with | |
| n when n < 0 && descendent -> None | |
| n when n < 0 && not descendent -> Some() | |
| 0 -> None | |
| n when n > 0 && descendent -> Some() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FunDomain.Persistence.NEventStore.NesGateway | |
open FunDomain.Persistence.Serialization | |
open NEventStore | |
open NEventStore.Persistence | |
open NEventStore.Persistence.Sql.SqlDialects | |
open Microsoft.FSharp.Reflection | |
open System |
OlderNewer