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
[FunctionName("SequentialWorkflow")] | |
public static async Task Sequential([OrchestrationTrigger] DurableOrchestrationContext context) | |
{ | |
var conference = await context.CallActivityAsync<ConfTicket>("BookConference", "ServerlessDays"); | |
var flight = await context.CallActivityAsync<FlightTickets>("BookFlight", conference.Dates); | |
await context.CallActivityAsync("BookHotel", flight.Dates); | |
} |
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
[FunctionName("BookConference")] | |
public static ConfTicket BookConference([ActivityTrigger] string conference) | |
{ | |
var ticket = BookingService.Book(conference); | |
return new ConfTicket { Code = ticket }; | |
} |
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
[FunctionName("MyFirstFunction")] | |
public static void QueueTrigger( | |
[QueueTrigger("myqueue-items")] string myQueueItem, | |
ILogger log) | |
{ | |
log.LogInformation($"C# function processed: {myQueueItem}"); | |
} |
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
// Given | |
Monad<T> monadicValue; | |
// Then (== means both parts are equivalent) | |
monadicValue.Bind(x => new Monad<T>(x)) == monadicValue |
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
// Given | |
Monad<T> m; | |
Func<T, Monad<U>> f; | |
Func<U, Monad<V>> g; | |
// Then (== means both parts are equivalent) | |
m.Bind(f).Bind(g) == m.Bind(a => f(a).Bind(g)) |
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
// Given | |
T value; | |
Func<T, Monad<U>> f; | |
// Then (== means both parts are equivalent) | |
new Monad<T>(value).Bind(f) == f(value) |
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 loop () = actor { | |
let! message = mailbox.Receive() | |
match message with | |
| Greet(name) -> printfn "Hello %s" name | |
| Hi -> printfn "Hello from F#!" | |
return! loop () | |
} |
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 MaybeBuilder() = | |
member this.Bind(x, f) = | |
match x with | |
| None -> None | |
| Some a -> f a | |
member this.Return(x) = | |
Some 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
let nextTalkCity (speaker: Speaker) = maybe { | |
let! talk = speaker.nextTalk() | |
let! conf = talk.getConference() | |
let! city = conf.getCity(talk) | |
return city | |
} |
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 sendReservation () = async { | |
let! speaker = repository.LoadSpeaker() | |
let! talk = speaker.nextTalk() | |
let! conf = talk.getConference() | |
let! city = conf.getCity() | |
do! bookFlight(speaker, city) | |
} |