This file contains hidden or 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
// Domain-specific module that uses the lower-level Elastic module | |
namespace RawElastic | |
open Thoth.Json.Net | |
open System.Net.Http | |
open System | |
module String = | |
let split (sep : string) (target : string) = |
This file contains hidden or 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
import { | |
TaggedTemplateLiteralInvocationType, | |
QueryResultRowType, | |
DatabasePoolType | |
} from 'slonik' | |
import * as t from 'io-ts' | |
import { Either } from 'fp-ts/Either' | |
const query = async <T>( | |
sqlQuery: TaggedTemplateLiteralInvocationType<QueryResultRowType>, |
This file contains hidden or 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
namespace HttpClient.FSharp | |
open System | |
open System.Net.Http | |
type HttpMethod = | |
| Post | |
| Put | |
| Delete | |
| Get |
This file contains hidden or 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
//db.fs - helpers | |
module Db = | |
open System.Data.SQLite | |
open System.Data | |
open Dapper | |
let createConnectionFactory (connectionString : string) = | |
let createConnection () = | |
new SQLiteConnection(connectionString) :> IDbConnection |
This file contains hidden or 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
namespace PureDI | |
open Microsoft.AspNetCore.Builder | |
open Microsoft.Extensions.Configuration | |
open Microsoft.Extensions.DependencyInjection | |
open Microsoft.AspNetCore.Mvc | |
open Microsoft.AspNetCore.Mvc.Controllers | |
open Microsoft.Extensions.Logging | |
open Microsoft.AspNetCore | |
open Microsoft.AspNetCore.Hosting |
This file contains hidden or 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
namespace PureDI | |
open Microsoft.AspNetCore.Builder | |
open Microsoft.Extensions.Configuration | |
open Microsoft.Extensions.DependencyInjection | |
open Microsoft.AspNetCore.Mvc | |
open Microsoft.AspNetCore.Mvc.Controllers | |
open Microsoft.AspNetCore.Hosting | |
type Person = { |
This file contains hidden or 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
mkdir Kata | |
cd Kata | |
dotnet new sln | |
mkdir App | |
cd App | |
dotnet new classlib -lang F# |
This file contains hidden or 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 finalResult = | |
seq { | |
yield firstCheckResult () | |
yield secondCheckResult () | |
yield thirdCheckResult () | |
} | |
|> combineResults |
This file contains hidden or 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 combineResults (results : Result<unit, NotAuthorized> seq) : Result<unit, NotAuthorized> = | |
results | |
|> Seq.tryFind (fun r -> | |
match r with | |
| Ok () -> true | |
| Error _ -> false) | |
|> Option.defaultValue (Error NotAuthorized) |
This file contains hidden or 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 allResults : Result<unit, NotAuthorized> seq = | |
seq { | |
yield firstCheckResult () | |
yield secondCheckResult () | |
yield thirdCheckResult () | |
} |
NewerOlder