Skip to content

Commit

Permalink
Merge branch 'trunk' into better-CLI-error-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sellout authored Jun 26, 2024
2 parents 532236b + e28c4f3 commit f14fca0
Show file tree
Hide file tree
Showing 169 changed files with 3,022 additions and 4,571 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ defaults:
shell: bash

on:
# Build on every pull request (and new PR commit)
# Run on the post-merge result of every PR commit
pull_request:
# Build on new pushes to trunk (E.g. Merge commits)
# Without the branch filter, each commit on a branch with a PR is triggered twice.
# See: https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
# Build on the pre-merge result of every branch commit
push:
branches:
- trunk
tags:
- release/*
workflow_dispatch:

env:
Expand All @@ -38,7 +32,7 @@ jobs:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v44
with:
# globs copied from default settings for run-ormolu
files: |
Expand Down Expand Up @@ -270,6 +264,14 @@ jobs:
${{env.transcripts}}
# Fail if any transcripts cause git diffs.
git diff --ignore-cr-at-eol --exit-code unison-src/transcripts
- name: docs.to-html
if: steps.cache-transcript-test-results.outputs.cache-hit != 'true'
run: |
${{env.ucm}} transcript unison-src/transcripts-manual/docs.to-html.md
# Fail if the output or generated docs differ.
git diff --ignore-cr-at-eol --exit-code \
unison-src/transcripts-manual/docs.to-html.output.md \
unison-src/transcripts-manual/docs.to-html
- name: mark transcripts as passing
if: steps.cache-transcript-test-results.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -417,7 +419,7 @@ jobs:
build-jit-binary:
name: build jit binary
needs: generate-jit-source
uses: ./.github/workflows/ci-build-jit-binary.yaml
uses: ./.github/workflows/ci-build-jit-binary.yaml

test-jit:
name: test jit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ormolu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: create pull request with formatting changes
uses: peter-evans/create-pull-request@v6
with:
commit_message: automatically run ormolu
commit-message: automatically run ormolu
branch: autoformat/${{github.ref_name}}
# branch_suffix: random
branch-suffix: short-commit-hash
title: format `${{github.ref_name}}` with ormolu ${{env.ormolu_version}}
3 changes: 3 additions & 0 deletions .github/workflows/update-transcripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
stack exec unison transcript unison-src/transcripts-manual/rewrites.md
- name: transcripts
run: stack exec transcripts
- name: docs.to-html
run: |
stack exec unison transcript unison-src/transcripts-manual/docs.to-html.md
- name: save transcript changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pull_request_rules:
- name: automatic merge on CI success and review
conditions:
- check-success=Contributor signed CONTRIBUTORS.markdown
- check-success=check-contributor
- check-success=build ucm (ubuntu-20.04)
- check-success=build ucm (macOS-12)
- check-success=build ucm (windows-2019)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ The format for this list: name, GitHub handle
* Upendra Upadhyay (@upendra1997)
* Dan Doel (@dolio)
* Eric Torreborre (@etorreborre)
* Eduard Nicodei (@neduard)
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ If these instructions don't work for you or are incomplete, please file an issue

The build uses [Stack](http://docs.haskellstack.org/). If you don't already have it installed, [follow the install instructions](http://docs.haskellstack.org/en/stable/README.html#how-to-install) for your platform. (Hint: `brew update && brew install stack`)

If you have not set up the Haskell toolchain before and are trying to contribute to Unison on an M1 Mac, we have [some tips specifically for you](docs/m1-mac-setup-tips.markdown).

```sh
$ git clone https://github.com/unisonweb/unison.git
$ cd unison
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/LocalIds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data LocalIds' t h = LocalIds
{ textLookup :: Vector t,
defnLookup :: Vector h
}
deriving (Show)
deriving (Functor, Show)

type LocalIds = LocalIds' TextId ObjectId

Expand Down
70 changes: 56 additions & 14 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Operations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ module U.Codebase.Sqlite.Operations
causalHashesByPrefix,

-- ** dependents index
directDependenciesOfScope,
dependents,
dependentsOfComponent,
dependentsWithinScope,
directDependentsWithinScope,
transitiveDependentsWithinScope,

-- ** type index
Q.addTypeToIndexForTerm,
Expand Down Expand Up @@ -205,6 +207,7 @@ import Unison.NameSegment.Internal qualified as NameSegment
import Unison.Prelude
import Unison.ShortHash (ShortCausalHash (..), ShortNamespaceHash (..))
import Unison.Sqlite
import Unison.Util.Defns (DefnsF)
import Unison.Util.List qualified as List
import Unison.Util.Map qualified as Map
import Unison.Util.Monoid (foldMapM)
Expand Down Expand Up @@ -1121,6 +1124,21 @@ causalHashesByPrefix (ShortCausalHash b32prefix) = do
hashes <- traverse (Q.expectHash . Db.unCausalHashId) hashIds
pure $ Set.fromList . map CausalHash $ hashes

directDependenciesOfScope ::
DefnsF Set C.TermReferenceId C.TypeReferenceId ->
Transaction (DefnsF Set C.TermReference C.TypeReference)
directDependenciesOfScope scope0 = do
-- Convert C -> S
scope1 <- bitraverse (Set.traverse c2sReferenceId) (Set.traverse c2sReferenceId) scope0

-- Do the query
dependencies0 <- Q.getDirectDependenciesOfScope scope1

-- Convert S -> C
dependencies1 <- bitraverse (Set.traverse s2cReference) (Set.traverse s2cReference) dependencies0

pure dependencies1

-- | returns a list of known definitions referencing `r`
dependents :: Q.DependentsSelector -> C.Reference -> Transaction (Set C.Reference.Id)
dependents selector r = do
Expand All @@ -1137,19 +1155,43 @@ dependents selector r = do
sIds <- Q.getDependentsForDependency selector r'
Set.traverse s2cReferenceId sIds

-- | `dependentsWithinScope scope query` returns all of transitive dependents of `query` that are in `scope` (not
-- including `query` itself). Each dependent is also tagged with whether it is a term or decl.
dependentsWithinScope :: Set C.Reference.Id -> Set C.Reference -> Transaction (Map C.Reference.Id C.ReferenceType)
dependentsWithinScope scope query = do
scope' <- Set.traverse c2sReferenceId scope
query' <- Set.traverse c2sReference query
Q.getDependentsWithinScope scope' query'
>>= Map.bitraverse s2cReferenceId (pure . objectTypeToReferenceType)
where
objectTypeToReferenceType = \case
ObjectType.TermComponent -> C.RtTerm
ObjectType.DeclComponent -> C.RtType
_ -> error "Q.getDependentsWithinScope shouldn't return any other types"
-- | `directDependentsWithinScope scope query` returns all direct dependents of `query` that are in `scope` (not
-- including `query` itself).
directDependentsWithinScope ::
Set C.Reference.Id ->
Set C.Reference ->
Transaction (DefnsF Set C.TermReferenceId C.TypeReferenceId)
directDependentsWithinScope scope0 query0 = do
-- Convert C -> S
scope1 <- Set.traverse c2sReferenceId scope0
query1 <- Set.traverse c2sReference query0

-- Do the query
dependents0 <- Q.getDirectDependentsWithinScope scope1 query1

-- Convert S -> C
dependents1 <- bitraverse (Set.traverse s2cReferenceId) (Set.traverse s2cReferenceId) dependents0

pure dependents1

-- | `transitiveDependentsWithinScope scope query` returns all transitive dependents of `query` that are in `scope` (not
-- including `query` itself).
transitiveDependentsWithinScope ::
Set C.Reference.Id ->
Set C.Reference ->
Transaction (DefnsF Set C.TermReferenceId C.TypeReferenceId)
transitiveDependentsWithinScope scope0 query0 = do
-- Convert C -> S
scope1 <- Set.traverse c2sReferenceId scope0
query1 <- Set.traverse c2sReference query0

-- Do the query
dependents0 <- Q.getTransitiveDependentsWithinScope scope1 query1

-- Convert S -> C
dependents1 <- bitraverse (Set.traverse s2cReferenceId) (Set.traverse s2cReferenceId) dependents0

pure dependents1

-- | returns a list of known definitions referencing `h`
dependentsOfComponent :: H.Hash -> Transaction (Set C.Reference.Id)
Expand Down
6 changes: 6 additions & 0 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Patch/TermEdit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ type Referent' t h = Referent.Referent' (Reference' t h) (Reference' t h)
data TermEdit' t h = Replace (Referent' t h) Typing | Deprecate
deriving (Eq, Ord, Show)

instance Functor (TermEdit' t) where
fmap :: (a -> b) -> TermEdit' t a -> TermEdit' t b
fmap f (Replace (Referent.Ref termRef) typing) = Replace (Referent.Ref (fmap f termRef)) typing
fmap f (Replace (Referent.Con typeRef consId) typing) = Replace (Referent.Con (fmap f typeRef) consId) typing
fmap _ Deprecate = Deprecate

_Replace :: Prism (TermEdit' t h) (TermEdit' t' h') (Referent' t h, Typing) (Referent' t' h', Typing)
_Replace = prism embed project
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type TypeEdit = TypeEdit' Db.TextId Db.ObjectId
type HashTypeEdit = TypeEdit' Text ComponentHash

data TypeEdit' t h = Replace (Reference' t h) | Deprecate
deriving (Eq, Ord, Show)
deriving (Eq, Functor, Ord, Show)

_Replace :: Prism (TypeEdit' t h) (TypeEdit' t' h') (Reference' t h) (Reference' t' h')
_Replace = prism Replace project
Expand Down
Loading

0 comments on commit f14fca0

Please sign in to comment.