You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The typing rules for the core language could look something like:
f : Format x : Repr Format ⊢ e : Bool
──────────────────────────────────────────────
{ x <- f | e } : Format
Repr { x <- f | e } = Repr f
s .. s' : f ⟹ e₁ x : Repr f = e₁ ⊢ e₂ = true : Bool
────────────────────────────────────────────────────────────
s .. s' : { x <- f | e₂ } ⟹ e₁
{ x <- f | e } is a Format when:
f is a Format
assuming x : Repr Format, e is a Bool
the representation of { x <- f | e } is Repr f
the bit sequence s .. s' is recognized with { x <- f | e₂ } as an expression e₁ when:
the bit sequence s .. s' is recognized with f as an expression e₁
assuming x : Repr f = e₁, e₂ is the same Bool as true
Elaborated typing rules
Some might find it easier to read these rules with explicit typing contexts, Γ:
Γ ⊢ f : Format Γ, x : Repr Format ⊢ e : Bool
────────────────────────────────────────────────────
Γ ⊢ { x <- f | e } : Format
under the context Γ, { x <- f | e } is a Format when:
under the context Γ, f is a Format
under the context Γ, x : Repr Format, e is a Bool
Note: The binary interpretation uses a similar notation as Mark Brown in the prolog prototype.
Naming ideas
Some alternative names for these format descriptions could be:
conditional formats
refinement formats
guard formats
Future extensions
Predicate preservation
Eventually we could preserve the guard condition in the representation types, using refinement types:
- f : Format x : Repr Format ⊢ e : Bool+ f : Format x : Repr Format ⊢ e : Prop
──────────────────────────────────────────────
{ x <- f | e } : Format
- Repr { x <- f | e } = Repr f+ Repr { x <- f | e } = { x : Repr f | e }
Syntactic Sugar
We could eventually add some sugar for record formats:
It would be useful to have format descriptions that are refine other formats with predicates:
For example, in OpenType we might see something like:
Rough specification
The typing rules for the core language could look something like:
{ x <- f | e }
is aFormat
when:f
is aFormat
x : Repr Format
,e
is aBool
{ x <- f | e }
isRepr f
s .. s'
is recognized with{ x <- f | e₂ }
as an expressione₁
when:s .. s'
is recognized withf
as an expressione₁
x : Repr f = e₁
,e₂
is the sameBool
astrue
Elaborated typing rules
Some might find it easier to read these rules with explicit typing contexts,
Γ
:Γ
,{ x <- f | e }
is aFormat
when:Γ
,f
is aFormat
Γ, x : Repr Format
,e
is aBool
Note: The binary interpretation uses a similar notation as Mark Brown in the prolog prototype.
Naming ideas
Some alternative names for these format descriptions could be:
Future extensions
Predicate preservation
Eventually we could preserve the guard condition in the representation types, using refinement types:
Syntactic Sugar
We could eventually add some sugar for record formats:
Or perhaps:
The text was updated successfully, but these errors were encountered: