Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006378OCamlOCaml typingpublic2014-04-23 11:132014-06-04 21:54
Reporterfrisch 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006378: Type-checking hooks
DescriptionSeveral useful meta-programming tasks require to access the type-checking environment (and/or the "expected type"). I propose to add hooks to the type-checker in order to enable such use cases. The hooks would be available in the compiler-libs, so people could tweak the type-checker by creating custom compiler drivers (or create a generic driver which can dynamically load plugins).

Hooks could look like:

val type_expression: (Env.t -> type_expr -> Parsetree.expression -> Parsetree.expression) ref
val type_pattern: (Env.t -> type_expr -> Parsetree.pattern -> Parsetree.pattern) ref
...

Note that hooks return parsetree fragments which are then type-checked normally. The "contract" should be that the hooks only inspect the expected type and environment, but does not do any side effect with them (unification). (A safer approach would be to pass opaque objects to the hooks with a restricted API to inspect them, but this is a lot more work.)

Typical uses of hooks would be to expand extension nodes or to implement features such as autofocusing (0005667).

I think OCamlPro proposed something similar (OCaml Templates).
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2014-04-23 11:13 frisch New Issue
2014-06-04 21:54 doligez Status new => acknowledged


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker