Why a list [1,2,3] compiles to [1,[2,[3,[0]]]?


#1

If you ever wonder why

let myList = [1,2,3];

compiles to this code in Javascript

var myList = /* :: */[
  1,
  /* :: */[
    2,
    /* :: */[
      3,
      /* [] */0
    ]
  ]
];

then this answer on SO from @glennsl will give you an excellent explanation

Tips:

None => 0
Some(1) => [1]

#2

Nice, see also https://bucklescript.github.io/docs/en/common-data-types.html#non-shared