unison/unison-src/transcripts-using-base/fix3542.output.md
2024-04-14 20:20:36 -04:00

763 B

arrayList v n = do
  use ImmutableByteArray read8
  ma = Scope.bytearrayOf v n
  a = freeze! ma
  go acc i =
    acc' = [read8 a i] ++ acc
    if i == 0
    then acc'
    else go acc' (drop i 1)
  go [] (drop n 1)

> Scope.run '(catch (arrayList 7 8))

  Loading changes detected in scratch.u.

  I found and typechecked these definitions in scratch.u. If you
  do an `add` or `update`, here's how your codebase would
  change:
  
    ⍟ These new definitions are ok to `add`:
    
      arrayList : Nat -> Nat -> '{Exception, Scope s} [Nat]
  
  Now evaluating any watch expressions (lines starting with
  `>`)... Ctrl+C cancels.

    12 | > Scope.run '(catch (arrayList 7 8))
           ⧩
           Right [7, 7, 7, 7, 7, 7, 7, 7]