-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHI 9 - Type Variables and Type Aliases #10
base: master
Are you sure you want to change the base?
Conversation
Merges in content from PHI 5 (type variables) with latex judgements for bidirectional type elaboration and kind synthesis/analysis. Will follow up with content from the PHI 3 (type aliases) later.
\begin{minipage}{\linewidth} | ||
\judgbox | ||
{\elabAna{\hPhi}{\htau}{\hkappa_1}{\dtau}{\hkappa_2}{\Delta}} | ||
{$\htau$ analyzes against type $\hkappa_1$ and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should say "kind" not "type"
\newcommand{\kconsistent}[2]{#1 \sim #2} | ||
|
||
\newcommand{\hPhi}{\Phi} | ||
\newcommand{\EmptyhPhi}{\emptyset} % From hand-written notes, Canonical forms lemma; page 14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use \cdot for both
``` | ||
type TPat.t = | ||
| EmptyHole(MetaVar.t) | ||
| TyVar(VarErrStatus.t, TyId.t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need a VarErrStatus here, since we're introducing a binding not consuming it
|
||
So that we can still assign a type properly to the resulting `DExp.t` we add the following new syntax: | ||
|
||
`TyBindings(TyVarCtx.t, DHExp.t)` for abstract syntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this needs to be a tyvarctx -- I think we can just turn each type alias line into a corresponding type alias expression in dhexp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we could avoid having to deal with patterns in DHExp if we did it this way and this will scale if/when type-patterns get more complicated.
I can't think of a way to, in a single DHExp, capture all the possibilities of holes in different places of the UHExp type alias without copying all the rules over (or is this what you're suggesting?)
\begin{minipage}{\linewidth} | ||
\judgbox | ||
{\kconsubkind{\Delta;\hPhi}{\hkappa_1}{\hkappa_2}} | ||
{$\hkappa_1$ is a consistent subkind of $\hkappa_2$} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we need a transitivity rule here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistent subkinding (and subtyping) isn’t transitive. Counter example:
S(Int) <~ ?
? <~ S(Bool)
but this is not true:
S(Int) <~ S(Bool)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, whoops.
Do you need a rule for S(t1) <~ S(t2) where t1 <~ t2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not yet (until polymorphism) because currently:
- S(tau) is only well-formed if tau has kind Ty
- forall types tau_1 and tau_2, tau_1 <~ tau_2 iff tau_1 === tau_2 -- and this is covered by the
KCRespectEquiv
rule
\begin{minipage}{\linewidth} | ||
\judgbox | ||
{\kformation{\Delta;\hPhi}{\hkappa}} | ||
{$\hkappa$ forms a kind} \;\\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need rules for other kind forms
\begin{minipage}{\linewidth} | ||
\judgbox | ||
{\kequiv{\Delta;\hPhi}{\hkappa_1}{\hkappa_2}} | ||
{$\hkappa_1$ is equivalent to $\hkappa_2$} \;\\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need rules for other type forms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused what is you mean by other type forms -- I'm not clear what's missing here
\begin{minipage}{\linewidth} | ||
\judgbox | ||
{\kcequiv{\Delta;\hPhi}{\dtau_1}{\dtau_2}{\hkappa}} | ||
{$\dtau_1$ is equivalent to $\dtau_2$ and has kind $\hkappa_2$} \;\\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^ same as my reply, I'm not sure what's missing
hejohns@8f53339 |
hejohns@4201af8 |
Looks right to me. Why do you think it may be a bug? Yes, T \equiv Int should be derivable in that case. |
I must be missing something. |
https://raw.githubusercontent.com/hejohns/hazel-etc/trunk/9-type-aliases/kind-judgements.ESDefine-simple.pdf https://raw.githubusercontent.com/hejohns/hazel-etc/trunk/9-type-aliases/kind-judgements.ESDefine-weird-knd-ana.pdf https://raw.githubusercontent.com/hejohns/hazel-etc/trunk/9-type-aliases/kind-judgements.KSVar-natural.pdf while the current let type line elaboration-- where the kind synthesized by the definition is added to the context-- seems natural at first, it may not be so. After all, you essentially want to singleton wrap/lift the type definition. Using the synthesized kind only serves this purpose if we define a somewhat unnatural KSVar rule, which definitely works, but rubs me the wrong way. edit: had to be more careful with KSVar-natural. Should probably should go with ESDefine-simple after all. |
https://raw.githubusercontent.com/hejohns/hazel-etc/trunk/9-type-aliases/kind-judgements.subkind.pdf as much as I want to modify KSVar, keeping it and adding this subkinding judgment is more decorous |
I think adding a kind analysis rule for type variables is the right solution. I've attached an annotation with that rule, as well as some other notes to think about for both of you @bkase and @hejohns. We can discuss in OH. |
@cyrus- i think your upload failed, can you retry it? |
https://raw.githubusercontent.com/hejohns/hazel-etc/trunk/9-type-aliases/mphi-9-type-aliases/mphi.pdf |
hazelgrove/hazel@45e180c uses higher-singletons and the |
f6fcfcc
to
4410cd5
Compare
^force push was rollback from accidental push upstream (confused remotes/muscle memory) @bkase , @cyrus- recommended making a new phi for the (wip) system w/ type constructors/Pi/Sigma-kinds, and updating this one to reflect the code as is. https://raw.githubusercontent.com/hejohns/hazel-etc/trunk/9-type-aliases/diff.patch (the full/binary patch; includes pdf) |
Merges in content from PHI 5 (type variables) with latex judgments
for bidirectional type elaboration and kind synthesis/analysis. Will
follow up with content from the PHI 3 (type aliases) later.