Cont is:module

  • Computation type: Computations which can be interrupted and resumed.
  • Binding strategy: Binding a function to a monadic value creates a new continuation which uses the function as the continuation of the monadic computation.
  • Useful for: Complex control structures, error handling, and creating co-routines.
  • Zero and plus: None.
  • Example type: Cont r a
The Continuation monad represents computations in continuation-passing style (CPS). In continuation-passing style function result is not returned, but instead is passed to another function, received as a parameter (continuation). Computations are built up from sequences of nested continuations, terminated by a final continuation (often id) which produces the final result. Since continuations are functions which represent the future of a computation, manipulation of the continuation functions can achieve complex manipulations of the future of the computation, such as interrupting a computation in the middle, aborting a portion of a computation, restarting a computation, and interleaving execution of computations. The Continuation monad adapts CPS to the structure of a monad. Before using the Continuation monad, be sure that you have a firm understanding of continuation-passing style and that continuations represent the best solution to your particular design problem. Many algorithms which require continuations in other languages do not require them in Haskell, due to Haskell's lazy semantics. Abuse of the Continuation monad can produce code that is impossible to understand and maintain.
Continuation monads. Delimited continuation operators are taken from Kenichi Asai and Oleg Kiselyov's tutorial at CW 2011, "Introduction to programming with shift and reset" (http://okmij.org/ftp/continuations/#tutorial).
  • Computation type: Computations which can be interrupted and resumed.
  • Binding strategy: Binding a function to a monadic value creates a new continuation which uses the function as the continuation of the monadic computation.
  • Useful for: Complex control structures, error handling, and creating co-routines.
  • Zero and plus: None.
  • Example type: Cont r a
The Continuation monad represents computations in continuation-passing style (CPS). In continuation-passing style function result is not returned, but instead is passed to another function, received as a parameter (continuation). Computations are built up from sequences of nested continuations, terminated by a final continuation (often id) which produces the final result. Since continuations are functions which represent the future of a computation, manipulation of the continuation functions can achieve complex manipulations of the future of the computation, such as interrupting a computation in the middle, aborting a portion of a computation, restarting a computation, and interleaving execution of computations. The Continuation monad adapts CPS to the structure of a monad. Before using the Continuation monad, be sure that you have a firm understanding of continuation-passing style and that continuations represent the best solution to your particular design problem. Many algorithms which require continuations in other languages do not require them in Haskell, due to Haskell's lazy semantics. Abuse of the Continuation monad can produce code that is impossible to understand and maintain.
Continuation style utilities.
API for Church-encoded vectors. Implementation of function from Data.Vector.Fixed module uses these function internally in order to provide shortcut fusion.
CPS encoded heterogeneous vectors.
The continuation indexed monad transformer.
Exception context and annotations.
Contravariant functors, sometimes referred to colloquially as Cofunctor, even though the dual of a Functor is just a Functor. As with Functor the definition of Contravariant for a given ADT is unambiguous.
This module defines the type class MonadBaseControl, a subset of MonadBase into which generic control operations such as catch can be lifted from IO or any other base monad. Instances are based on monad transformers in MonadTransControl, which includes all standard monad transformers in the transformers library except ContT. See the lifted-base package which uses monad-control to lift IO operations from the base library (like catch or bracket) into any monad that is an instance of MonadBase or MonadBaseControl. See the following tutorial by Michael Snoyman on how to use this package: https://www.yesodweb.com/book/monad-control

Quick implementation guide

Given a base monad B and a stack of transformers T:
A collection of basic Content-Types (also known as Internet Media Types, or MIME types). Additionally, this module provides classes that encapsulate how to serialize or deserialize values to or from a particular Content-Type. Content-Types are used in ReqBody and the method combinators:
>>> type MyEndpoint = ReqBody '[JSON, PlainText] Book :> Put '[JSON, PlainText] Book
Meaning the endpoint accepts requests of Content-Type application/json or text/plain;charset=utf8, and returns data in either one of those formats (depending on the Accept header). If you would like to support Content-Types beyond those provided here, then:
  1. Declare a new data type with no constructors (e.g. data HTML).
  2. Make an instance of it for Accept.
  3. If you want to be able to serialize data *into* that Content-Type, make an instance of it for MimeRender.
  4. If you want to be able to deserialize data *from* that Content-Type, make an instance of it for MimeUnrender.
Note that roles are reversed in servant-server and servant-client: to be able to serve (or even typecheck) a Get '[JSON, XML] MyData, you'll need to have the appropriate MimeRender instances in scope, whereas to query that endpoint with servant-client, you'll need a MimeUnrender instance in scope.
FFI bindings to the various standard Win32 controls.