Agda integer addition shenanigans
My first experiment with Agda, a dependently typed functional programming language. I attempted to solve this problem:
Write a program that adds two (or more) integers, without using any of the plus literal (+), the minus literal (-), the add method (or equivalent), the subtraction method (or equivalent), the sum method. The integers can be negative, zero or positive.
I'm not even a very good Haskell programmer so, so I definitely suck at Agda, but I had fun learning. I've cited borrowed code inline.
To run it:
-
Install Agda (on a Mac, try
brew install agda
). If you don't install using homebrew, you might also need to install the Agda Standard Library. -
If you installed using homebrew, you'll probably need to recompile the foreign function interface:
cd /usr/local/lib/agda/ffi cabal install
-
Compile it:
agda -i . -i <path to the agda std lib - on a mac try /usr/local/lib/agda/src> -c Main.agda
-
Run it:
./Main