An ML-Style Module System for Cross-Stage Type Abstraction in Multi-stage Programming

We propose MetaFM, a novel ML-style module system that enables users to decompose multi-stage programs (i.e., programs written in a typed multi-stage programming language) into loosely coupled components in a manner natural with respect to type abstraction. The distinctive aspect of MetaFM is that i...

Full description

Saved in:
Bibliographic Details
Published inFunctional and Logic Programming pp. 237 - 272
Main Authors Suwa, Takashi, Igarashi, Atsushi
Format Book Chapter
LanguageEnglish
Published Singapore Springer Nature Singapore 2024
SeriesLecture Notes in Computer Science
Subjects
Online AccessGet full text
ISBN9819722993
9789819722990
ISSN0302-9743
1611-3349
1611-3349
DOI10.1007/978-981-97-2300-3_13

Cover

Abstract We propose MetaFM, a novel ML-style module system that enables users to decompose multi-stage programs (i.e., programs written in a typed multi-stage programming language) into loosely coupled components in a manner natural with respect to type abstraction. The distinctive aspect of MetaFM is that it allows values at different stages to be bound in a single structure (i.e., struct⋯end $$ \textbf{struct} \ \cdots \ \textbf{end} $$ ). This feature is crucial, for example, for defining a function and a macro that use one abstract type in common, without revealing the implementation detail of that type. MetaFM also accommodates functors, higher-kinded types, the withtype $$\textbf{with} \ \textbf{type} $$ -construct, etc. with staging features. For defining semantics and proving type safety, we employ an elaboration technique, i.e., type-directed translation to a target language, inspired by the formalization of F-ing Modules. Specifically, we give a set of elaboration rules for converting MetaFM programs into System Fω⟨⟩ $$\omega ^{\langle \rangle }$$ , a multi-stage extension of System Fω $$\omega $$ , and prove that the elaboration preserves typing. Additionally, our language supports cross-stage persistence (CSP), a feature for code reuse spanning more than one stage, without breaking type safety.
AbstractList We propose MetaFM, a novel ML-style module system that enables users to decompose multi-stage programs (i.e., programs written in a typed multi-stage programming language) into loosely coupled components in a manner natural with respect to type abstraction. The distinctive aspect of MetaFM is that it allows values at different stages to be bound in a single structure (i.e., struct⋯end $$ \textbf{struct} \ \cdots \ \textbf{end} $$ ). This feature is crucial, for example, for defining a function and a macro that use one abstract type in common, without revealing the implementation detail of that type. MetaFM also accommodates functors, higher-kinded types, the withtype $$\textbf{with} \ \textbf{type} $$ -construct, etc. with staging features. For defining semantics and proving type safety, we employ an elaboration technique, i.e., type-directed translation to a target language, inspired by the formalization of F-ing Modules. Specifically, we give a set of elaboration rules for converting MetaFM programs into System Fω⟨⟩ $$\omega ^{\langle \rangle }$$ , a multi-stage extension of System Fω $$\omega $$ , and prove that the elaboration preserves typing. Additionally, our language supports cross-stage persistence (CSP), a feature for code reuse spanning more than one stage, without breaking type safety.
Author Igarashi, Atsushi
Suwa, Takashi
Author_xml – sequence: 1
  givenname: Takashi
  orcidid: 0009-0004-9845-7419
  surname: Suwa
  fullname: Suwa, Takashi
  email: tsuwa@fos.kuis.kyoto-u.ac.jp
– sequence: 2
  givenname: Atsushi
  orcidid: 0000-0002-5143-9764
  surname: Igarashi
  fullname: Igarashi, Atsushi
BookMark eNp9kEtOwzAURc1Poi3dAYNswPBsx409rCp-UiuQWsTQchonCiR2ZadC2U3X0pXhUMaMrnTfPW9wxujSOmsQuiVwRwCye5kJLAXBMsOUAWCmCDtD01jHVmZDx87RiMwIwYyl8gKNTwcqJbtEI2BAI5yyazQN4RPinBKQMhuhj7lNVku87vrGJCtX7GOs-9CZNimdPx4W3oUQz7oyyabfmWSeh87rbVc7m9T2eFjtm67G4Xfw5l3lddvWtrpBV6Vugpn-5QS9Pz5sFs94-fr0spgvcZ4S2mFNyqLgTAtJDWx1SkVKZcm5znlOcsiAFikXM-A5L2UJJEvNTJeCGEEKvqXAJoif_u7tTvffumnUztet9r0ioAZ7KmpSUUdMNZhSg73I0RMX4txWxqvcua_wP_QDRnZwWw
ContentType Book Chapter
Copyright The Author(s) 2024, Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.The images or other third party material in this chapter are included in the chapter’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Copyright_xml – notice: The Author(s) 2024, Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.The images or other third party material in this chapter are included in the chapter’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
DBID AAQKC
ABOKW
UNPAY
DOI 10.1007/978-981-97-2300-3_13
DatabaseName SpringerLink Fully Open Access Books
Unpaywall for CDI: Monographs and Miscellaneous Content
Unpaywall
DatabaseTitleList
Database_xml – sequence: 1
  dbid: AAQKC
  name: SpringerLink Fully Open Access Books
  url: https://link.springer.com
  sourceTypes: Publisher
– sequence: 2
  dbid: UNPAY
  name: Unpaywall
  url: https://proxy.k.utb.cz/login?url=https://unpaywall.org/
  sourceTypes: Open Access Repository
DeliveryMethod fulltext_linktorsrc
Discipline Computer Science
EISBN 9789819723003
9819723000
EISSN 1611-3349
Editor Gibbons, Jeremy
Miller, Dale
Editor_xml – sequence: 1
  givenname: Jeremy
  orcidid: 0000-0002-8426-9917
  surname: Gibbons
  fullname: Gibbons, Jeremy
– sequence: 2
  givenname: Dale
  orcidid: 0000-0003-0274-4954
  surname: Miller
  fullname: Miller, Dale
EndPage 272
ExternalDocumentID 10.1007/978-981-97-2300-3_13
GroupedDBID 38.
AABBV
AACKP
AAHEH
AAQKC
ABHYI
ABLGM
ADCIB
ADZDO
AEDXK
AEIVC
AEKFX
ALMA_UNASSIGNED_HOLDINGS
BBABE
CZZ
IEZ
SBO
TPJZQ
TSXQS
Z5O
Z7R
Z7S
Z7U
Z7W
Z7X
Z7Y
Z7Z
Z81
Z83
Z84
Z85
Z87
Z88
-DT
-GH
-~X
1SB
29L
2HA
2HV
5QI
875
AASHB
ABMNI
ABOKW
ACGFS
ADCXD
AEFIE
EJD
F5P
FEDTE
HVGLF
LAS
LDH
P2P
RNI
RSU
SVGTG
UNPAY
VI1
~02
ID FETCH-LOGICAL-b412t-a1fdd53a892e0ca428429f55ab5b1b0702d458605b5f9f0174e6af81e81d5c203
IEDL.DBID UNPAY
ISBN 9819722993
9789819722990
ISSN 0302-9743
1611-3349
IngestDate Sun Sep 07 11:16:50 EDT 2025
Tue Jul 29 20:11:46 EDT 2025
IsDoiOpenAccess true
IsOpenAccess true
IsPeerReviewed true
IsScholarly true
Language English
License cc-by
LinkModel DirectLink
MergedId FETCHMERGED-LOGICAL-b412t-a1fdd53a892e0ca428429f55ab5b1b0702d458605b5f9f0174e6af81e81d5c203
Notes Original Abstract: We propose MetaFM, a novel ML-style module system that enables users to decompose multi-stage programs (i.e., programs written in a typed multi-stage programming language) into loosely coupled components in a manner natural with respect to type abstraction. The distinctive aspect of MetaFM is that it allows values at different stages to be bound in a single structure (i.e., struct⋯end\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$ \textbf{struct} \ \cdots \ \textbf{end} $$\end{document}). This feature is crucial, for example, for defining a function and a macro that use one abstract type in common, without revealing the implementation detail of that type. MetaFM also accommodates functors, higher-kinded types, the withtype\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{with} \ \textbf{type} $$\end{document}-construct, etc. with staging features. For defining semantics and proving type safety, we employ an elaboration technique, i.e., type-directed translation to a target language, inspired by the formalization of F-ing Modules. Specifically, we give a set of elaboration rules for converting MetaFM programs into System Fω⟨⟩\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega ^{\langle \rangle }$$\end{document}, a multi-stage extension of System Fω\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega $$\end{document}, and prove that the elaboration preserves typing. Additionally, our language supports cross-stage persistence (CSP), a feature for code reuse spanning more than one stage, without breaking type safety.
ORCID 0009-0004-9845-7419
0000-0002-5143-9764
OpenAccessLink https://proxy.k.utb.cz/login?url=https://doi.org/10.1007/978-981-97-2300-3_13
PageCount 36
ParticipantIDs unpaywall_primary_10_1007_978_981_97_2300_3_13
springer_books_10_1007_978_981_97_2300_3_13
PublicationCentury 2000
PublicationDate 2024
PublicationDateYYYYMMDD 2024-01-01
PublicationDate_xml – year: 2024
  text: 2024
PublicationDecade 2020
PublicationPlace Singapore
PublicationPlace_xml – name: Singapore
PublicationSeriesTitle Lecture Notes in Computer Science
PublicationSeriesTitleAlternate Lect.Notes Computer
PublicationSubtitle 17th International Symposium, FLOPS 2024, Kumamoto, Japan, May 15–17, 2024, Proceedings
PublicationTitle Functional and Logic Programming
PublicationYear 2024
Publisher Springer Nature Singapore
Publisher_xml – name: Springer Nature Singapore
RelatedPersons Hartmanis, Juris
Gao, Wen
Steffen, Bernhard
Bertino, Elisa
Goos, Gerhard
Yung, Moti
RelatedPersons_xml – sequence: 1
  givenname: Gerhard
  surname: Goos
  fullname: Goos, Gerhard
– sequence: 2
  givenname: Juris
  surname: Hartmanis
  fullname: Hartmanis, Juris
– sequence: 3
  givenname: Elisa
  surname: Bertino
  fullname: Bertino, Elisa
– sequence: 4
  givenname: Wen
  surname: Gao
  fullname: Gao, Wen
– sequence: 5
  givenname: Bernhard
  orcidid: 0000-0001-9619-1558
  surname: Steffen
  fullname: Steffen, Bernhard
– sequence: 6
  givenname: Moti
  orcidid: 0000-0003-0848-0873
  surname: Yung
  fullname: Yung, Moti
SSID ssj0003210997
ssj0002792
Score 2.1090667
Snippet We propose MetaFM, a novel ML-style module system that enables users to decompose multi-stage programs (i.e., programs written in a typed multi-stage...
SourceID unpaywall
springer
SourceType Open Access Repository
Publisher
StartPage 237
SubjectTerms Code generation
Macros
Module systems
Staging
SummonAdditionalLinks – databaseName: SpringerLink Fully Open Access Books
  dbid: AAQKC
  link: http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwlV1La8MwDDalPexx2Jt1L3zYbbjETpzEx1BWyraOja2st2AnNox1aVlTRv9Nf0t_2eSkCT2MwU4mJFGCYkv65HwSQtdS2Sr7hpNE-4p4lAoiAscQmghNlZ9CFGyB4uDR7w-9uxEfNRCvUxfZR6fakSwMdcV1s2hHhBQkEYiawXbEtldtiwWhD5O5FUXP993aBNuqeHWmxbJURNFlBSY0AwGeW1beAXEiYNYeA1yrD9wNgt1vD93YMt1BW_NsKhffcjze8Eq9fbRrmQrYUghAOweoobNDtFf1acDrZXuE3qIMDx7IS74YazyYpHMYykrlGELW1bJrPSWcBtOCLS7FkbIJkILxgN-z1bJg6ZJZccFT-UPXJ7zaMRr2bl-7fbJuqECUR1lOJDVpyl0ZCqadRALyAG9kOIcPpqiCxc9Sj4cAcBQ3wsBa9bQvTUg1BLU8YY57gprZJNOnCIfg1TxunMSRgecnNAwB7BpJU5Boi9i30U2lpdjChVlc1UcGncagUxhjq9PY6rSNOrUi42lZZuPPG87-Jf4cbTOIRcrMyQVq5l9zfQmxRK6u1jPnB96Qt-0
  priority: 102
  providerName: Springer Nature
Title An ML-Style Module System for Cross-Stage Type Abstraction in Multi-stage Programming
URI http://link.springer.com/10.1007/978-981-97-2300-3_13
https://doi.org/10.1007/978-981-97-2300-3_13
UnpaywallVersion publishedVersion
hasFullText 1
inHoldings 1
isFullTextHit
isPrint
link http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwlV1fS8MwED_G9iD6MP_iREcefNOMpmu69rEMx1A3JjrUp5K0CYizG65F5qfZZ9kn87KuMoaIPuWhyZFemvvTu_sdwLmQBmVfcxopV1KHMZ_6LUtTFvmKSTdGK9g4ir2-2x0610_8qQSXRS3MRvx-CQDrewwJUDSWUWSEpkVtxeVoeZehMuwPguc8UGDjnDyf3jXIfE3HX6uU-4nMWuxzG7ayZCJmH2I0WlMvnSr0io3lWSWvjSyVjehzA7PxrzvfhR1TwkBMbQGybQ9KKtmHatHAgazu8wE8Bgnp3dL7dDZSpDeOMxxyCHOCtuxi3jYqFB-jzCHGYSWBNH9GlqUQ5CVZzJflu3S6nDDIM73e8FUPYdi5emh36arTApUOs1MqmI5j3hSebysrEuiSoJrSnONJSiZRKtixwz30fCTXvsZL7ChXaI8ptHZ5ZFvNIygn40QdA_FQ3TlcW5ElWo4bMc9DL1gLFiNFg25fg4uC66HxI6ZhAZyMDAuRYTiGhmGhYVgNGt8HE05y_I1fF5z8d8EplNP3TJ2haZHKOlSC4O6mXV99WV-fFsQs
linkProvider Unpaywall
linkToHtml http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwlV1La8MwDBalPXTbYW_WPX3YbXjEqZ0mx1BWuvXBxlq2W7ATGwZdWtaW0X_T39JfNjlpSg9jsJMJSRSj2JI-258EcCuVzbJvBI21pyhnLKBBwzGUxYFmykswCrZAsdf32kP-9C7eS-AVXJjstHuxJZlZ6oLsZuFO4DMURTFsRuMR2WK1Fc4QiJehEoYvnebGBtu0eJulFktTCbIyKziiXRTA63nqHRQXNFxrkBGvbS7qWwy73z66tWe6C9V5OpGLbzkabbml1gHsWaoCsRwCVM8hlHR6BPtFoQaynrfH8BampNelr7PFSJPeOJljk6cqJxizrpZN6yrxNtoWYoEpCZVdAckoD-QjXS0zmi6dZg885ye6PrFrJzBsPQyabbquqEAVZ-6MSmaSRNSlH7jaiSVCD3RHRgj8Y4opnP1uwoWPCEcJExicrFx70vhMY1QrYtepn0I5Haf6DIiPbo0L48SObHAvZr6PaNdIlqBEm8W-BneFliKLF6ZRkSAZdRqhTrGNrE4jq9Ma3G8UGU3yPBt_vnD-L_E3UG0Pet2o-9jvXMCOi4FJvoxyCeXZ11xfYWAxU9frUfQDtKC7Pg
linkToPdf http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwlV1bS8MwFA6ygbcH7zivefBNok3XdO1jmY7pLkx0uLeStAkIsxuuQ_Zv9lv2yzynXcceRPAplLan4TQ5lyTfdwi5kQpZ9o1gkXYVczj3mV-zDOORr7lyY4iCMVHsdN1m33keiMEaFiY77V5sSeaYBmRpStL7cWyKXf2MFtb3OIhlEEKDIQmxcG0ZUZx2iZSD4KVVX9ljpMhbLbsgZMXPSq7A6LZBgFPNaXhAnF-z0ThD7ra6qK6h7X776Nr-6Q7ZmiZjOfuWw-Gai2rsk12ELVDEE4CqDsiGTg7JXlG0gS7n8BF5DxLaabPXdDbUtDOKp9DktOUU4tfFvI5uE26DnaGYpNJA4WpIBn-gH8linkF22SR7oJef7vqErh2TfuPxrd5ky-oKTDncTpnkJo5FVXq-ra1IQhoCrskIAX9PcQWWwI4d4UG2o4TxDUxcR7vSeFxDhCsi26qekFIySvQpoR64OEcYK7JkzXEj7nmQ-RrJY5CIjPYVcltoKcTcYRIWZMmg0xB0Cm2IOg1RpxVyt1JkOM45N_584exf4q_JZu-hEbafuq1zsm1DjJKvqFyQUvo11ZcQY6TqajmIfgBrzr-D
linkToUnpaywall http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwlV1fS8MwED_G9iD6MP_iRCUPvmlG0zVd-ziGY4gdAx3Op5K0CYizG65F5qfZZ9kn89KuMoaIPuWhyZFemvvTu_sdwJWQBmVfcxopV1KHMZ_6bUtTFvmKSTdGK9g4isHA7Y-cuzEfV-CmrIXZit_nALC-x5AARWMZRUZoWtTWXI6WdxVqo8Gw81wECmycU-TTuwaZr-X4G5VyP5HZiH3uwk6WzMTiQ0wmG-qlV4eg3FiRVfLazFLZjD63MBv_uvN92DMlDMTUFiDbDqCikkOolw0cyPo-H8FTJyHBPX1IFxNFgmmc4VBAmBO0ZVfLrlGh-BhlDjEOK-lI82ckL4UgL8lqmZfv0nk-YVhker3hqx7DqHf72O3TdacFKh1mp1QwHce8JTzfVlYk0CVBNaU5x5OUTKJUsGOHe-j5SK59jZfYUa7QHlNo7fLItlonUE2miToF4qG6c7i2Iku0HTdinodesBYsRooG3b4B1yXXQ-NHzMMSOBkZFiLDcAwNw0LDsAY0vw8mnBX4G78uOPvvgnOopu-ZukDTIpWX6y_qC4W5wqg
openUrl ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fsummon.serialssolutions.com&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.title=Functional+and+Logic+Programming&rft.au=Suwa%2C+Takashi&rft.au=Igarashi%2C+Atsushi&rft.atitle=An+ML-Style+Module+System+for%C2%A0Cross-Stage+Type+Abstraction+in%C2%A0Multi-stage+Programming&rft.series=Lecture+Notes+in+Computer+Science&rft.date=2024-01-01&rft.pub=Springer+Nature+Singapore&rft.isbn=9789819723003&rft.issn=0302-9743&rft.eissn=1611-3349&rft.spage=237&rft.epage=272&rft_id=info:doi/10.1007%2F978-981-97-2300-3_13
thumbnail_l http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/lc.gif&issn=0302-9743&client=summon
thumbnail_m http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/mc.gif&issn=0302-9743&client=summon
thumbnail_s http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/sc.gif&issn=0302-9743&client=summon