Abstract:Recent work on embedding object languages into Haskell use "phantom types" (i.e., parameterized types whose parameter does not occur on the right-hand side of the type definition) to ensure that the embedded object-language terms are simply typed. But is it a safe assumption that only simply-typed terms can be represented in Haskell using phantom types? And conversely, can all simply-typed terms be represented in Haskell under the restrictions imposed by phantom types? In this article we investigate the condit… Show more
“…It might not be clear why an embedded interpreted language could be useful to an application written in ML. After all, languages like ML and Haskell usually have top-level interactive loops, and there are well-studied techniques for expressing embedded-language terms as Haskell terms (Leijen & Meijer, 2000;Rhiger, 2003), so why not just use ML or Haskell? Why have a scripting language?…”
Section: Embedded Scripting For Functional Programsmentioning
Using an embedded, interpreted language to control a complicated application can have significant software-engineering benefits. But existing interpreters are designed for embedding into C code. To embed an interpreter into a different language requires an API suited to that language. This paper presents Lua-ML, a new API that is suited to languages that provide higher-order functions and types. The API exploits higher-order functions and types to reduce the amount of glue code needed to use an embedded interpreter. Where embedding in C requires a special-purpose "glue function" for every function to be embedded, embedding in Lua-ML requires only a description of each function's type. Lua-ML also makes it easy to define a Lua function whose behavior depends on the number and types of its arguments.
“…It might not be clear why an embedded interpreted language could be useful to an application written in ML. After all, languages like ML and Haskell usually have top-level interactive loops, and there are well-studied techniques for expressing embedded-language terms as Haskell terms (Leijen & Meijer, 2000;Rhiger, 2003), so why not just use ML or Haskell? Why have a scripting language?…”
Section: Embedded Scripting For Functional Programsmentioning
Using an embedded, interpreted language to control a complicated application can have significant software-engineering benefits. But existing interpreters are designed for embedding into C code. To embed an interpreter into a different language requires an API suited to that language. This paper presents Lua-ML, a new API that is suited to languages that provide higher-order functions and types. The API exploits higher-order functions and types to reduce the amount of glue code needed to use an embedded interpreter. Where embedding in C requires a special-purpose "glue function" for every function to be embedded, embedding in Lua-ML requires only a description of each function's type. Lua-ML also makes it easy to define a Lua function whose behavior depends on the number and types of its arguments.
“…When dynamic linking is used for the plugging, the plug-in's functions are registered in a global table in the kernel at load-time. Because all functions do not have the same ML type, phantom types (Rhiger 2003) are used in order to dynamically ensure the program's safety (see Section 4.6). Dynamic linking solves two out of three issues of static linking: it ceases to be necessary for the kernel to be aware of the types of all plug-ins' exported functions, and it becomes more convenient to distribute a plug-in separately from Frama-C (in particular a plugin no longer needs to patch the kernel).…”
Section: Dynamic Loading Of Plug-insmentioning
confidence: 99%
“…Both dynamic loading and journalization rely on phantom types (Rhiger 2003). Phantom types -parameterized types which employ their type variables for encoding meta-information -are used in both cases to ensure the dynamic safety of function calls which cannot be checked by the OCaml type system.…”
Section: Phantom Types For Dynamic Typing In a Static Settingmentioning
This experience report describes the choice of OCaml as the implementation language for Frama-C, a framework for the static analysis of C programs. OCaml became the implementation language for Frama-C because it is expressive. Most of the reasons listed in the remaining of this article are secondary reasons, features which are not specific to OCaml (modularity, availability of a C parser, control over the use of resources. . . ) but could have prevented the use of OCaml for this project if they had been missing.
“…Typechecking object programs can thus be regarded as an orthogonal problem, solved by entirely standard methods. (In cases where object programs are less dynamic and the embedding is shallower, techniques such as phantom types (Rhiger, 2003) can leverage the metalanguage type system to reject ill-typed object programs at compile-time. )…”
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.