Module

Transit.Class.CheckReturn

Package
purescript-transit
Repository
m-bock/purescript-transit

Type classes for checking and expanding partial return types to full state types.

#CheckReturn Source

class CheckReturn :: List' @Type ReturnTL -> Row Type -> Row Type -> Constraintclass CheckReturn (returns :: List' ReturnTL) (rowIn :: Row Type) (rowOut :: Row Type) | returns -> rowIn rowOut where

Checks and expands return types by removing Ret and RetVia wrappers from variant types.

The functional dependency returns -> rowIn rowOut ensures that given the return list, both input and output row types are uniquely determined.

  • returns: List of return type-level specifications
  • rowIn: Input row type (with wrappers)
  • rowOut: Output row type (without wrappers)

Members

Instances

#checkReturnFast Source

checkReturnFast :: forall @returns state msg m rowIn rowOut. CheckReturn returns rowIn rowOut => (state -> msg -> m (Variant rowIn)) -> (state -> msg -> m (Variant rowOut))

A faster version of checkReturn that uses unsafe coercion. This is useful for performance-critical code where code generated by the compiler is a bottleneck. It is safe because we guarantee that the runtime representation of the handler function is the same as the type-level representation.