Module

Transit.Core

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

Core types and functions for transit specifications.

This module provides the foundational types for representing state machine specifications at both the type level and value level. It includes:

  • Type-level constructors for building transit specifications
  • Runtime reflection of type-level specifications to values
  • Core data types for matches, returns, and transit cores
  • Utility functions for querying transit specifications

#GuardName Source

type GuardName = String

Type alias for guard names (runtime).

#Match Source

data Match

A match represents a transition from a state triggered by a message.

  • First StateName: Source state name
  • Second MsgName: Message name
  • Array Return: Possible return states (may include guards)

Constructors

Instances

#MatchImpl Source

newtype MatchImpl :: Symbol -> Symbol -> Type -> Type -> (Type -> Type) -> Type -> Typenewtype MatchImpl (symStateIn :: Symbol) (symMsgIn :: Symbol) stateIn msgIn (m :: Type -> Type) stateOut

Type for match implementations in the update function builder.

Constructors

Instances

#MatchTL Source

data MatchTL

Type-level representation of a match (state, message, returns).

#MkMatchTL Source

data MkMatchTL :: StateNameTL -> MsgNameTL -> List' ReturnTL -> MatchTLdata MkMatchTL t0 t1 t2

Constructs a type-level match from a state name, message name, and list of returns.

Instances

#MkReturnTL Source

data MkReturnTL :: StateNameTL -> ReturnTLdata MkReturnTL t0

Constructs a type-level return to a state (no guard).

Instances

#MkReturnViaTL Source

data MkReturnViaTL :: GuardNameTL -> StateNameTL -> ReturnTLdata MkReturnViaTL t0 t1

Constructs a type-level return via a guard to a state.

Instances

#MkTransitCoreTL Source

data MkTransitCoreTL :: List' MatchTL -> TransitCoreTLdata MkTransitCoreTL t0

Constructs a type-level transit core from a list of matches.

Instances

#MsgName Source

type MsgName = String

Type alias for message names (runtime).

#Return Source

data Return

A return specification indicating the next state after a transition.

  • Return stateName: Direct transition to a state
  • ReturnVia guardName stateName: Conditional transition via a guard

Constructors

Instances

#Ret Source

newtype Ret a

Wrapper for direct return values.

Constructors

Instances

#RetVia Source

newtype RetVia :: Symbol -> Type -> Typenewtype RetVia (symGuard :: Symbol) a

Wrapper for return values via a guard condition.

Constructors

Instances

#ReturnTL Source

data ReturnTL

Type-level representation of a return specification.

#StateName Source

type StateName = String

Type alias for state names (runtime).

#TransitCore Source

newtype TransitCore

A transit core containing all matches (transitions) in a state machine.

Constructors

Instances

#TransitCoreTL Source

data TransitCoreTL

Type-level representation of a transit core specification.

#IsTransitSpec Source

class IsTransitSpec :: forall spec. spec -> TransitCoreTL -> Constraintclass IsTransitSpec spec core | spec -> core

Type class that identifies a type as a valid transit specification.

Instances

#getMatchesForState Source

getMatchesForState :: StateName -> TransitCore -> Array Match

Gets all matches (transitions) that originate from a given state.

Returns an array of all matches where the source state matches the provided state name.

#getStateNames Source

getStateNames :: TransitCore -> Array StateName

Extracts all unique state names from a transit core.

Returns all states that appear as either source states or target states in any match, with duplicates removed.