{ "info": { "author": "Maksim Yegorov", "author_email": "findmaksim@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Software Development :: Build Tools" ], "description": "# What\n\nSML compilers, such as [MLton](http://mlton.org/MLBasis) and\n[SML/NJ](http://www.smlnj.org/doc/CM/new.pdf), are designed to\nrelieve the programmer to a large extent from managing the dependency\ngraph of individual source files, beyond specifying the imports and\nexports, typically for a group of source files constituting a library\ncomponent.\n\nDepending on one's workflow and the project's complexity,\nthe cognitive load on the programmer may in fact be minimized by\nkeeping the import and export statements within the context of\nthe module where they apply. In this approach, the link between the\ndeclarations and their uses is made explicit. This enforces a certain\ndiscipline by limiting the unintentional snowballing of names in scope. \nIn addition, one can incrementally type check the program one file at a time,\nperhaps as a background process,\nas suggested in https://sourceforge.net/p/mlton/mailman/message/31513087/\n\nThe goal is to develop a proof of concept for a transpiler step added to\nan [MLBasis](http://mlton.org/MLBasis) based compilation workflow and test \nit on a non-trivial SML project. It should be emphasized\nthat no changes are planned to how MLBasis manages the namespaces\nbehind the scenes. A subset of \n[MLBasis](http://mlton.org/MLBasisSyntaxAndSemantics) constructs\nwill be supported (excluding `ann`).\n\n\n# Use case\n\nThe `transmile` utility may be invoked as in the following\n`Makefile` target:\n```shell\nSML=mlton\n\n.PHONY: foo\nfoo: src/foo.smlb\n\ttransmile src --out dist --skip README --copy-files\n\t$(SML) -stop tc ./dist/foo.sml.mlb\n```\n\nThe `transmile` commandline utility (here assumed to be on the shell\nsearch path) will pick up any `*.smlb`,\n`*.sigb` or `*.funb` files in the `src` directory and transpile them into a \nset of `*.sml`, `*.sig`, or `*.fun` files in the `dist` directory, each\nwith a corresponding `*.mlb` MLBasis file.\nWith the above flags, it will also copy any files that it\ndidn't transpile, with the exception of explicitly excluded files.\n\n`import` and `export` statements in a `*b` source file must come before any\nSML program, except that SML-style comments (and line directives) are \nallowed within the import/export block.\n\nThe syntax for importing entities is any combination of:\n```\nimport $(SML_LIB)/basis/basis-1997.mlb\nimport \"/path/to/moduleA.sigb\"\nimport (functor X, structure Z = Y) from \"../path/to/moduleB.funb\"\n```\n\nBy default, every module will implicitly import the SML Basis library\n(`$(SML_LIB)/basis/basis.mlb`), except where overriden by any explicit\n`import $(SML_LIB)/...` directive as in the above example.\n\n`transmile` will try to resolve any path (except any path from the\n`$(SML_LIB)` root) in this order:\n* searching the directory relative to the `*b` source file (except\n where an absolute path is specified);\n* followed by the environment variable `SMLPATH` (set to, e.g.,\n `/src:/sml-modules` in the `Makefile`);\n* followed by any installation-dependent default search path (shell `PATH`).\n\nFor example, resolving `import X.sigb` entails looking up `./X.sig.mlb`,\nthen `<($SMLPATH)>/X.sig.mlb`, then `<($PATH)>/X.sig.mlb`, and returning with\nan error if none is found.\n\nAssuming the above import statements are placed in an `example.smlb`, \nand that all the referenced `*.mlb` files can be found relative to the\nlocation of `example.smlb`,\nthe outcome will be an `example.sml` file with the SML program, plus\nan `example.sml.mlb` file:\n\n```sml\nlocal\n basis a = bas (*#line 1.8 \"example.smlb\"*)$(SML_LIB)/basis/basis-1997.mlb end\n basis b = bas (*#line 2.8 \"example.smlb\"*)\"/path/to/moduleA.sig.mlb\" end\n basis c =\n let\n (*#line 3.42 \"example.smlb\"*)\"../path/to/moduleB.fun.mlb\"\n in\n bas\n (*#line 3.9 \"example.smlb\"*)functor X\n (*#line 3.20 \"example.smlb\"*)structure Z = Y\n end\n end\n\n open a b c\n\nin\n example.sml\nend\n```\n\nThe syntax for exporting entities is along the lines of:\n```\nexport (signature K, structure M = L)\n%% (* for the time being signals the end of import/export block *)\n```\n\nAssuming this `export` statement follows the `import` statements in the\nabove `example.smlb`, the resulting `example.sml.mlb`\nwill contain:\n\n```sml\nlocal\n local\n basis a = bas (*#line 1.8 \"example.smlb\"*)$(SML_LIB)/basis/basis-1997.mlb end\n basis b = bas (*#line 2.8 \"example.smlb\"*)\"/path/to/moduleA.sig.mlb\" end\n basis c =\n let\n (*#line 3.42 \"example.smlb\"*)\"../path/to/moduleB.fun.mlb\"\n in\n bas\n (*#line 3.9 \"example.smlb\"*)functor X\n (*#line 3.20 \"example.smlb\"*)structure Z = Y\n end\n end\n\n open a b c\n in\n example.sml\n end\n\nin\n (*#line 4.9 \"example.smlb\"*)signature K\n (*#line 4.22 \"example.smlb\"*)structure M = L\nend\n```\n\nIf an `export` statement were missing from `example.smlb`, the module\nwould effectively export all its top-level identifiers.\n\n# Installation\n\nCurrently requires Python 3. (I plan to rewrite the transpiler in SML.)\n\nClone the repository and run `python transmile.py` to display the\nusage message, or alternatively install with `pip`:\n\n```shell\npip install transmler\ntransmile\n```\n\nSee `./example/` for an extended example.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/myegorov/transmler", "keywords": "transpiler sml mlton import export", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "transmler", "package_url": "https://pypi.org/project/transmler/", "platform": "", "project_url": "https://pypi.org/project/transmler/", "project_urls": { "Homepage": "https://github.com/myegorov/transmler" }, "release_url": "https://pypi.org/project/transmler/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "syntactic sugar for MLBasis files", "version": "0.3.1" }, "last_serial": 3339935, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "8db977d8a5db464510e4b637c1c3d970", "sha256": "b9d6f53543ecff6bf329541d44ea9d51665677b90472243eccd179da40f4320e" }, "downloads": -1, "filename": "transmler-0.3.tar.gz", "has_sig": false, "md5_digest": "8db977d8a5db464510e4b637c1c3d970", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12716, "upload_time": "2017-11-16T18:16:40", "url": "https://files.pythonhosted.org/packages/d0/1f/18c5a30067d7e17245e024802df081ee189d921ab6b3b963122f7a3bbc28/transmler-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "0e67f1c5b89a9d0e4ddeb24a4dc9639e", "sha256": "5c5f699639e9504f406c43361555a4230c73a8dc9687b7b8b4c7f2747756b671" }, "downloads": -1, "filename": "transmler-0.3.1.tar.gz", "has_sig": false, "md5_digest": "0e67f1c5b89a9d0e4ddeb24a4dc9639e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12746, "upload_time": "2017-11-16T22:09:34", "url": "https://files.pythonhosted.org/packages/6a/a8/da3e7c23ac1a383eb1d1461fbb67f1352003d0db9ed09ba8579ca56d2a93/transmler-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0e67f1c5b89a9d0e4ddeb24a4dc9639e", "sha256": "5c5f699639e9504f406c43361555a4230c73a8dc9687b7b8b4c7f2747756b671" }, "downloads": -1, "filename": "transmler-0.3.1.tar.gz", "has_sig": false, "md5_digest": "0e67f1c5b89a9d0e4ddeb24a4dc9639e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12746, "upload_time": "2017-11-16T22:09:34", "url": "https://files.pythonhosted.org/packages/6a/a8/da3e7c23ac1a383eb1d1461fbb67f1352003d0db9ed09ba8579ca56d2a93/transmler-0.3.1.tar.gz" } ] }