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
#r "nuget: FSharp.Data, 4.1.1" | |
open FSharp.Data | |
type TimeData = CsvProvider<"ExampleDates.csv"> | |
let data = TimeData.Load $"{__SOURCE_DIRECTORY__}\\ExampleDates.csv" | |
let analysis = | |
data.Rows | |
|> Seq.map (fun row -> row.ExampleDateTime.Hour) |
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 State<'a, 's> = ('s -> 'a * 's) | |
module State = | |
// Explicit | |
// let result x : State<'a, 's> = fun s -> x, s | |
// Less explicit but works better with other, existing functions: | |
let result x s = | |
x, s | |
let bind (f:'a -> State<'b, 's>) (m:State<'a, 's>) : State<'b, '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
/// State is a function type that takes a state and | |
/// returns a value and the new state. | |
/// Single case union of the same type. | |
type State<'a, 's> = ('s -> 'a * 's) | |
module State = | |
// Explicit | |
// let result x : State<'a, 's> = fun s -> x, s | |
// Less explicit but works better with other, existing functions: | |
let result x 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
type StateId = StateId of int | |
type PlanId = PlanId of int | |
type StepId = StepId of int | |
type State = { | |
LastStateId : StateId | |
LastPlanId : PlanId | |
LastStepId : StepId | |
} | |
type Step = |
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 Food = | |
| Chicken | |
| Rice | |
type Step<'next> = | |
| GetFood of Food * 'next | |
| Eat of Food * 'next | |
| Sleep of hours:int * 'next | |
module Step = |
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 BuilderTest () = | |
member this.Yield (evalResult: bool) = | |
evalResult | |
member this.For(source: seq<'a>, body:'a -> seq<'b * bool>) = | |
source | |
|> Seq.collect (fun x -> body x |> Seq.map (fun (idx, expr) -> (x, idx), expr)) | |
member this.For(source: seq<'a>, body:'a -> bool) = | |
source |> Seq.map (fun x -> x, body x) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
NewerOlder