Skip to content

Instantly share code, notes, and snippets.

cinst 1password
cinst 7zip
cinst 7zip.install
cinst AdobeAIR
cinst adobereader
cinst Atom
cinst markdownpad2
cinst autohotkey.portable
cinst beyondcompare
cinst curl
#time "on"
#load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor

There is a great purely functional streaming/IO library in Scala called scalaz-stream. It is itself based upon a Haskell library called machines. They provide powerful abstractions to express compositional effectful computations. These libraries rely on certain type system features in both Scala and Haskell which are unavailable in F# - namely existential types and higher kinds. Higher kinds allow the monad representing the side-effects to be abstracted over. If however we specialize this to a specific monad, we can get around the lack of existentials as well.

Tomas Petricek created a type called asynchronous sequence which provides similar capabilities. The F# AsyncSeq type is declared as follows:

type AsyncSeq<'a> = Async<AsyncSeqInner<'a>>

and AsyncSeqInner<'a> = 
    | Nil
 | Cons of 'a * AsyncSeq&lt;'a&gt;
type CarsController() =
inherit ApiController()
let values = [| { Make = "Ford"; Model = "Mustang" }; { Make = "Nissan"; Model = "Titan" } |]
/// Gets all values.
member x.Get() =
let ok = x.Ok(values)
let badRequest (msg:string) = x.BadRequest(msg)
async {
  1. General Background and Overview