This tool was implemented as part of a bachelor thesis (by Malte Clement at Kiel University) and should be considered as an alpha version of a prototype.
- Haskell to Haskell Transformation Tool
- Directory Structure
- Getting Started
- Usage
- Get Involved
- License
This is a tool to translate different language features of Haskell into simpler expressions.
-
It translates pattern matching on left-hand sides into explicit pattern matching on right-hand sides using Wadler's algorithm for compiling pattern matching.
-
Guards are transformed into
case
expressions using their semantics as described in the Haskell report. -
Partially defined functions are completed by inserting alternatives whose right-hand side is
undefined
such that pattern matching failures are handled explicitly.
The repository is structured as follows.
-
src
contains the source code of the project.src/exe
contains modules for the command line interface.src/lib
contains modules for the code transformation library.src/test
contains modules that have been translated to test certain features.
-
example
contains some examples that have been transformed by hand using Wadler's algorithm.
Additionally, it contains some special examples that were used to test the Free Compiler. -
tool
contains Bash scripts that are used during development and for testing.
The tool is written in Haskell and uses Cabal to manage the dependencies. To build it, the GHC and Cabal are required. The tool has been tested with the following software versions.
In order to install the command line interface, navigate to the root directory of the project and run the following command.
cabal new-install exe:haskell-src-transformations
The command above builds the executable pattern matching compiler's command line interface and creates a symbolic link in ~/.cabal/bin
.
To test whether the installation was successful, make sure the ~/.cabal/bin
is in your PATH
environment variable and run the following command.
haskell-src-transformations --help
If you want to run the command line interface without installing the package on your machine (e.g., for debugging purposes), execute the following command in the root directory of the project instead of using the haskell-src-transformations
executable.
cabal new-run exe:haskell-src-transformations -- [options...] <input-files...>
The two dashes are needed to separate the arguments to pass to the pattern matching compiler from Cabal's arguments.
Alternatively, you can use the ./tool/run.sh
bash script.
./tool/run.sh [options...]
In addition to running the Cabal new-run
command, the script also sets the -Wwarn
flag of the GHC automatically.
This flag ensures that warnings are not reported as errors by GHC which is convenient during development.
In production, there should be no compiler warnings.
Thus, the CI pipeline does not use the ./tool/run.sh
script but tests the compiler with the -Werror
flag set.
The library provided by this package is not yet available on Hackage.
In order to use the Haskell code transformations in your own project, add the following stanza to your cabal.project
file.
source-repository-package
type: git
location: git://github.com/FreeProving/haskell-src-transformations.git
tag: v0.2.0.0
To transform a Haskell module, install the command line interface as described above and run the following command.
haskell-src-transformations -I [InputFile]
Regular, qualified and aliased imports between the input modules are supported. The generated code is printed to the console. If you want to specify the output directory, use the -o
flag.
For more information on the different flags you can use the -h
flag.
Feature requests, enhancement proposals, bug reports, pull requests and all other contributions are welcome!
Have a look at our contributing guidelines for more information on how to contribute.
The Free Compiler is licensed under The 3-Clause BSD License.
See the LICENSE file for details.