aboutsummaryrefslogtreecommitdiff

Malodivo

Budget planning in a fairy Kingdom of Malodivo. For the whole story read the plot.

Requirements

Malodivo is written in Haskell with GHC. All required Haskell libraries are listed in malodivo.cabal. Use cabal-install to fetch and build all pre-requisites automatically.

Command-line utility

The command-line utility malodivo provides a means to process input JSON files and output JSON describing the actual amounts that go towards each bill by each district. This utility reads input JSON data from standard input and writes output JSON data to standard output.

Usage

Usage: malodivo [options] < input.json > output.json

Options:

  -h, --help               Show this message and exit

Examples

Command:

$ malodivo < sample/simpleBudget.json

Input:

{
  "bills": [
    {
      "name": "An Act to Construct the Great Wall of Malodivo",
      "ministry": "Defense",
      "amount": 300
    },
    {
      "name": "An Act to Construct Shelters for the Homeless",
      "ministry": "Welfare",
      "amount": 400
    }
  ],
  "districts": [
    {
      "name": "Palolene",
      "amount": 200
    },
    {
      "name": "SouthernPalolene",
      "amount": 400
    },
    {
      "name": "Lakos",
      "amount": 300
    }
  ]
}

Output (formatted with the jq utility):

[
  {
    "bill": {
      "amount": 300,
      "name": "An Act to Construct the Great Wall of Malodivo",
      "ministry": "Defense"
    },
    "districts": [
      {
        "amount": 100,
        "name": "Lakos"
      },
      {
        "amount": 66,
        "name": "Palolene"
      },
      {
        "amount": 133,
        "name": "SouthernPalolene"
      }
    ]
  },
  {
    "bill": {
      "amount": 400,
      "name": "An Act to Construct Shelters for the Homeless",
      "ministry": "Welfare"
    },
    "districts": [
      {
        "amount": 133,
        "name": "Lakos"
      },
      {
        "amount": 88,
        "name": "Palolene"
      },
      {
        "amount": 177,
        "name": "SouthernPalolene"
      }
    ]
  }
]