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
using System; | |
using QueryPattern.Test1; | |
using QueryPattern.Test2; | |
using LaYumba.Functional; | |
namespace QueryPattern | |
{ | |
using System.Threading.Tasks; | |
using static Console; | |
using static F; |
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
using System; | |
using System.Threading.Tasks; | |
using LaYumba.Functional; | |
namespace QueryPattern | |
{ | |
using static Console; | |
using static F; | |
class Program | |
{ |
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
// IMPORTANT! Learn this when teaching yourself f# | |
// BAD! Encourages a non functional request/response design | |
class MyParametricApi | |
{ | |
public MyParametricApi(IDep1 dep1, IDep2 dep2, IDep3 dep3) {} | |
public string Function1(int arg1) { ... } | |
public string Function2(string arg2) { ... } | |
} |
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 context = | |
{ Dep1 = CON ".\SqlExpress"; | |
Dep2 = ENV "DEP_2"; | |
Dep3 = RND (System.Random().Next()); } | |
let app2 = (function2 "test" | |
>>=. function1 | |
>>- function4 | |
>>= (function3 >=> function2)) |
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
type Reader<'x> = Reader of 'x | |
module Reader = | |
let pure x = Reader x | |
let run xR ctx = | |
match xR with | |
| Reader x -> x ctx |
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
type ConnectionString = CON of string | |
type EnvVariable = ENV of string | |
type RandomNum = RND of int | |
type MyApiContext = | |
{ Dep1 : ConnectionString ; | |
Dep2 : EnvVariable; | |
Dep3 : RandomNum } | |
type MyApiPart<'a> = Reader<MyApiContext -> 'a> |
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 config = "world" | |
let greeter = | |
pure (fun config -> "hello" + config + "!") | |
let calc (s:string) = | |
pure (fun (config:string) -> s.Length - config.Length) | |
let app1 = (greeter >>= calc) | |
let r1 = run app1 config |
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
type Reader<'x> = Reader of 'x | |
module Reader = | |
let pure x = Reader x | |
let run xR ctx = | |
match xR with | |
| Reader x -> x ctx |
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
type MyParametricApi(dep1, dep2, dep3) = | |
let doStuffWith dep1 dep2 dep3 arg1 = printfn "stuff:%A" arg1 | |
let doStuffWith' dep1 dep2 dep3 arg2 = printfn "'stuff:%A" arg2 | |
member __.Function1 arg1 = doStuffWith dep1 dep2 dep3 arg1 | |
member __.Function2 arg2 = doStuffWith' dep1 dep2 dep3 arg2 |
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
interface IShowable<T> | |
{ | |
T Value { get; } | |
U Accept<U>(IVisitor<T, U> visitor); | |
} | |
class ShowVisitor : IVisitor<string, string>, | |
IVisitor<int, string>, | |
IVisitor<float, string> | |
{ |
NewerOlder