Define datatypes once, get polyglot results
README.md

DataTypeTool #

Describe datatypes in one or more ".type" file, then create appropriate datatypes for (eventually) any language.

Still a work-in-progress, but there's (very early) results! This is open to collaboration, so if you would like to see {{insert_language+version_here}} faster than I can get around to it, feel free to take a swing at it. Once we get to a more feature-complete state and actually make this open to distribution, I'll keep track of actual changes with a CHANGELOG.md and versioning.

Inside exampleProject/ (an example project root directory), there's a datatypetool.toml file. There are also test .type files inside exampleProject/types/. Some basic language scripts are there to do basic testing on types generated from exampleProject/types/Test_File.type, based on the JSON in exampleProject/test.json

There's also some basic (and hopefully undestandable) documentation in docs/.

More languages and functionality to come soon!

What you need to use this, at the moment: #

  • Nix is probably a good idea, then you can use what's in the nix-shell.
  • Just is optional, but very helpful. Also in the nix-shell if you get in there.
    • I will be referencing this project's just commands here, so if you omit this, you may need to look inside the justfile to run each command-suite individually.
  • If non-nix, GHC: 9.8.2, HLS: 2.7.0.0, cabal 3.10.2.1 from GHCup is what I have locally. Cabal will fetch the dependencies when it builds.
  • Do regular git-clone+cd stuff, then:
    • just shell (aka nix-shell --pure --show-trace)
    • just run --toml exampleProject/datatypetool.toml (to generate files based on whats in exampleProject/types/)
    • just format (to format files for keeping things tidy)
    • just with no arguments or just help will list the available commands. Right now there's only 4, and this runs one of them. The other three are listed above.
    • Language based stuff (Toml configs, language writers, etc.) are found in app/Lang/. Just follow whats there, keep things organized.
    • *.type file parser stuff is found in app/Parsing/
    • datatypetool.toml parser stuff is found in app/Config, except dedicated language settings, which are found in app/Lang/**/{{Config / Toml}}.hs
    • app/Cli.hs has the command line parser (as one might expect)
    • app/Instances.hs is for doing funky Haskell instance declarations on special cases.
    • app/Common/ is for general-purpose functions that could be used anywhere. Files in this directory should try to not import files outside of here, to prevent import loops.