Skip to content

Instantly share code, notes, and snippets.

@palladin
Last active September 25, 2021 17:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save palladin/3bf4630d3dedb83984a04aa78aadbed7 to your computer and use it in GitHub Desktop.
Save palladin/3bf4630d3dedb83984a04aa78aadbed7 to your computer and use it in GitHub Desktop.
Stream sig
type Stream<'T> // abstract type
module Stream =
// general combinators
val map : (Expr<'A> -> Expr<'B>) -> Stream<'A> -> Stream<'B>
val collect : (Expr<'A> -> Stream<'B>) -> Stream<'A> -> Stream<'B>
val filter : (Expr<'A> -> Expr<bool>) -> Stream<'A> -> Stream<'A>
val take : Expr<int> -> Stream<'A> -> Stream<'A>
val zipWith : (Expr<'A> -> Expr<'B> -> Expr<'C>) -> Stream<'A> -> Stream<'B> -> Stream<'C>
// ...
// producers
val ofArray : Expr<'A []> -> Stream<'A>
val ofList : Expr<'A list> -> Stream<'A>
// consumers
val length : Stream<'A> -> Expr<int>
val toArray : Stream<'A> -> Expr<'A []>
val toList : Stream<'A> -> Expr<'A list>
// ...
// helpers
val compile : (Var<'A> -> Expr<'B>) -> ('A -> 'B)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment