Skip to content

Commit

Permalink
Merge trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jun 26, 2024
2 parents e28c4f3 + 2cb85ae commit 209ddc0
Show file tree
Hide file tree
Showing 406 changed files with 2,116 additions and 3,623 deletions.
12 changes: 5 additions & 7 deletions lib/unison-prelude/src/Unison/Debug.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ module Unison.Debug
)
where

import Control.Applicative (empty)
import Control.Monad (when)
import Data.Set (Set)
import Data.Set qualified as Set
import Data.Text qualified as Text
import Debug.Pretty.Simple (pTrace, pTraceM, pTraceShowId, pTraceShowM)
import Debug.Pretty.Simple (pTrace, pTraceM)
import System.IO.Unsafe (unsafePerformIO)
import Text.Pretty.Simple (pShow)
import Unison.Prelude
import UnliftIO.Environment (lookupEnv)

data DebugFlag
Expand Down Expand Up @@ -148,7 +147,7 @@ debugPatternCoverageConstraintSolver = PatternCoverageConstraintSolver `Set.memb
debug :: (Show a) => DebugFlag -> String -> a -> a
debug flag msg a =
if shouldDebug flag
then pTraceShowId (pTrace (msg <> ":\n") a)
then (pTrace (msg <> ":\n" <> into @String (pShow a)) a)
else a

-- | Use for selective debug logging in monadic contexts.
Expand All @@ -159,8 +158,7 @@ debug flag msg a =
debugM :: (Show a, Monad m) => DebugFlag -> String -> a -> m ()
debugM flag msg a =
whenDebug flag do
pTraceM (msg <> ":\n")
pTraceShowM a
traceM (msg <> ":\n" <> into @String (pShow a))

debugLog :: DebugFlag -> String -> a -> a
debugLog flag msg =
Expand Down
4 changes: 2 additions & 2 deletions unison-share-api/src/Unison/Server/Local.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ relocateToNameRoot perspective query rootBranch = do
-- Since the project root is lower down we need to strip the part of the prefix
-- which is now redundant.
pure . Right $ (projectRoot, query <&> \n -> fromMaybe n $ Path.unprefixName (Path.Absolute remainder) n)
-- The namesRoot is _inside_ of the project containing the query
-- The namesRoot is _inside (or equal to)_ the project containing the query
(_sharedPrefix, remainder, Path.Empty) -> do
-- Since the project is higher up, we need to prefix the query
-- with the remainder of the path
pure $ Right (projectRoot, query <&> Path.prefixNameIfRel (Path.AbsolutePath' $ Path.Absolute remainder))
pure $ Right (projectRoot, query <&> Path.prefixNameIfRel (Path.RelativePath' $ Path.Relative remainder))
-- The namesRoot and project root are disjoint, this shouldn't ever happen.
(_, _, _) -> pure $ Left (DisjointProjectAndPerspective perspective projectRoot)

Expand Down
6 changes: 3 additions & 3 deletions unison-src/builtin-tests/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Thus, make sure the contents of this file define the contents of the cache
(e.g. don't pull `latest`.)

```ucm
.> pull @unison/base/releases/2.5.0 .base
.> builtins.mergeio
.> undo
scratch/main> pull @unison/base/releases/2.5.0 .base
scratch/main> builtins.mergeio
scratch/main> undo
```
8 changes: 4 additions & 4 deletions unison-src/builtin-tests/interpreter-tests.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ If you want to add or update tests, you can create a branch of that project, and
Before merging the PR on Github, we'll merge your branch on Share and restore `runtime_tests_version` to /main or maybe a release.

```ucm:hide:error
.> this is a hack to trigger an error, in order to swallow any error on the next line.
.> we delete the project to avoid any merge conflicts or complaints from ucm.
.> delete.project runtime-tests
scratch/main> this is a hack to trigger an error, in order to swallow any error on the next line.
scratch/main> we delete the project to avoid any merge conflicts or complaints from ucm.
scratch/main> delete.project runtime-tests
```
```ucm:hide
.> clone ${runtime_tests_version} runtime-tests/selected
scratch/main> clone ${runtime_tests_version} runtime-tests/selected
```

```ucm
Expand Down
12 changes: 6 additions & 6 deletions unison-src/builtin-tests/jit-tests.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ If you want to add or update tests, you can create a branch of that project, and
Before merging the PR on Github, we'll merge your branch on Share and restore `runtime_tests_version` to /main or maybe a release.

```ucm:hide:error
.> this is a hack to trigger an error, in order to swallow any error on the next line.
.> we delete the project to avoid any merge conflicts or complaints from ucm.
.> delete.project runtime-tests
scratch/main> this is a hack to trigger an error, in order to swallow any error on the next line.
scratch/main> we delete the project to avoid any merge conflicts or complaints from ucm.
scratch/main> delete.project runtime-tests
```
```ucm:hide
.> clone ${runtime_tests_version} runtime-tests/selected
scratch/main> clone ${runtime_tests_version} runtime-tests/selected
```

```ucm
Expand All @@ -31,8 +31,8 @@ foo = do
```

```ucm
.> run.native foo
.> run.native foo
scratch/main> run.native foo
scratch/main> run.native foo
```

This can also only be tested by separately running this test, because
Expand Down
52 changes: 26 additions & 26 deletions unison-src/transcripts-manual/benchmarks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```ucm:hide
.> pull unison.public.base.releases.M4d base
.> pull runarorama.public.sort.data sort
scratch/main> pull unison.public.base.releases.M4d base
scratch/main> pull runarorama.public.sort.data sort
```

```unison:hide
Expand Down Expand Up @@ -34,63 +34,63 @@ prepare = do
```

```ucm:hide
.> add
.> run prepare
scratch/main> add
scratch/main> run prepare
```

## Benchmarks

```ucm
.> load unison-src/transcripts-manual/benchmarks/each.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/each.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/listmap.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/listmap.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/listfilter.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/listfilter.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/random.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/random.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/simpleloop.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/simpleloop.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/fibonacci.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/fibonacci.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/map.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/map.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/natmap.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/natmap.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/stm.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/stm.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/tmap.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/tmap.u
scratch/main> run main
```

```ucm
.> load unison-src/transcripts-manual/benchmarks/array-sort.u
.> run main
scratch/main> load unison-src/transcripts-manual/benchmarks/array-sort.u
scratch/main> run main
```
2 changes: 1 addition & 1 deletion unison-src/transcripts-manual/remote-tab-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Note: this makes a network call to share to get completions

```ucm
.> debug.tab-complete pull unison.pub
scratch/main> debug.tab-complete pull unison.pub
```
48 changes: 24 additions & 24 deletions unison-src/transcripts-manual/rewrites.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

```ucm:hide
.> builtins.mergeio
.> load unison-src/transcripts-using-base/base.u
.> add
scratch/main> builtins.mergeio
scratch/main> load unison-src/transcripts-using-base/base.u
scratch/main> add
```

## Structural find and replace
Expand Down Expand Up @@ -37,19 +37,19 @@ rule2 x = @rewrite signature Optional ==> Optional2
Let's rewrite these:

```ucm
.> rewrite rule1
.> rewrite eitherToOptional
scratch/main> rewrite rule1
scratch/main> rewrite eitherToOptional
```

```ucm:hide
.> load
.> add
scratch/main> load
scratch/main> add
```

After adding to the codebase, here's the rewritten source:

```ucm
.> view ex1 Either.mapRight rule1
scratch/main> view ex1 Either.mapRight rule1
```

Another example, showing that we can rewrite to definitions that only exist in the file:
Expand All @@ -75,18 +75,18 @@ blah2 = 456
Let's apply the rewrite `woot1to2`:

```ucm
.> rewrite woot1to2
scratch/main> rewrite woot1to2
```

```ucm:hide
.> load
.> add
scratch/main> load
scratch/main> add
```

After adding the rewritten form to the codebase, here's the rewritten `Woot1` to `Woot2`:

```ucm
.> view wootEx
scratch/main> view wootEx
```

This example shows that rewrite rules can to refer to term definitions that only exist in the file:
Expand All @@ -111,15 +111,15 @@ sameFileEx =
```

```ucm:hide
.> rewrite rule
.> load
.> add
scratch/main> rewrite rule
scratch/main> load
scratch/main> add
```

After adding the rewritten form to the codebase, here's the rewritten definitions:

```ucm
.> view foo1 foo2 sameFileEx
scratch/main> view foo1 foo2 sameFileEx
```

## Capture avoidance
Expand All @@ -145,13 +145,13 @@ sameFileEx =
In the above example, `bar2` is locally bound by the rule, so when applied, it should not refer to the `bar2` top level binding.

```ucm
.> rewrite rule
scratch/main> rewrite rule
```

Instead, it should be an unbound free variable, which doesn't typecheck:

```ucm:error
.> load
scratch/main> load
```

In this example, the `a` is locally bound by the rule, so it shouldn't capture the `a = 39494` binding which is in scope at the point of the replacement:
Expand All @@ -167,13 +167,13 @@ rule a = @rewrite
```

```ucm
.> rewrite rule
scratch/main> rewrite rule
```

The `a` introduced will be freshened to not capture the `a` in scope, so it remains as an unbound variable and is a type error:

```ucm:error
.> load
scratch/main> load
```

## Structural find
Expand All @@ -183,7 +183,7 @@ eitherEx = Left ("hello", "there")
```

```ucm:hide
.> add
scratch/main> add
```

```unison:hide
Expand All @@ -192,7 +192,7 @@ findEitherFailure = @rewrite signature a . Either Failure a ==> ()
```

```ucm
.> sfind findEitherEx
.> sfind findEitherFailure
.> find 1-5
scratch/main> sfind findEitherEx
scratch/main> sfind findEitherFailure
scratch/main> find 1-5
```
10 changes: 5 additions & 5 deletions unison-src/transcripts-manual/scheme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ This transcript executes very slowly, because the compiler has an
entire copy of base (and other stuff) within it.

```ucm:hide
.> builtins.merge
.> pull.without-history unison.public.base.trunk base
scratch/main> builtins.merge
scratch/main> pull.without-history unison.public.base.trunk base
```

```unison
Expand Down Expand Up @@ -55,7 +55,7 @@ multiAddUp = repeat 35 '(printAddUp 3000000)
```

```ucm
.> add
.> run singleAddUp
.> run.native multiAddUp
scratch/main> add
scratch/main> run singleAddUp
scratch/main> run.native multiAddUp
```
Loading

0 comments on commit 209ddc0

Please sign in to comment.