This tutorial aims to explain how to install and use Typedefs. Typedefs is a language to define types and generate type definitions as well as serialisers and deserialisers for a target language. We are going to see later how to achieve that, right now we are going to focus on how to install the tools.
Since Typedefs is written using Idris we are going to install the Idris compiler. You can find instruction on how to install Idris for your platform here: https://www.idris-lang.org/download/.
If you're using Mac OS, you can use brew
to install Idris by typing this on your terminal
brew install idris
Once Idris is installed you can check it works by typing
idris
And you should get
____ __ _
/ _/___/ /____(_)____
/ // __ / ___/ / ___/ Version 1.3.2-git:ed4d4cf30
_/ // /_/ / / / (__ ) http://www.idris-lang.org/
/___/\__,_/_/ /_/____/ Type :? for help
Idris is free software with ABSOLUTELY NO WARRANTY.
For details type :warranty.
Idris>
Use :q
to quit.
In order to compile Typedefs you will need to download its source, you can find it on its public repo here: http://github.com/typedefs/typedefs
One very easy way to get the code is to clone the project with the following command
git clone [email protected]:typedefs/typedefs.git
For this tutorial we are going to build the project using the elba package manager. The README contains the instructions to install elba on your system.
The easiest way to install is to use the pre-built binary and add it to your path.
The prebuilt binary can be found on the release page
Once your copy of the repo is downloaded go into its directory (using cd typedefs
for example)
and you can now compile the project using
elba install
This will download all the dependencies and compile the project. The last line printed should be something like
done! 1 binaries installed into ~/.elba/bin [54.81s]
You can try Typedefs by running it with a very simple command:
~/.elba/bin/typedefs -i "(name bool (+ 1 1))"
This assumes that elba
installed the binary in ~/.elba/bin
. If you have ~/.elba/bin
in your path you can simply
call
typedefs -i "(name bool (+ 1 1))"
You can now move on to our next tutorial Using typedefs