Module

Transit.VariantUtils

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

Convenience utilities for creating Variant values.

This module provides a type-safe way to create Variant values using type application, eliminating the need for Proxy values and allowing empty record arguments to be omitted.

Usage

For variants with empty payloads (empty record):

v @"DoorOpen" :: State

For variants with non-empty payloads:

v @"DoorLocked" { activePin: "1234" } :: State

#Inj Source

class Inj :: Symbol -> Type -> Constraintclass Inj (sym :: Symbol) a  where

Type class for injecting values into Variants using type application.

The v function provides a convenient way to create Variant values without needing Proxy values. It automatically handles both empty and non-empty payloads.

Members

  • v :: a

    Creates a Variant value by injecting a value into the specified variant label.

    For variants with non-empty payloads, the payload must be provided:

    v @"Label" payload :: Variant (label :: PayloadType | r)
    

    For variants with empty payloads (empty record), the payload can be omitted:

    v @"Label" :: Variant (label :: {} | r)
    

Instances