Skip to content

Latest commit

 

History

History
176 lines (139 loc) · 8.76 KB

TODO.org

File metadata and controls

176 lines (139 loc) · 8.76 KB

Tasks

values fields without type sign aren’t part of principal sig

module X {
  sig x : t1
  val x = e1
  val y = e2
}

The principal signature of X is { val x : t1 } instead of the expected {val x : t1; val y : t2 }. This is because principal signature computation for a structure looks for sig f : t declarations. Type elaboration should insert such declarations.

This will require a slight architectural tweak. Currently that portion of the typechecking code assumes that each field declaration in the structure before typechecking gives rise to exactly one field declaration after typechecking (it uses a list of decls for the module and just conses the fields together). Instead we should use a Endo [Decl] Monoid to allow zero or more elaborated declarations.

Reconcile concrete syntax with wiki examples.

At the very least :: vs : in type ascription.

Desugar mixed-model syntax into nested modules.

file:src/Insomnia/SurfaceSyntax/ToAST.hs::– TODO: allow models to contain parameters

model X {
  parameter p = e
  val s ~ e'
}
-- becomes
module X {
  parameter p = e
  model $Model {
    val s ~ e'
  }
}
-- in the rest of the program, references to X as a model now go to X.$Model
-- note that X.s is not legal, so it's only things like sampling from X or observing it.

Translate models to interpreter language

  • CLOSING NOTE [2015-09-18 Fri 11:56]
    (Translating to FOmega instead, and interpreting that.)

file:src/Insomnia/Interp/ToLam.hs::– TODO: translate models

consume type annotations on parsed samples

file:src/Insomnia/SurfaceSyntax/Parse.hs::– TODO: use the type

make a special module for the builtin types

Specifically, “->” ought to live somewhere. file:src/Insomnia/SurfaceSyntax/ToAST.hs::– TODO: these really ought to be imported from somewhere, not built in.

Resurrect infix resolution tests

file:src/Insomnia/SurfaceSyntax/ToAST.hs::– TODO: make infix resolution tests executable again.

Consider explicitly representing scope of Toplevel

file:src/Insomnia/Toplevel.hs::– TODO: worth representing this stuff using Unbound binders?

Share datatype definition

file:src/Insomnia/Typecheck/ClarifySignature.hs::– TODO: share the value constructors of a generative type definition. file:src/Insomnia/Typecheck/ClarifySignature.hs::– TODO: also need to alias the value constructors. Will need a This is probably not too difficult internally now since value constructors are a separate datatype.

Pretty print entire Env in debugging type errors.

file:src/Insomnia/Typecheck/Env.hs::– TODO: the rest of the env

Generalize let-bound values and function declarations.

file:src/Insomnia/Typecheck/Expr.hs::– XXX : TODO generalize uvars, or else freeze ‘em if we’re going to file:src/Insomnia/Typecheck/Module.hs::– XXX TODO: generalize here. Or else decree that

But maybe not. Folk wisdom is that programmers don’t mind putting in type annotations for truly polymorphic local bindings.

The story is dodgier for toplevel bindings, but perhaps it’s okay for these also to require a signature.

Ensure there are no duplicate fields in a module.

file:src/Insomnia/Typecheck/ModuleType.hs::– TODO: actually check that the field names are unique.

Add row polymorphism?

file:src/Insomnia/Types.hs::data Rows = Rows – TODO

Infix syntax

Parse to full application, understand fixity declarations, parse with precedence to disambiguate applications.

Use exact rationals for precedence, not integers!

Tabled declaration for syntax

forall i : t1  in
  f i ~ e i

Analysis to rule out inductive data types.

Unless they turn out to be useful, in which case we will need to understand their semantics.

parsing record pattern matching and explicit braces

case e of
  { f1 = p1, f2 = p2 } -> e

The parser sees the above as an explicitly-delimited pattern list. case e of { pat1 ; pat2 }. So we get a parse error about the leftmost =.

The workaround is to write

case e of
  ({ f1 = p1, f2 = p2 }) -> e

If bare record types (without a datatype wrapped around them) are going to be common, this may get very annoying.

simplify infix operator resolution

Assuming that we can lexically distinguish values, constructors and operators, we should have a better representation of fixity declarations in the ToAST module. file:src/Insomnia/SurfaceSyntax/ToAST.hs::– TODO: this is horrible. rethink how we resolve associativity and precedence. file:src/Insomnia/SurfaceSyntax/ToAST.hs::– TODO: we should handle default fixity in a more principled way.

don’t allow projection of modules out of models

file:src/Insomnia/Typecheck/LookupModuleSigPath.hs::– XXX: Do I really want to allow projection out of models here?

Ideas about syntax

http://ppaml.cs.tufts.edu/Sean%E2%80%99s%20simple%20model%20notation

Abstraction of model

sbs: It would be helpful to separate the model from the query form and from the definitions of the observations.

Example:

– this is a big joint distribution (with some kinda ML-module like – dependent record type) called “T”

dist T is N ∷ ℕ type classes ∷ enum N

  • mu’ ∷ ℝ
  • σ’ ∷ ℝ⁺

M ∷ ℕ type object ∷ enum M class ∷ object → classes awesomeness ∷ object → ℝ mu ∷ classes → ℝ σ ∷ classes → ℝ⁺

the model gives the joint distribution over this type. there might be nuisance variables that noone will condition or query on.

this might be the model type. And we may want to mark μ’ and σ’ distinctly since they will not be exposed from the model type.

This is akin to a ML module.

There is a step here (not yet shown) to turn it into a conditional distribution.

Two observation forms:

observe (P :: T → Bool) :: (Dist T → Dist T)

observe v (where v is a value (of type T?) for some restricted set of types T. Maybe just polynomials of Int and Real)

Actually the idea is more like a type-directed operator “observe τ” where τ is the type of some path into a model. Given by a judgment ⌜T⊢ τ → (a → Dist T → Dist T)⌝.

Signature ascription-like thing to represent which part of a model will be subject to observation.

So the idea is if we have a model M with model type T, then if S is a super-type (dropped components) then something like “observable M S” means that we promise to only observe the S components.