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
open System | |
open Thoth.Json.Net | |
type DecodeBuilder() = | |
member _.Bind(decoder, f) : Decoder<_> = | |
Decode.andThen f decoder | |
member _.Return(value) = | |
Decode.succeed value | |
member _.ReturnFrom(decoder : Decoder<_>) = | |
decoder |
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
open Microsoft.EntityFrameworkCore | |
open System.Linq | |
[<CLIMutable>] | |
type YourTable = | |
{ | |
id : int | |
rev : int | |
contents : 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
open System | |
open System.Linq | |
open FSharp.Data.TypeProviders | |
open Microsoft.FSharp.Linq.RuntimeHelpers | |
type Db = SqlDataConnection<"Server=.;Database=QueryTest;Trusted_Connection=true"> | |
let d = Db.GetDataContext() | |
type Result = | |
{ |
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
[<AutoOpen>] | |
module Operators = | |
let uncurry f (a, b) = f a b | |
let cnst x _ = x | |
/// https://en.wikibooks.org/wiki/Haskell/Arrow_tutorial | |
type Circuit<'a, 'b> = Cir of TransitionFunction<'a, 'b> | |
and TransitionFunction<'a, 'b> = 'a -> Circuit<'a, 'b> * 'b | |
module Circuit = |
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
open Microsoft.EntityFrameworkCore | |
[<CLIMutable>] | |
type Customer = | |
{ | |
CustomerId : string | |
CompanyName : string | |
Address : string | |
City : 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
open MongoDB.Bson | |
open MongoDB.Driver | |
type User = | |
{ | |
_id : BsonObjectId | |
Name : string | |
} | |
[<EntryPoint>] |
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
type ContinuationMonad() = | |
member __.Bind(m, f) = fun c -> m (fun a -> f a c) | |
member __.Return(x) = fun k -> k x | |
let cont = ContinuationMonad() | |
let rec reduce fs = | |
cont { | |
match fs with | |
| [] -> return [] |
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
open System.Collections | |
open System.Collections.Generic | |
type InfiniteLazyList<'T> = | |
| (::) of ('T * Lazy<InfiniteLazyList<'T>>) | |
interface IEnumerable<'T> with | |
member this.GetEnumerator() = | |
let head :: tail = this | |
let s = |
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
/// Free monad of Option<'t>. | |
type Nest<'t> = | |
/// Nested options. | |
| Free of Option<Nest<'t>> | |
/// Lifts a value directly into the monad. | |
| Pure of 't | |
module Nest = |
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
/// https://stackoverflow.com/questions/40052256/how-does-continuation-monad-really-work/42062682#42062682 | |
/// A continuation is a function that represents "the rest of the computation". | |
type Cont<'T, 'U> = ('T -> 'U) | |
/// An incomplete computation is a function which, when given a continuation, | |
/// will return a value. | |
type Inc<'T, 'U> = Cont<'T, 'U> -> 'U | |
/// Creates an incomplete computation that holds the given value. |
NewerOlder