/agda-integer-shenanigans

i am a sucker for punishment and hard maths, so i'm learning agda. here is some junk i threw together for this challenge: https://github.com/software-shokunin/feb-code-challenge

Primary LanguageAgda

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:

  1. 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.

  2. If you installed using homebrew, you'll probably need to recompile the foreign function interface:

     cd /usr/local/lib/agda/ffi
     cabal install
    
  3. Compile it:

     agda -i . -i <path to the agda std lib - on a mac try /usr/local/lib/agda/src> -c Main.agda
    
  4. Run it:

     ./Main