Skip to content

Instantly share code, notes, and snippets.

@17cupsofcoffee
Last active March 11, 2017 17:34
Show Gist options
  • Save 17cupsofcoffee/710f1ddb518d8dc16b91a18765c1e99a to your computer and use it in GitHub Desktop.
Save 17cupsofcoffee/710f1ddb518d8dc16b91a18765c1e99a to your computer and use it in GitHub Desktop.
open Akka.FSharp
open Akka.Actor
let system = System.create "system" (Configuration.defaultConfig())
type GreeterMsg =
| Hello of string
| Goodbye of string
let greeter = spawn system "greeter" <| fun mailbox ->
let rec loop() = actor {
let! msg = mailbox.Receive()
match msg with
| Hello name -> printf "Hello, %s!\n" name
| Goodbye name -> printf "Goodbye, %s!\n" name
return! loop()
}
loop()
greeter <! Hello "Joe"
greeter <! Goodbye "Joe"
System.Console.ReadLine() |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment