unison/unison-src/transcripts/definition-diff-api.md
2024-08-09 10:58:47 -07:00

1.4 KiB

diffs/main> builtins.mergeio lib.builtins
diffs/main> alias.term lib.builtins.Nat.gt lib.builtins.Nat.>
diffs/main> alias.term lib.builtins.Nat.drop lib.builtins.Nat.-
term =
  _ = "Here's some text"
  1 + 1

type Type = Type Nat

ability Stream a where
  emit : a -> ()

take n s =
  use Nat > -
  h n = cases
    { emit a -> k } -> if n > 0
                         then
                           emit a
                           handle k() with h (n - 1)
                         else None
    { r }  -> Some r
  handle s() with h n
diffs/main> add
diffs/main> branch.create new
term =
  _ = "Here's some different text"
  1 + 2

type Type a = Type a Text

ability Stream a where
  emit : a -> ()

take n s =
  use Nat > -
  h n = cases
    { emit a -> k } ->
        emit a
        if n > 0
          then handle k() with h (n - 1)
          else None
    { r }  -> Some r
  if n > 0
    then handle s () with h (n - 1)
    else None
diffs/new> update

Diff terms

GET /api/projects/diffs/diff/terms?oldBranchRef=main&newBranchRef=new&oldTerm=term&newTerm=term

More complex diff

GET /api/projects/diffs/diff/terms?oldBranchRef=main&newBranchRef=new&oldTerm=take&newTerm=take

Diff types

GET /api/projects/diffs/diff/types?oldBranchRef=main&newBranchRef=new&oldType=Type&newType=Type