Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into series/M2
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Oct 5, 2021
2 parents 4d13caf + 6213a5b commit e89eb98
Show file tree
Hide file tree
Showing 376 changed files with 12,929 additions and 6,960 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ jobs:
stack --no-terminal exec transcripts
git diff
x=`git status --porcelain -uno` bash -c 'if [[ -n $x ]]; then echo "$x" && false; fi'
- name: prettyprint-round-trip
run: stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md
1 change: 1 addition & 0 deletions CONTRIBUTORS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ The format for this list: name, GitHub handle, and then optional blurb about wha
* Simon Højberg (@hojberg)
* David Smith (@shmish111)
* Chris Penner (@ChrisPenner)
* Rebecca Mark (@rlmark)
1 change: 1 addition & 0 deletions development.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ On startup, Unison prints a url for the codebase UI. If you did step 3 above, th
* `stack exec tests` runs the tests
* `stack exec transcripts` runs all the integration tests, found in `unison-src/transcripts`. You can add more tests to this directory.
* `stack exec tests -- prefix-of-test` and `stack exec transcripts -- prefix-of-test` only run tests with a matching prefix.
* `stack exec unison -- transcript unison-src/transcripts-round-trip/main.md` runs the pretty-printing round trip tests

### What if you want a profiled build?

Expand Down
107 changes: 107 additions & 0 deletions docs/release-steps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

__0__

Communicate with core team - we are cutting a release now, are there any showstopping bugs that need fixing first?

__1__

Create and push the tag to github. This will trigger the build. To determine the last release, check [the releases page](https://github.com/unisonweb/unison/releases).

```
git fetch
git checkout series/M2
git merge origin/trunk
git tag -a release/$RELEASE_NAME -m "release"
git push origin release/$RELEASE_NAME
```

__2__

Wait for the release to show up on [the releases page](https://github.com/unisonweb/unison/releases). This can take an hour or two!

__3__

Create a release notes draft issue, following [this template](https://github.com/unisonweb/unison/issues/2342) and updating the output of PRs merged and contributors to the release.

__4__

Update trunk of `base` to include any new builtins added since last release. Suggestion for how to do this: look through the release notes draft to find the PRs merged since last release. @runarorma does this usually.

```
git log --oneline release/M2h...release/M2i | grep 'Merge pull request #'
```

Then just use `alias.term ##Nat.newBuiltin Nat.someName` and/or `alias.type ##SomeType SomeType`. I think this is probably better than doing `builtins.merge` at this point.

__5__

Cut a release of base. @runarorama does this usually.

```
.> pull https://unisonweb/base basedev.release
.> cd basedev.release
.basedev.release> delete.namespace releases._latest
.basedev.release> squash trunk releases._<ReleaseName>
.basedev.release> fork releases._<ReleaseName> releases._latest
.basedev.release> push [email protected]/unisonweb/base
```

__6__

Update homebrew.

```
git clone [email protected]/unisonweb/homebrew-unison
```

Update this file: https://github.com/unisonweb/homebrew-unison/blob/master/unison-language.rb and change the version number and the path to the release. Leave the SHA alone, and then run `brew upgrade`.

Do `brew upgrade unison-language`. It will tell you the SHA hash doesn't match. Update the file to use the hash it says.
Do the same for linux and mac - you can temporarily swap the mac / linux stanzas just to get the value for the other platform.

__7__

Merge and promote to production any PRs pending [on the docs site](https://github.com/unisonweb/unisonweb-org/pulls) which are associated with the new release. Confirm with @rlmark.

__8__

Bug @pchiusano to update [the Slack post](https://unisonlanguage.slack.com/files/TLL09QC85/FMT7TDDDY?origin_team=TLL09QC85) which provides install instructions for people coming from [the quickstart guide](https://www.unisonweb.org/docs/quickstart/).

__9__

Announce on #contrib Slack channel. Template below.

---

Release announcement template (be sure to update the release urls) -

We've just released a new version of Unison, $RELEASE_NAME, release notes here (link to the issue). Install/upgrade instructions in the thread.

Mac upgrade is just `brew upgrade unison-language`.

A fresh install via:

```
brew tap unisonweb/unison
brew install unison-language
```

If you have previously done brew install unison-language --head to install a dev build, uninstall that first via brew uninstall unison-language.

_Linux manual install:_

```
mkdir unisonlanguage
curl -L https://github.com/unisonweb/unison/releases/download/release%2FM2h/ucm-linux.tar.gz --output unisonlanguage/ucm.tar.gz
tar -xzf unisonlanguage/ucm.tar.gz -C unisonlanguage
./unisonlanguage/ucm
```

_Mac manual install:_

```
mkdir unisonlanguage
curl -L https://github.com/unisonweb/unison/releases/download/release%2FM2h/ucm-macos.tar.gz --output unisonlanguage/ucm.tar.gz
tar -xzf unisonlanguage/ucm.tar.gz -C unisonlanguage
./unisonlanguage/ucm
```
Binary file added parser-typechecker/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions parser-typechecker/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ library:
- configurator
- cryptonite
- data-default
- deepseq
- directory
- either
- fuzzyfind
Expand Down Expand Up @@ -75,6 +76,7 @@ library:
- optparse-applicative >= 0.16.1.0
- openapi3
- pem
- prelude-extras
- process
- primitive
- random >= 1.2.0
Expand Down Expand Up @@ -108,6 +110,7 @@ library:
- x509
- x509-store
- x509-system
- zlib
- unison-codebase
- unison-codebase-sqlite
- unison-codebase-sync
Expand Down Expand Up @@ -143,6 +146,7 @@ executables:
- unison-parser-typechecker
- unison-codebase-sync
- uri-encode
- unliftio
when:
- condition: '!os(windows)'
dependencies: unix
Expand Down Expand Up @@ -203,6 +207,8 @@ executables:
- text
- unison-core1
- unison-parser-typechecker
build-tools:
- unison-parser-typechecker:unison

benchmarks:
runtime:
Expand Down
65 changes: 61 additions & 4 deletions parser-typechecker/src/Unison/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Unison.Codebase.CodeLookup ( CodeLookup(..) )
import qualified Unison.Builtin.Decls as DD
import qualified Unison.Builtin.Terms as TD
import qualified Unison.DataDeclaration as DD
import Unison.Parser ( Ann(..) )
import Unison.Parser.Ann (Ann (..))
import qualified Unison.Reference as R
import qualified Unison.Referent as Referent
import Unison.Symbol ( Symbol )
Expand All @@ -46,6 +46,7 @@ import Unison.Names3 (Names(Names), Names0)
import qualified Unison.Names3 as Names3
import qualified Unison.Typechecker.TypeLookup as TL
import qualified Unison.Util.Relation as Rel
import qualified Unison.Hashing.V2.Convert as H

type DataDeclaration v = DD.DataDeclaration v Ann
type EffectDeclaration v = DD.EffectDeclaration v Ann
Expand Down Expand Up @@ -106,15 +107,15 @@ builtinDependencies =
-- a relation whose domain is types and whose range is builtin terms with that type
builtinTermsByType :: Rel.Relation R.Reference Referent.Referent
builtinTermsByType =
Rel.fromList [ (Type.toReference ty, Referent.Ref r)
Rel.fromList [ (H.typeToReference ty, Referent.Ref r)
| (r, ty) <- Map.toList (termRefTypes @Symbol) ]

-- a relation whose domain is types and whose range is builtin terms that mention that type
-- example: Nat.+ mentions the type `Nat`
builtinTermsByTypeMention :: Rel.Relation R.Reference Referent.Referent
builtinTermsByTypeMention =
Rel.fromList [ (m, Referent.Ref r) | (r, ty) <- Map.toList (termRefTypes @Symbol)
, m <- toList $ Type.toReferenceMentions ty ]
, m <- toList $ H.typeToReferenceMentions ty ]

-- The dependents of a builtin type is the set of builtin terms which
-- mention that type.
Expand Down Expand Up @@ -179,6 +180,8 @@ builtinTypesSrc =
, B' "Tls.Cipher" CT.Data, Rename' "Tls.Cipher" "io2.Tls.Cipher"
, B' "TVar" CT.Data, Rename' "TVar" "io2.TVar"
, B' "STM" CT.Effect, Rename' "STM" "io2.STM"
, B' "Ref" CT.Data
, B' "Scope" CT.Effect
]

-- rename these to "builtin" later, when builtin means intrinsic as opposed to
Expand Down Expand Up @@ -253,7 +256,8 @@ typeOf a f r = maybe a f (Map.lookup r termRefTypes)

builtinsSrc :: Var v => [BuiltinDSL v]
builtinsSrc =
[ B "Int.+" $ int --> int --> int
[ B "Any.unsafeExtract" $ forall1 "a" (\a -> anyt --> a)
, B "Int.+" $ int --> int --> int
, B "Int.-" $ int --> int --> int
, B "Int.*" $ int --> int --> int
, B "Int./" $ int --> int --> int
Expand Down Expand Up @@ -432,6 +436,11 @@ builtinsSrc =
, B "Bytes.size" $ bytes --> nat
, B "Bytes.flatten" $ bytes --> bytes

, B "Bytes.zlib.compress" $ bytes --> bytes
, B "Bytes.zlib.decompress" $ bytes --> eithert text bytes
, B "Bytes.gzip.compress" $ bytes --> bytes
, B "Bytes.gzip.decompress" $ bytes --> eithert text bytes

{- These are all `Bytes -> Bytes`, rather than `Bytes -> Text`.
This is intentional: it avoids a round trip to `Text` if all
you are doing with the bytes is dumping them to a file or a
Expand Down Expand Up @@ -462,6 +471,17 @@ builtinsSrc =
, B "List.at" $ forall1 "a" (\a -> nat --> list a --> optionalt a)

, B "Debug.watch" $ forall1 "a" (\a -> text --> a --> a)
, B "unsafe.coerceAbilities" $
forall4 "a" "b" "e1" "e2" $ \a b e1 e2 ->
(a --> Type.effect1 () e1 b) --> (a --> Type.effect1 () e2 b)
, B "Scope.run" . forall2 "r" "g" $ \r g ->
(forall1 "s" $ \s -> unit --> Type.effect () [scopet s, g] r) --> Type.effect1 () g r
, B "Scope.ref" . forall2 "a" "s" $ \a s ->
a --> Type.effect1 () (scopet s) (reft (Type.effects () [scopet s]) a)
, B "Ref.read" . forall2 "a" "g" $ \a g ->
reft g a --> Type.effect1 () g a
, B "Ref.write" . forall2 "a" "g" $ \a g ->
reft g a --> a --> Type.effect1 () g unit
] ++
-- avoid name conflicts with Universal == < > <= >=
[ Rename (t <> "." <> old) (t <> "." <> new)
Expand Down Expand Up @@ -546,6 +566,7 @@ ioBuiltins =
, ("IO.putBytes.impl.v3", handle --> bytes --> iof unit)
, ("IO.getLine.impl.v1", handle --> iof text)
, ("IO.systemTime.impl.v3", unit --> iof nat)
, ("IO.systemTimeMicroseconds.v1", unit --> io int)
, ("IO.getTempDirectory.impl.v3", unit --> iof text)
, ("IO.createTempDirectory.impl.v3", text --> iof text)
, ("IO.getCurrentDirectory.impl.v3", unit --> iof text)
Expand Down Expand Up @@ -573,6 +594,8 @@ ioBuiltins =

, ("IO.delay.impl.v3", nat --> iof unit)
, ("IO.kill.impl.v3", threadId --> iof unit)
, ("IO.ref", forall1 "a" $ \a ->
a --> io (reft (Type.effects () [Type.builtinIO ()]) a))
, ("Tls.newClient.impl.v3", tlsClientConfig --> socket --> iof tls)
, ("Tls.newServer.impl.v3", tlsServerConfig --> socket --> iof tls)
, ("Tls.handshake.impl.v3", tls --> iof unit)
Expand Down Expand Up @@ -618,13 +641,16 @@ codeBuiltins =
, ("Code.serialize", code --> bytes)
, ("Code.deserialize", bytes --> eithert text code)
, ("Code.cache_", list (tuple [termLink,code]) --> io (list termLink))
, ("Code.validate", list (tuple [termLink,code]) --> io (optionalt failure))
, ("Code.lookup", termLink --> io (optionalt code))
, ("Code.display", text --> code --> text)
, ("Value.dependencies", value --> list termLink)
, ("Value.serialize", value --> bytes)
, ("Value.deserialize", bytes --> eithert text value)
, ("Value.value", forall1 "a" $ \a -> a --> value)
, ("Value.load"
, forall1 "a" $ \a -> value --> io (eithert (list termLink) a))
, ("Link.Term.toText", termLink --> text)
]

stmBuiltins :: forall v. Var v => [(Text, Type v)]
Expand All @@ -645,6 +671,31 @@ forall1 name body =
a = Var.named name
in Type.forall () a (body $ Type.var () a)

forall2
:: Var v => Text -> Text -> (Type v -> Type v -> Type v) -> Type v
forall2 na nb body = Type.foralls () [a,b] (body ta tb)
where
a = Var.named na
b = Var.named nb
ta = Type.var () a
tb = Type.var () b

forall4
:: Var v
=> Text -> Text -> Text -> Text
-> (Type v -> Type v -> Type v -> Type v -> Type v)
-> Type v
forall4 na nb nc nd body = Type.foralls () [a,b,c,d] (body ta tb tc td)
where
a = Var.named na
b = Var.named nb
c = Var.named nc
d = Var.named nd
ta = Type.var () a
tb = Type.var () b
tc = Type.var () c
td = Type.var () d

app :: Ord v => Type v -> Type v -> Type v
app = Type.app ()

Expand Down Expand Up @@ -675,6 +726,12 @@ failure = DD.failureType ()
eithert :: Var v => Type v -> Type v -> Type v
eithert l r = DD.eitherType () `app` l `app` r

scopet :: Var v => Type v -> Type v
scopet s = Type.scopeType () `app` s

reft :: Var v => Type v -> Type v -> Type v
reft s a = Type.refType () `app` s `app` a

socket, threadId, handle, unit :: Var v => Type v
socket = Type.socket ()
threadId = Type.threadId ()
Expand Down
11 changes: 7 additions & 4 deletions parser-typechecker/src/Unison/Builtin/Decls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Unison.Builtin.Decls where

import Control.Lens (_3,over)
import Control.Lens (over, _3)
import Data.List (elemIndex, find)
import qualified Data.Map as Map
import Data.Text (Text, unpack)
Expand All @@ -13,16 +13,16 @@ import qualified Unison.ConstructorType as CT
import Unison.DataDeclaration
( DataDeclaration (..),
Modifier (Structural, Unique),
hashDecls,
)
import qualified Unison.DataDeclaration as DD
import Unison.Hashing.V2.Convert (hashDecls)
import qualified Unison.Pattern as Pattern
import Unison.Reference (Reference)
import qualified Unison.Reference as Reference
import Unison.Referent (Referent)
import Unison.Referent (ConstructorId, Referent)
import qualified Unison.Referent as Referent
import Unison.Symbol (Symbol)
import Unison.Term (ConstructorId, Term, Term2)
import Unison.Term (Term, Term2)
import qualified Unison.Term as Term
import Unison.Type (Type)
import qualified Unison.Type as Type
Expand Down Expand Up @@ -86,6 +86,7 @@ constructorId ref name = do

noneId, someId, okConstructorId, failConstructorId, docBlobId, docLinkId, docSignatureId, docSourceId, docEvaluateId, docJoinId, linkTermId, linkTypeId, eitherRightId, eitherLeftId :: ConstructorId
isPropagatedConstructorId, isTestConstructorId, bufferModeNoBufferingId, bufferModeLineBufferingId, bufferModeBlockBufferingId, bufferModeSizedBlockBufferingId :: ConstructorId
seqViewEmpty, seqViewElem :: ConstructorId
Just noneId = constructorId optionalRef "Optional.None"
Just someId = constructorId optionalRef "Optional.Some"
Just isPropagatedConstructorId = constructorId isPropagatedRef "IsPropagated.IsPropagated"
Expand All @@ -102,6 +103,8 @@ Just linkTermId = constructorId linkRef "Link.Term"
Just linkTypeId = constructorId linkRef "Link.Type"
Just eitherRightId = constructorId eitherRef "Either.Right"
Just eitherLeftId = constructorId eitherRef "Either.Left"
Just seqViewEmpty = constructorId seqViewRef "SeqView.VEmpty"
Just seqViewElem = constructorId seqViewRef "SeqView.VElem"

Just bufferModeNoBufferingId = constructorId bufferModeRef "io2.BufferMode.NoBuffering"
Just bufferModeLineBufferingId = constructorId bufferModeRef "io2.BufferMode.LineBuffering"
Expand Down
6 changes: 5 additions & 1 deletion parser-typechecker/src/Unison/Builtin/Terms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Data.Map (Map)
import qualified Data.Map as Map
import Data.Text (Text)
import qualified Unison.Builtin.Decls as Decls
import qualified Unison.Hashing.V2.Convert as H
import qualified Unison.Reference as Reference
import Unison.Term (Term)
import qualified Unison.Term as Term
Expand All @@ -31,6 +32,9 @@ v :: Var v => Text -> v
v = Var.named

builtinTermsRef :: Var v => a -> Map v Reference.Id
builtinTermsRef a = fmap fst . Term.hashComponents . Map.fromList
builtinTermsRef a =
fmap fst
. H.hashTermComponents
. Map.fromList
. fmap (\(v, tm, _tp) -> (v, tm))
$ builtinTermsSrc a
Loading

0 comments on commit e89eb98

Please sign in to comment.