charon-0.1: Template
Safe HaskellSafe-Inferred
LanguageGHC2021

Charon.Runner.Phase

Description

Provides framework for "phased" data. This is a generalization of the "Higher-kinded data" approach where instead of merely annotating a data type with some constructor e.g.

data Foo f = MkFoo
  { bar :: f Bool,
    baz :: f String,
    ...
  }

we use a type family:

data Foo s = MkFoo
  { bar :: Fam1 s,
    baz :: Fam2 s,
  ...
  }

Not only does this allow fields to vary independently, it also means we can avoid clunky wrappers like Identity.

We do this so that we can represent data that "evolves" e.g. we may initially parse a data type as Foo1 (phase 1) but then further process this data type into Foo2 (phase 2). Using this phase approach avoids duplication of constructors and fields.

Synopsis

Documentation

data Phase Source #

Index for data that has a "phased" evolution.

Constructors

Phase1 
Phase2 

Instances

Instances details
Show Phase Source # 
Instance details

Defined in Charon.Runner.Phase

Methods

showsPrec :: Int -> Phase -> ShowS #

show :: Phase -> String #

showList :: [Phase] -> ShowS #

Eq Phase Source # 
Instance details

Defined in Charon.Runner.Phase

Methods

(==) :: Phase -> Phase -> Bool #

(/=) :: Phase -> Phase -> Bool #

class AdvancePhase a where Source #

Advances phased data.

Associated Types

type NextPhase a Source #

The next phase.

Methods

advancePhase :: a -> NextPhase a Source #

Advances the data.

type family MaybePhaseF s a where ... Source #

Type family for the common case of evolving an optional type Maybe a into a definite a (i.e. after default substitution).

Equations

MaybePhaseF Phase1 a = Maybe a 
MaybePhaseF Phase2 a = a