vamchale/polyglot

extra pompous

By Vanessa McHale <vanessa.mchale@reconfigure.io> on November 30, 2017
This patch is not signed. Learn here why and how to sign your patches.
9bBeDLccwgxKJdivDUqFEsF3tkn48G7FPZBWb1psA9ra7mbo7tejCv6nRZRj14vAoLjChTdiErHtatiCSSy2GbVM

This patch is in the following branches:

master
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
# Contributing to Madlang

I emphatically welcome bug reports, issues you may encounter, documentation, and
pull requests. Feature requests will likely be implemented if and only they are
relatively small.

Do note that `polyglot` is hosted using
[pijul](https://nest.pijul.com/vamchale/polyglot), so contributions and bug
reports there will be more effective.

## Getting started

If you'd like ideas for ways to contribute, check out `TODO.md`. Feel free to
open a PR or an issue if you need guidance on how to implement something.

## Navigating the Code

ATS can be quite daunting. The following are things that are relatively easy to
implement:

  * Adding a new file type and its associated extension
  * Adding a new file type and its associated extension (note that the name of
    a file type must be less than 20 characters; otherwise there will be a type
    error!)
  * Adding a new directory to ignore (e.g. `.cabal-sandbox`)
45

```
polt ./project/src --table
49

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

70
71
72
73


fnx right_pad {k: int | k >= 0} .<k>. (s: string, n: int(k)) : string =
// Pad a string of bounded length on the right by adding spaces.
fnx right_pad { k: int | k >= 0 }{ m: int | m <= k } .<k>. (s: string(m), n: int(k)) : string =
  case+ length(s) < n of
    | true when n > 0 => right_pad(s, n - 1) + " "
    | _ => s

// Pad a string on the left by adding spaces.
fnx left_pad { k: int | k >= 0 } .<k>. (s : string, n : int(k)) : string =
  case+ length(s) < n of
    | true when n > 0 => " " + left_pad(s, n - 1)
    | _ => s

// helper function for make_output
fun maybe_string(s: string, n: int): string =
  if n > 0
    then
      s + ": " + tostring_int(n) + "\n"
    else
      ""

fun maybe_table(s: string, files: int, lines: int): string =
// helper function for make_table
fun maybe_table{ k : int | k >= 0 && k < 20 }(s: string(k), files: int, lines: int): string =
  if files > 0
    then
      right_pad(" " + s, 21) + left_pad(tostring_int(files), 5) + left_pad(tostring_int(lines), 13) + "            -            -            -\n"