| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
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
- data Phase
- class AdvancePhase a where
- type NextPhase a
- advancePhase :: a -> NextPhase a
- type family MaybePhaseF s a where ...
Documentation
Index for data that has a "phased" evolution.
class AdvancePhase a where Source #
Advances phased data.
Instances
| AdvancePhase ListFormatPhase1 Source # | |
Defined in Charon.Runner.Command.List Associated Types type NextPhase ListFormatPhase1 Source # Methods advancePhase :: ListFormatPhase1 -> NextPhase ListFormatPhase1 Source # | |
| AdvancePhase (Command 'Phase1) Source # | |
| AdvancePhase (ListCmd 'Phase1) Source # | |
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 |