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
Currently, we have a few type definintions in construct.ml:
let answerT = T.unit
let contT typ = T.Func (T.Local, T.Returns, [], T.as_seq typ, [])
let err_contT = T.Func (T.Local, T.Returns, [], [T.catch], [])
let cpsT typ = T.Func (T.Local, T.Returns, [], [contT typ; err_contT], [])
some of which are just manully parsed copies of the same types in internals.mo:
type @Cont<T> = T -> () ;
type @Async<T> = (@Cont<T>,@Cont<Error>) -> ();
The point of internals.mo is to define values and types for internal use, and for values that works nicely. It would be more ergonomic (for us) if IR passes (e.g. async.ml) would could somehow just these types without duplicating them manually.
This is harder than for values because values are still bound at the IR stage, while type definitions just float around.
Maybe the pipeline somehow has to pass the initial_stat_env (or portions from it – maybe just the @-prefixed type definitions) to the IR code?
This came up in the context of #2348, where I wasn’t looking forward to replica
let typRepT =
let open T in
let c = Con.fresh "TypRep" (Abs ([], Pre)) in
let t = Con (c, []) in
let rhs =
Variant [
{ lab = "bool"; typ = T.unit; depr = None };
{ lab = "int"; typ = T.unit; depr = None };
…
{ lab = "tup"; typ = T.Array t; depr = None }
…
] in
set_kind c (Def ([], rhs));
t
(although maybe it’s not that bad, our IR type checker would catch mistakes.)
The text was updated successfully, but these errors were encountered:
nomeata
changed the title
(IR-Internals) Somehow expose type definitions in internals.mo to IR passes
(IR-Internals) Expose type defs internals.mo to IR passes
Mar 9, 2021
The types in construct.ml that you mention actually have some (dodgy) inbuilt flattening, so they are not really the same as the prelude defined, unary ones.
Defining this (although kinda large) type twice (once in internals.mo and once in construct.ml) isn’t too bad after all, and the type checker keeps us honest. So not a high priority here.
Currently, we have a few type definintions in
construct.ml
:some of which are just manully parsed copies of the same types in
internals.mo
:The point of
internals.mo
is to define values and types for internal use, and for values that works nicely. It would be more ergonomic (for us) if IR passes (e.g.async.ml
) would could somehow just these types without duplicating them manually.This is harder than for values because values are still bound at the IR stage, while type definitions just float around.
Maybe the pipeline somehow has to pass the
initial_stat_env
(or portions from it – maybe just the@
-prefixed type definitions) to the IR code?This came up in the context of #2348, where I wasn’t looking forward to replica
by writing
(although maybe it’s not that bad, our IR type checker would catch mistakes.)
The text was updated successfully, but these errors were encountered: