Skip to content

Commit 5040c20

Browse files
authored
Merge pull request #1162 from unisonweb/master
staging release/M1h
2 parents 3d9e482 + e1d94eb commit 5040c20

File tree

145 files changed

+7013
-1295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+7013
-1295
lines changed

.mergify.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pull_request_rules:
2+
- name: automatic merge on CI success and review
3+
conditions:
4+
- status-success=continuous-integration/travis-ci/pr
5+
- label=ready-to-merge
6+
- "#approved-reviews-by>=1"
7+
actions:
8+
merge:
9+
method: merge
10+
# - name: delete head branch after merge
11+
# conditions: []
12+
# actions:
13+
# delete_head_branch: {}

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ install:
2424
- stack --no-terminal exec tests
2525
- stack --no-terminal exec transcripts
2626
# fail if running transcripts modified any versioned files
27-
- x=`git status --porcelain -uno` bash -c 'if [[ -n $x ]]; then echo "$x" && false; fi'
27+
- git diff
28+
- x=`git status --porcelain -uno` bash -c 'if [[ -n $x ]]; then echo "$x" && false; fi'

CONTRIBUTORS.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ The format for this list: name, GitHub handle, and then optional blurb about wha
3030
* Jonas De Vuyst (@jdevuyst)
3131
* George Marrows (@georgemarrows)
3232
* Florian Thurm (@0xflotus)
33+
* Mat Ess (@matthewess)
3334
* Evan Burchard (@evanburchard)
35+
* Alvaro Carrasco (@alvaroc1)
36+
* Vladislav Zavialov (@int-index)
37+
* Aaron Novstrup (@anovstrup)
38+
* Pete Tsamouris (@pete-ts)

parser-typechecker/src/Unison/Builtin.hs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Unison.Builtin
1111
,names0
1212
,builtinDataDecls
1313
,builtinEffectDecls
14+
,builtinConstructorType
1415
,builtinTypeDependents
1516
,builtinTermsByType
1617
,builtinTermsByTypeMention
@@ -75,7 +76,8 @@ typeLookup =
7576
(Map.fromList $ map snd builtinEffectDecls)
7677

7778
constructorType :: R.Reference -> Maybe CT.ConstructorType
78-
constructorType = TL.constructorType (typeLookup @Symbol)
79+
constructorType r = TL.constructorType (typeLookup @Symbol) r
80+
<|> Map.lookup r builtinConstructorType
7981

8082
-- | parse some builtin data types, and resolve their free variables using
8183
-- | builtinTypes' and those types defined herein
@@ -122,7 +124,7 @@ builtinTypes :: [(Name, R.Reference)]
122124
builtinTypes = Map.toList . Map.mapKeys Name.unsafeFromText
123125
$ foldl' go mempty builtinTypesSrc where
124126
go m = \case
125-
B' r -> Map.insert r (R.Builtin r) m
127+
B' r _ -> Map.insert r (R.Builtin r) m
126128
D' r -> Map.insert r (R.Builtin r) m
127129
Rename' r name -> case Map.lookup name m of
128130
Just _ -> error . Text.unpack $
@@ -144,21 +146,23 @@ builtinTypes = Map.toList . Map.mapKeys Name.unsafeFromText
144146
-- WARNING: Don't delete any of these lines, only add corrections.
145147
builtinTypesSrc :: [BuiltinTypeDSL]
146148
builtinTypesSrc =
147-
[ B' "Int"
148-
, B' "Nat"
149-
, B' "Float"
150-
, B' "Boolean"
151-
, B' "Sequence", Rename' "Sequence" "List"
152-
, B' "Text"
153-
, B' "Char"
154-
, B' "Effect", Rename' "Effect" "Request"
155-
, B' "Bytes"
156-
, B' "Link.Term"
157-
, B' "Link.Type"
149+
[ B' "Int" CT.Data
150+
, B' "Nat" CT.Data
151+
, B' "Float" CT.Data
152+
, B' "Boolean" CT.Data
153+
, B' "Sequence" CT.Data, Rename' "Sequence" "List"
154+
, B' "Text" CT.Data
155+
, B' "Char" CT.Data
156+
, B' "Effect" CT.Data, Rename' "Effect" "Request"
157+
, B' "Bytes" CT.Data
158+
, B' "Link.Term" CT.Data
159+
, B' "Link.Type" CT.Data
158160
]
159161

162+
builtinConstructorType :: Map R.Reference CT.ConstructorType
163+
builtinConstructorType = Map.fromList [ (R.Builtin r, ct) | B' r ct <- builtinTypesSrc ]
160164

161-
data BuiltinTypeDSL = B' Text | D' Text | Rename' Text Text | Alias' Text Text
165+
data BuiltinTypeDSL = B' Text CT.ConstructorType | D' Text | Rename' Text Text | Alias' Text Text
162166

163167

164168
data BuiltinDSL v
@@ -309,6 +313,9 @@ builtinsSrc =
309313
, B "Universal.>=" $ forall1 "a" (\a -> a --> a --> boolean)
310314
, B "Universal.<=" $ forall1 "a" (\a -> a --> a --> boolean)
311315

316+
, B "bug" $ forall1 "a" (\a -> forall1 "b" (\b -> a --> b))
317+
, B "todo" $ forall1 "a" (\a -> forall1 "b" (\b -> a --> b))
318+
312319
, B "Boolean.not" $ boolean --> boolean
313320

314321
, B "Text.empty" text

parser-typechecker/src/Unison/Codebase.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import qualified Unison.Codebase.Branch as Branch
1717
import qualified Unison.Codebase.CodeLookup as CL
1818
import qualified Unison.Codebase.Reflog as Reflog
1919
import qualified Unison.DataDeclaration as DD
20-
import Unison.Name ( Name(..) )
20+
import qualified Unison.Name as Name
2121
import qualified Unison.Names2 as Names
2222
import Unison.Reference ( Reference )
2323
import qualified Unison.Reference as Reference
@@ -89,8 +89,8 @@ data Codebase m v a =
8989
, branchHashesByPrefix :: ShortBranchHash -> m (Set Branch.Hash)
9090
}
9191

92-
bootstrapNames :: Names.Names0
93-
bootstrapNames =
92+
bootstrapNames :: Names.Names0
93+
bootstrapNames =
9494
Builtin.names0 <> UF.typecheckedToNames0 IOSource.typecheckedFile
9595

9696
-- | Write all of the builtins types and IO types into the codebase. Returns the names of builtins
@@ -110,7 +110,7 @@ initializeCodebase :: forall m. Monad m => Codebase m Symbol Parser.Ann -> m ()
110110
initializeCodebase c = do
111111
initializeBuiltinCode c
112112
let b0 = BranchUtil.addFromNames0
113-
(Names.prefix0 (Name "builtin") bootstrapNames)
113+
(Names.prefix0 (Name.unsafeFromText "builtin") bootstrapNames)
114114
Branch.empty0
115115
putRootBranch c (Branch.one b0)
116116

@@ -129,7 +129,7 @@ addDefsToCodebase c uf = do
129129
goType :: (t -> Decl v a) -> (Reference.Reference, t) -> m ()
130130
goType f (ref, decl) = case ref of
131131
Reference.DerivedId id -> putTypeDeclaration c id (f decl)
132-
_ -> pure ()
132+
Reference.Builtin{} -> pure ()
133133

134134
getTypeOfConstructor ::
135135
(Monad m, Ord v) => Codebase m v a -> Reference -> Int -> m (Maybe (Type v a))
@@ -155,7 +155,7 @@ typeLookupForDependencies codebase = foldM go mempty
155155
Just (Right dd) ->
156156
pure $ TypeLookup mempty (Map.singleton ref dd) mempty
157157
Nothing -> pure mempty
158-
go tl _builtin = pure tl -- codebase isn't consulted for builtins
158+
go tl Reference.Builtin{} = pure tl -- codebase isn't consulted for builtins
159159

160160
-- todo: can this be implemented in terms of TransitiveClosure.transitiveClosure?
161161
-- todo: add some tests on this guy?
@@ -186,7 +186,7 @@ transitiveDependencies code seen0 r = if Set.member r seen0
186186
Just (Right dd) -> foldM (transitiveDependencies code)
187187
seen
188188
(DD.dependencies dd)
189-
_ -> pure seen
189+
Reference.Builtin{} -> pure seen
190190

191191
toCodeLookup :: Codebase m v a -> CL.CodeLookup v m a
192192
toCodeLookup c = CL.CodeLookup (getTerm c) (getTypeDeclaration c)
@@ -205,12 +205,12 @@ makeSelfContained' code uf = do
205205
deps <- foldM (transitiveDependencies code) Set.empty (Set.unions deps0)
206206
decls <- fmap catMaybes . forM (toList deps) $ \case
207207
r@(Reference.DerivedId rid) -> fmap (r, ) <$> CL.getTypeDeclaration code rid
208-
_ -> pure Nothing
208+
Reference.Builtin{} -> pure Nothing
209209
let (es1, ds1) = partitionEithers [ bimap (r,) (r,) d | (r, d) <- decls ]
210210
bs1 <- fmap catMaybes . forM (toList deps) $ \case
211211
r@(Reference.DerivedId rid) ->
212212
fmap (r, ) <$> CL.getTerm code rid
213-
_ -> pure Nothing
213+
Reference.Builtin{} -> pure Nothing
214214
let
215215
allVars = Set.unions
216216
[ UF.allVars uf

0 commit comments

Comments
 (0)