Skip to content

Opinionated format on Vector<32, Uint<5>> #307

@faculerena

Description

@faculerena

I have a fold that wants to be a zip:

circuit foo(input: Bytes<32>, t: Uint<32>,): Boolean {
  return fold((acc: Boolean, byte: Uint<8>, i: Uint<8>): Boolean =>
    ...,
    true,
    input,
    [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
}

Running compact-format over this causes it to be... ugly.

circuit foo(input: Bytes<32>, t: Uint<32>,): Boolean {
  return fold((acc: Boolean, byte: Uint<8>, i: Uint<8>): Boolean =>
    ...,
    true,
    input,
    [0,
     1,
     2,
     3,
     4,
     5,
     6,
     7,
     8,
     9,
     10,
     11,
     12,
     13,
     14,
     15,
     16,
     17,
     18,
     19,
     20,
     21,
     22,
     23,
     24,
     25,
     26,
     27,
     28,
     29,
     30,
     31];
}

Moving it to another function makes it less annoying

circuit zero_to_31(): Vector<32, Uint<5>> {
  return [0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10,
          11,
          12,
          13,
          14,
          15,
          16,
          17,
          18,
          19,
          20,
          21,
          22,
          23,
          24,
          25,
          26,
          27,
          28,
          29,
          30,
          31];
}

Could something like this be an exception, or maybe get some kind of directive like #[no_format] or something like that? I really like having format-on-save.

Metadata

Metadata

Assignees

Labels

triagedIssues that have been triaged by the team

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions