Merge remote-tracking branch 'origin/trunk' into topic/getLine

# Conflicts:
#	unison-src/transcripts/alias-many.output.md
#	unison-src/transcripts/builtins-merge.output.md
#	unison-src/transcripts/emptyCodebase.output.md
#	unison-src/transcripts/merges.output.md
#	unison-src/transcripts/reflog.output.md
#	unison-src/transcripts/squash.output.md
This commit is contained in:
Paul Chiusano 2021-07-27 20:58:40 -04:00
commit 7b7801f8ae
18 changed files with 608 additions and 396 deletions

View File

@ -526,7 +526,7 @@ ioBuiltins =
, ("IO.setBuffering.impl.v3", handle --> bmode --> iof unit)
, ("IO.getBytes.impl.v3", handle --> nat --> iof bytes)
, ("IO.putBytes.impl.v3", handle --> bytes --> iof unit)
, ("IO.getLine.impl.v3", handle --> iof text)
, ("IO.getLine.impl.v1", handle --> iof text)
, ("IO.systemTime.impl.v3", unit --> iof nat)
, ("IO.getTempDirectory.impl.v3", unit --> iof text)
, ("IO.createTempDirectory.impl.v3", text --> iof text)

View File

@ -4,6 +4,7 @@
module Unison.Builtin.Decls where
import Control.Lens (_3,over)
import Data.List (elemIndex, find)
import qualified Data.Map as Map
import Data.Text (Text, unpack)
@ -30,10 +31,17 @@ import qualified Unison.Var as Var
lookupDeclRef :: Text -> Reference
lookupDeclRef str
| [(_, d, _)] <- filter (\(v, _, _) -> v == Var.named str) decls = Reference.DerivedId d
| [(_, d)] <- filter (\(v, _) -> v == Var.named str) decls = Reference.DerivedId d
| otherwise = error $ "lookupDeclRef: missing \"" ++ unpack str ++ "\""
where
decls = builtinDataDecls @Symbol
decls = [ (a,b) | (a,b,_) <- builtinDataDecls @Symbol ]
lookupEffectRef :: Text -> Reference
lookupEffectRef str
| [(_, d)] <- filter (\(v, _) -> v == Var.named str) decls = Reference.DerivedId d
| otherwise = error $ "lookupEffectRef: missing \"" ++ unpack str ++ "\""
where
decls = [ (a,b) | (a,b,_) <- builtinEffectDecls @Symbol ]
unitRef, pairRef, optionalRef, eitherRef :: Reference
unitRef = lookupDeclRef "Unit"
@ -43,7 +51,7 @@ eitherRef = lookupDeclRef "Either"
testResultRef, linkRef, docRef, ioErrorRef, stdHandleRef :: Reference
failureRef, ioFailureRef, tlsFailureRef :: Reference
tlsSignedCertRef, tlsPrivateKeyRef :: Reference
exceptionRef, tlsSignedCertRef, tlsPrivateKeyRef :: Reference
isPropagatedRef, isTestRef :: Reference
isPropagatedRef = lookupDeclRef "IsPropagated"
@ -54,6 +62,7 @@ docRef = lookupDeclRef "Doc"
ioErrorRef = lookupDeclRef "io2.IOError"
stdHandleRef = lookupDeclRef "io2.StdHandle"
failureRef = lookupDeclRef "io2.Failure"
exceptionRef = lookupEffectRef "Exception"
ioFailureRef = lookupDeclRef "io2.IOFailure"
tlsFailureRef = lookupDeclRef "io2.TlsFailure"
tlsSignedCertRef = lookupDeclRef "io2.Tls.SignedCert"
@ -295,8 +304,22 @@ builtinDataDecls = rs1 ++ rs
, ((), v "Link.Type", Type.typeLink () `arr` var "Link")
]
builtinEffectDecls :: [(v, Reference.Id, DD.EffectDeclaration v ())]
builtinEffectDecls = []
builtinEffectDecls :: Var v => [(v, Reference.Id, DD.EffectDeclaration v ())]
builtinEffectDecls =
case hashDecls $ Map.fromList [ (v "Exception", exception) ] of
Right a -> over _3 DD.EffectDeclaration <$> a
Left e -> error $ "builtinEffectDecls: " <> show e
where
v = Var.named
var name = Type.var () (v name)
arr = Type.arrow'
self t = Type.cleanupAbilityLists $ Type.effect () [var "Exception"] t
exception = DataDeclaration
Structural
()
[]
[ ((), v "Exception.raise", Type.forall () (v "x") (failureType () `arr` self (var "x")))
]
pattern UnitRef <- (unUnitRef -> True)
pattern PairRef <- (unPairRef -> True)
@ -347,7 +370,7 @@ pattern LinkType ty <- Term.App' (Term.Constructor' LinkRef LinkTypeId) ty
unitType, pairType, optionalType, testResultType,
eitherType, ioErrorType, fileModeType, filePathType, bufferModeType, seekModeType,
stdHandleType, failureType
stdHandleType, failureType, exceptionType
:: Ord v => a -> Type v a
unitType a = Type.ref a unitRef
pairType a = Type.ref a pairRef
@ -361,6 +384,7 @@ bufferModeType a = Type.ref a bufferModeRef
seekModeType a = Type.ref a seekModeRef
stdHandleType a = Type.ref a stdHandleRef
failureType a = Type.ref a failureRef
exceptionType a = Type.ref a exceptionRef
tlsSignedCertType :: Var v => a -> Type v a
tlsSignedCertType a = Type.ref a tlsSignedCertRef

View File

@ -1611,6 +1611,7 @@ loop = do
Right _ -> pure () -- TODO
IOTestI main -> do
-- todo - allow this to run tests from scratch file, using addRunMain
testType <- eval RuntimeTest
parseNames0 <- (`Names3.Names` mempty) <$> basicPrettyPrintNames0A
ppe <- prettyPrintEnv parseNames0
@ -1634,7 +1635,7 @@ loop = do
[Referent.Ref ref] -> do
typ <- loadTypeOfTerm (Referent.Ref ref)
case typ of
Just typ | Typechecker.isSubtype testType typ -> do
Just typ | Typechecker.isSubtype typ testType -> do
let a = ABT.annotation tm
tm = DD.forceTerm a a (Term.ref a ref) in do
-- v Don't cache IO tests
@ -1643,8 +1644,8 @@ loop = do
Left e -> respond (EvaluationFailure e)
Right tm' ->
respond $ TestResults Output.NewlyComputed ppe True True (oks [(ref, tm')]) (fails [(ref, tm')])
_ -> respond $ NoMainFunction "main" ppe [testType]
_ -> respond $ NoMainFunction "main" ppe [testType]
_ -> respond $ NoMainFunction (HQ.toString main) ppe [testType]
_ -> respond $ NoMainFunction (HQ.toString main) ppe [testType]
-- UpdateBuiltinsI -> do
-- stepAt updateBuiltins

View File

@ -54,17 +54,17 @@ getMainTerm loadTypeOfTerm parseNames0 mainName mainType =
_ -> pure (BadType mainName Nothing)
_ -> pure (NotFound mainName)
-- '{io2.IO} ()
-- '{io2.IO, Exception} ()
builtinMain :: Var v => a -> Type.Type v a
builtinMain a = Type.arrow a (Type.ref a DD.unitRef) io
where io = Type.effect1 a (Type.builtinIO a) (Type.ref a DD.unitRef)
where io = Type.effect a [Type.builtinIO a, DD.exceptionType a] (Type.ref a DD.unitRef)
-- [Result]
resultArr :: Ord v => a -> Type.Type v a
resultArr a = Type.app a (Type.ref a Type.listRef) (Type.ref a DD.testResultRef)
builtinResultArr :: Ord v => a -> Type.Type v a
builtinResultArr a = Type.effect1 a (Type.builtinIO a) (resultArr a)
builtinResultArr a = Type.effect a [Type.builtinIO a, DD.exceptionType a] (resultArr a)
-- '{io2.IO} [Result]
builtinTest :: Ord v => a -> Type.Type v a

View File

@ -681,6 +681,20 @@ watch
-> TLets Direct [] [] (TPrm PRNT [t])
$ TVar v
raise :: Var v => SuperNormal v
raise
= unop0 4 $ \[r,f,n,j,k]
-> TMatch r . flip (MatchData Ty.exceptionRef) Nothing $ mapFromList
[ (0, ([BX], TAbs f $ TVar f))
, (i, ([UN,BX]
, TAbss [j,f]
. TShift Ty.exceptionRef k
. TLetD n BX (TLit $ T "builtin.raise")
$ TPrm EROR [n, f]))
]
where
i = fromIntegral $ builtinTypeNumbering Map.! Ty.exceptionRef
code'missing :: Var v => SuperNormal v
code'missing
= unop0 1 $ \[link,b]
@ -1332,7 +1346,9 @@ builtinLookup
, ("Universal.>=", geu)
, ("Universal.<=", leu)
-- internal stuff
, ("jumpCont", jumpk)
, ("raise", raise)
, ("IO.forkComp.v2", fork'comp)
@ -1412,7 +1428,7 @@ declareForeigns = do
declareForeign "IO.setBuffering.impl.v3" set'buffering
. mkForeignIOF $ uncurry hSetBuffering
declareForeign "IO.getLine.impl.v3" boxToEFBox $ mkForeignIOF Text.hGetLine
declareForeign "IO.getLine.impl.v1" boxToEFBox $ mkForeignIOF Text.hGetLine
declareForeign "IO.getBytes.impl.v3" boxNatToEFBox . mkForeignIOF
$ \(h,n) -> Bytes.fromArray <$> hGet h n

View File

@ -110,7 +110,8 @@ decompileForeign topTerms f
= Right $ typeLink () l
| Just s <- unwrapSeq f
= list' () <$> traverse (decompile topTerms) s
decompileForeign _ f = err $ "cannot decompile Foreign: " ++ show f
decompileForeign _ f
= err $ "cannot decompile Foreign: " ++ show f
decompileBytes :: Var v => By.Bytes -> Term v ()
decompileBytes

View File

@ -299,6 +299,11 @@ bugMsg ppe name tm
\possible inputs"
, sorryMsg
]
| name == "builtin.raise" = P.callout icon . P.lines $
[ P.wrap ("The program halted with an unhandled exception:")
, ""
, P.indentN 2 $ pretty ppe tm
]
bugMsg ppe name tm = P.callout icon . P.lines $
[ P.wrap ("I've encountered a call to" <> P.red (P.text name)
<> "with the following value:")

View File

@ -33,6 +33,7 @@ import qualified Data.Primitive.PrimArray as PA
import Text.Read (readMaybe)
import Unison.Builtin.Decls (exceptionRef)
import Unison.Reference (Reference(Builtin))
import Unison.Referent (pattern Ref)
import Unison.Symbol (Symbol)
@ -105,9 +106,11 @@ baseCCache
ftm = 1 + maximum builtinTermNumbering
fty = 1 + maximum builtinTypeNumbering
rns = emptyRNs { dnum = refLookup "ty" builtinTypeNumbering }
combs
= mapWithKey
(\k v -> emitComb @Symbol emptyRNs k mempty (0,v))
(\k v -> emitComb @Symbol rns k mempty (0,v))
numberedTermLookup
info :: Show a => String -> a -> IO ()
@ -122,6 +125,19 @@ eval0 !env !co = do
bstk <- alloc
eval env mempty ustk bstk KE co
topDEnv
:: M.Map Reference Word64
-> M.Map Reference Word64
-> (DEnv, K -> K)
topDEnv rfTy rfTm
| Just n <- M.lookup exceptionRef rfTy
, rcrf <- Builtin (Tx.pack "raise")
, Just j <- M.lookup rcrf rfTm
= ( EC.mapSingleton n (PAp (CIx rcrf j 0) unull bnull)
, Mark (EC.setSingleton n) mempty
)
topDEnv _ _ = (mempty, id)
-- Entry point for evaluating a numbered combinator.
-- An optional callback for the base of the stack may be supplied.
--
@ -134,10 +150,12 @@ apply0 !callback !env !i = do
ustk <- alloc
bstk <- alloc
cmbrs <- readTVarIO $ combRefs env
(denv, kf) <-
topDEnv <$> readTVarIO (refTy env) <*> readTVarIO (refTm env)
r <- case EC.lookup i cmbrs of
Just r -> pure r
Nothing -> die "apply0: missing reference to entry point"
apply env mempty ustk bstk k0 True ZArgs
apply env denv ustk bstk (kf k0) True ZArgs
$ PAp (CIx r i 0) unull bnull
where
k0 = maybe KE (CB . Hook) callback

View File

@ -62,374 +62,376 @@ Let's try it!
42. type Either a b
43. Either.Left : a -> Either a b
44. Either.Right : b -> Either a b
45. builtin type Float
46. Float.* : Float -> Float -> Float
47. Float.+ : Float -> Float -> Float
48. Float.- : Float -> Float -> Float
49. Float./ : Float -> Float -> Float
50. Float.abs : Float -> Float
51. Float.acos : Float -> Float
52. Float.acosh : Float -> Float
53. Float.asin : Float -> Float
54. Float.asinh : Float -> Float
55. Float.atan : Float -> Float
56. Float.atan2 : Float -> Float -> Float
57. Float.atanh : Float -> Float
58. Float.ceiling : Float -> Int
59. Float.cos : Float -> Float
60. Float.cosh : Float -> Float
61. Float.eq : Float -> Float -> Boolean
62. Float.exp : Float -> Float
63. Float.floor : Float -> Int
64. Float.fromText : Text -> Optional Float
65. Float.gt : Float -> Float -> Boolean
66. Float.gteq : Float -> Float -> Boolean
67. Float.log : Float -> Float
68. Float.logBase : Float -> Float -> Float
69. Float.lt : Float -> Float -> Boolean
70. Float.lteq : Float -> Float -> Boolean
71. Float.max : Float -> Float -> Float
72. Float.min : Float -> Float -> Float
73. Float.pow : Float -> Float -> Float
74. Float.round : Float -> Int
75. Float.sin : Float -> Float
76. Float.sinh : Float -> Float
77. Float.sqrt : Float -> Float
78. Float.tan : Float -> Float
79. Float.tanh : Float -> Float
80. Float.toText : Float -> Text
81. Float.truncate : Float -> Int
82. builtin type Int
83. Int.* : Int -> Int -> Int
84. Int.+ : Int -> Int -> Int
85. Int.- : Int -> Int -> Int
86. Int./ : Int -> Int -> Int
87. Int.and : Int -> Int -> Int
88. Int.complement : Int -> Int
89. Int.eq : Int -> Int -> Boolean
90. Int.fromText : Text -> Optional Int
91. Int.gt : Int -> Int -> Boolean
92. Int.gteq : Int -> Int -> Boolean
93. Int.increment : Int -> Int
94. Int.isEven : Int -> Boolean
95. Int.isOdd : Int -> Boolean
96. Int.leadingZeros : Int -> Nat
97. Int.lt : Int -> Int -> Boolean
98. Int.lteq : Int -> Int -> Boolean
99. Int.mod : Int -> Int -> Int
100. Int.negate : Int -> Int
101. Int.or : Int -> Int -> Int
102. Int.popCount : Int -> Nat
103. Int.pow : Int -> Nat -> Int
104. Int.shiftLeft : Int -> Nat -> Int
105. Int.shiftRight : Int -> Nat -> Int
106. Int.signum : Int -> Int
107. Int.toFloat : Int -> Float
108. Int.toText : Int -> Text
109. Int.trailingZeros : Int -> Nat
110. Int.truncate0 : Int -> Nat
111. Int.xor : Int -> Int -> Int
112. unique type IsPropagated
113. IsPropagated.IsPropagated : IsPropagated
114. unique type IsTest
115. IsTest.IsTest : IsTest
116. unique type Link
117. builtin type Link.Term
118. Link.Term : Term -> Link
119. builtin type Link.Type
120. Link.Type : Type -> Link
121. builtin type List
122. List.++ : [a] -> [a] -> [a]
123. List.+: : a -> [a] -> [a]
124. List.:+ : [a] -> a -> [a]
125. List.at : Nat -> [a] -> Optional a
126. List.cons : a -> [a] -> [a]
127. List.drop : Nat -> [a] -> [a]
128. List.empty : [a]
129. List.size : [a] -> Nat
130. List.snoc : [a] -> a -> [a]
131. List.take : Nat -> [a] -> [a]
132. builtin type Nat
133. Nat.* : Nat -> Nat -> Nat
134. Nat.+ : Nat -> Nat -> Nat
135. Nat./ : Nat -> Nat -> Nat
136. Nat.and : Nat -> Nat -> Nat
137. Nat.complement : Nat -> Nat
138. Nat.drop : Nat -> Nat -> Nat
139. Nat.eq : Nat -> Nat -> Boolean
140. Nat.fromText : Text -> Optional Nat
141. Nat.gt : Nat -> Nat -> Boolean
142. Nat.gteq : Nat -> Nat -> Boolean
143. Nat.increment : Nat -> Nat
144. Nat.isEven : Nat -> Boolean
145. Nat.isOdd : Nat -> Boolean
146. Nat.leadingZeros : Nat -> Nat
147. Nat.lt : Nat -> Nat -> Boolean
148. Nat.lteq : Nat -> Nat -> Boolean
149. Nat.mod : Nat -> Nat -> Nat
150. Nat.or : Nat -> Nat -> Nat
151. Nat.popCount : Nat -> Nat
152. Nat.pow : Nat -> Nat -> Nat
153. Nat.shiftLeft : Nat -> Nat -> Nat
154. Nat.shiftRight : Nat -> Nat -> Nat
155. Nat.sub : Nat -> Nat -> Int
156. Nat.toFloat : Nat -> Float
157. Nat.toInt : Nat -> Int
158. Nat.toText : Nat -> Text
159. Nat.trailingZeros : Nat -> Nat
160. Nat.xor : Nat -> Nat -> Nat
161. type Optional a
162. Optional.None : Optional a
163. Optional.Some : a -> Optional a
164. builtin type Request
165. type SeqView a b
166. SeqView.VElem : a -> b -> SeqView a b
167. SeqView.VEmpty : SeqView a b
168. unique type Test.Result
169. Test.Result.Fail : Text -> Result
170. Test.Result.Ok : Text -> Result
171. builtin type Text
172. Text.!= : Text -> Text -> Boolean
173. Text.++ : Text -> Text -> Text
174. Text.drop : Nat -> Text -> Text
175. Text.empty : Text
176. Text.eq : Text -> Text -> Boolean
177. Text.fromCharList : [Char] -> Text
178. Text.fromUtf8.impl : Bytes -> Either Failure Text
179. Text.gt : Text -> Text -> Boolean
180. Text.gteq : Text -> Text -> Boolean
181. Text.lt : Text -> Text -> Boolean
182. Text.lteq : Text -> Text -> Boolean
183. Text.repeat : Nat -> Text -> Text
184. Text.size : Text -> Nat
185. Text.take : Nat -> Text -> Text
186. Text.toCharList : Text -> [Char]
187. Text.toUtf8 : Text -> Bytes
188. Text.uncons : Text -> Optional (Char, Text)
189. Text.unsnoc : Text -> Optional (Text, Char)
190. type Tuple a b
191. Tuple.Cons : a -> b -> Tuple a b
192. type Unit
193. Unit.Unit : ()
194. Universal.< : a -> a -> Boolean
195. Universal.<= : a -> a -> Boolean
196. Universal.== : a -> a -> Boolean
197. Universal.> : a -> a -> Boolean
198. Universal.>= : a -> a -> Boolean
199. Universal.compare : a -> a -> Int
200. builtin type Value
201. Value.dependencies : Value -> [Term]
202. Value.deserialize : Bytes -> Either Text Value
203. Value.load : Value ->{IO} Either [Term] a
204. Value.serialize : Value -> Bytes
205. Value.value : a -> Value
206. bug : a -> b
207. builtin type crypto.HashAlgorithm
208. crypto.HashAlgorithm.Blake2b_256 : HashAlgorithm
209. crypto.HashAlgorithm.Blake2b_512 : HashAlgorithm
210. crypto.HashAlgorithm.Blake2s_256 : HashAlgorithm
211. crypto.HashAlgorithm.Sha2_256 : HashAlgorithm
212. crypto.HashAlgorithm.Sha2_512 : HashAlgorithm
213. crypto.HashAlgorithm.Sha3_256 : HashAlgorithm
214. crypto.HashAlgorithm.Sha3_512 : HashAlgorithm
215. crypto.hash : HashAlgorithm -> a -> Bytes
216. crypto.hashBytes : HashAlgorithm -> Bytes -> Bytes
217. crypto.hmac : HashAlgorithm -> Bytes -> a -> Bytes
218. crypto.hmacBytes : HashAlgorithm
45. ability Exception
46. Exception.raise : Failure ->{Exception} x
47. builtin type Float
48. Float.* : Float -> Float -> Float
49. Float.+ : Float -> Float -> Float
50. Float.- : Float -> Float -> Float
51. Float./ : Float -> Float -> Float
52. Float.abs : Float -> Float
53. Float.acos : Float -> Float
54. Float.acosh : Float -> Float
55. Float.asin : Float -> Float
56. Float.asinh : Float -> Float
57. Float.atan : Float -> Float
58. Float.atan2 : Float -> Float -> Float
59. Float.atanh : Float -> Float
60. Float.ceiling : Float -> Int
61. Float.cos : Float -> Float
62. Float.cosh : Float -> Float
63. Float.eq : Float -> Float -> Boolean
64. Float.exp : Float -> Float
65. Float.floor : Float -> Int
66. Float.fromText : Text -> Optional Float
67. Float.gt : Float -> Float -> Boolean
68. Float.gteq : Float -> Float -> Boolean
69. Float.log : Float -> Float
70. Float.logBase : Float -> Float -> Float
71. Float.lt : Float -> Float -> Boolean
72. Float.lteq : Float -> Float -> Boolean
73. Float.max : Float -> Float -> Float
74. Float.min : Float -> Float -> Float
75. Float.pow : Float -> Float -> Float
76. Float.round : Float -> Int
77. Float.sin : Float -> Float
78. Float.sinh : Float -> Float
79. Float.sqrt : Float -> Float
80. Float.tan : Float -> Float
81. Float.tanh : Float -> Float
82. Float.toText : Float -> Text
83. Float.truncate : Float -> Int
84. builtin type Int
85. Int.* : Int -> Int -> Int
86. Int.+ : Int -> Int -> Int
87. Int.- : Int -> Int -> Int
88. Int./ : Int -> Int -> Int
89. Int.and : Int -> Int -> Int
90. Int.complement : Int -> Int
91. Int.eq : Int -> Int -> Boolean
92. Int.fromText : Text -> Optional Int
93. Int.gt : Int -> Int -> Boolean
94. Int.gteq : Int -> Int -> Boolean
95. Int.increment : Int -> Int
96. Int.isEven : Int -> Boolean
97. Int.isOdd : Int -> Boolean
98. Int.leadingZeros : Int -> Nat
99. Int.lt : Int -> Int -> Boolean
100. Int.lteq : Int -> Int -> Boolean
101. Int.mod : Int -> Int -> Int
102. Int.negate : Int -> Int
103. Int.or : Int -> Int -> Int
104. Int.popCount : Int -> Nat
105. Int.pow : Int -> Nat -> Int
106. Int.shiftLeft : Int -> Nat -> Int
107. Int.shiftRight : Int -> Nat -> Int
108. Int.signum : Int -> Int
109. Int.toFloat : Int -> Float
110. Int.toText : Int -> Text
111. Int.trailingZeros : Int -> Nat
112. Int.truncate0 : Int -> Nat
113. Int.xor : Int -> Int -> Int
114. unique type IsPropagated
115. IsPropagated.IsPropagated : IsPropagated
116. unique type IsTest
117. IsTest.IsTest : IsTest
118. unique type Link
119. builtin type Link.Term
120. Link.Term : Term -> Link
121. builtin type Link.Type
122. Link.Type : Type -> Link
123. builtin type List
124. List.++ : [a] -> [a] -> [a]
125. List.+: : a -> [a] -> [a]
126. List.:+ : [a] -> a -> [a]
127. List.at : Nat -> [a] -> Optional a
128. List.cons : a -> [a] -> [a]
129. List.drop : Nat -> [a] -> [a]
130. List.empty : [a]
131. List.size : [a] -> Nat
132. List.snoc : [a] -> a -> [a]
133. List.take : Nat -> [a] -> [a]
134. builtin type Nat
135. Nat.* : Nat -> Nat -> Nat
136. Nat.+ : Nat -> Nat -> Nat
137. Nat./ : Nat -> Nat -> Nat
138. Nat.and : Nat -> Nat -> Nat
139. Nat.complement : Nat -> Nat
140. Nat.drop : Nat -> Nat -> Nat
141. Nat.eq : Nat -> Nat -> Boolean
142. Nat.fromText : Text -> Optional Nat
143. Nat.gt : Nat -> Nat -> Boolean
144. Nat.gteq : Nat -> Nat -> Boolean
145. Nat.increment : Nat -> Nat
146. Nat.isEven : Nat -> Boolean
147. Nat.isOdd : Nat -> Boolean
148. Nat.leadingZeros : Nat -> Nat
149. Nat.lt : Nat -> Nat -> Boolean
150. Nat.lteq : Nat -> Nat -> Boolean
151. Nat.mod : Nat -> Nat -> Nat
152. Nat.or : Nat -> Nat -> Nat
153. Nat.popCount : Nat -> Nat
154. Nat.pow : Nat -> Nat -> Nat
155. Nat.shiftLeft : Nat -> Nat -> Nat
156. Nat.shiftRight : Nat -> Nat -> Nat
157. Nat.sub : Nat -> Nat -> Int
158. Nat.toFloat : Nat -> Float
159. Nat.toInt : Nat -> Int
160. Nat.toText : Nat -> Text
161. Nat.trailingZeros : Nat -> Nat
162. Nat.xor : Nat -> Nat -> Nat
163. type Optional a
164. Optional.None : Optional a
165. Optional.Some : a -> Optional a
166. builtin type Request
167. type SeqView a b
168. SeqView.VElem : a -> b -> SeqView a b
169. SeqView.VEmpty : SeqView a b
170. unique type Test.Result
171. Test.Result.Fail : Text -> Result
172. Test.Result.Ok : Text -> Result
173. builtin type Text
174. Text.!= : Text -> Text -> Boolean
175. Text.++ : Text -> Text -> Text
176. Text.drop : Nat -> Text -> Text
177. Text.empty : Text
178. Text.eq : Text -> Text -> Boolean
179. Text.fromCharList : [Char] -> Text
180. Text.fromUtf8.impl : Bytes -> Either Failure Text
181. Text.gt : Text -> Text -> Boolean
182. Text.gteq : Text -> Text -> Boolean
183. Text.lt : Text -> Text -> Boolean
184. Text.lteq : Text -> Text -> Boolean
185. Text.repeat : Nat -> Text -> Text
186. Text.size : Text -> Nat
187. Text.take : Nat -> Text -> Text
188. Text.toCharList : Text -> [Char]
189. Text.toUtf8 : Text -> Bytes
190. Text.uncons : Text -> Optional (Char, Text)
191. Text.unsnoc : Text -> Optional (Text, Char)
192. type Tuple a b
193. Tuple.Cons : a -> b -> Tuple a b
194. type Unit
195. Unit.Unit : ()
196. Universal.< : a -> a -> Boolean
197. Universal.<= : a -> a -> Boolean
198. Universal.== : a -> a -> Boolean
199. Universal.> : a -> a -> Boolean
200. Universal.>= : a -> a -> Boolean
201. Universal.compare : a -> a -> Int
202. builtin type Value
203. Value.dependencies : Value -> [Term]
204. Value.deserialize : Bytes -> Either Text Value
205. Value.load : Value ->{IO} Either [Term] a
206. Value.serialize : Value -> Bytes
207. Value.value : a -> Value
208. bug : a -> b
209. builtin type crypto.HashAlgorithm
210. crypto.HashAlgorithm.Blake2b_256 : HashAlgorithm
211. crypto.HashAlgorithm.Blake2b_512 : HashAlgorithm
212. crypto.HashAlgorithm.Blake2s_256 : HashAlgorithm
213. crypto.HashAlgorithm.Sha2_256 : HashAlgorithm
214. crypto.HashAlgorithm.Sha2_512 : HashAlgorithm
215. crypto.HashAlgorithm.Sha3_256 : HashAlgorithm
216. crypto.HashAlgorithm.Sha3_512 : HashAlgorithm
217. crypto.hash : HashAlgorithm -> a -> Bytes
218. crypto.hashBytes : HashAlgorithm -> Bytes -> Bytes
219. crypto.hmac : HashAlgorithm -> Bytes -> a -> Bytes
220. crypto.hmacBytes : HashAlgorithm
-> Bytes
-> Bytes
-> Bytes
219. unique type io2.BufferMode
220. io2.BufferMode.BlockBuffering : BufferMode
221. io2.BufferMode.LineBuffering : BufferMode
222. io2.BufferMode.NoBuffering : BufferMode
223. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode
224. unique type io2.Failure
225. io2.Failure.Failure : Type -> Text -> Any -> Failure
226. unique type io2.FileMode
227. io2.FileMode.Append : FileMode
228. io2.FileMode.Read : FileMode
229. io2.FileMode.ReadWrite : FileMode
230. io2.FileMode.Write : FileMode
231. builtin type io2.Handle
232. builtin type io2.IO
233. io2.IO.clientSocket.impl : Text
221. unique type io2.BufferMode
222. io2.BufferMode.BlockBuffering : BufferMode
223. io2.BufferMode.LineBuffering : BufferMode
224. io2.BufferMode.NoBuffering : BufferMode
225. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode
226. unique type io2.Failure
227. io2.Failure.Failure : Type -> Text -> Any -> Failure
228. unique type io2.FileMode
229. io2.FileMode.Append : FileMode
230. io2.FileMode.Read : FileMode
231. io2.FileMode.ReadWrite : FileMode
232. io2.FileMode.Write : FileMode
233. builtin type io2.Handle
234. builtin type io2.IO
235. io2.IO.clientSocket.impl : Text
-> Text
->{IO} Either Failure Socket
234. io2.IO.closeFile.impl : Handle ->{IO} Either Failure ()
235. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure ()
236. io2.IO.createDirectory.impl : Text
236. io2.IO.closeFile.impl : Handle ->{IO} Either Failure ()
237. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure ()
238. io2.IO.createDirectory.impl : Text
->{IO} Either Failure ()
237. io2.IO.createTempDirectory.impl : Text
239. io2.IO.createTempDirectory.impl : Text
->{IO} Either
Failure Text
238. io2.IO.delay.impl : Nat ->{IO} Either Failure ()
239. io2.IO.directoryContents.impl : Text
240. io2.IO.delay.impl : Nat ->{IO} Either Failure ()
241. io2.IO.directoryContents.impl : Text
->{IO} Either
Failure [Text]
240. io2.IO.fileExists.impl : Text
242. io2.IO.fileExists.impl : Text
->{IO} Either Failure Boolean
241. io2.IO.forkComp : '{IO} a ->{IO} ThreadId
242. io2.IO.getBuffering.impl : Handle
243. io2.IO.forkComp : '{IO} a ->{IO} ThreadId
244. io2.IO.getBuffering.impl : Handle
->{IO} Either
Failure BufferMode
243. io2.IO.getBytes.impl : Handle
245. io2.IO.getBytes.impl : Handle
-> Nat
->{IO} Either Failure Bytes
244. io2.IO.getCurrentDirectory.impl : '{IO} Either
246. io2.IO.getCurrentDirectory.impl : '{IO} Either
Failure Text
245. io2.IO.getEnv.impl : Text ->{IO} Either Failure Text
246. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat
247. io2.IO.getFileTimestamp.impl : Text
247. io2.IO.getEnv.impl : Text ->{IO} Either Failure Text
248. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat
249. io2.IO.getFileTimestamp.impl : Text
->{IO} Either Failure Nat
248. io2.IO.getLine.impl : Handle ->{IO} Either Failure Text
249. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text
250. io2.IO.handlePosition.impl : Handle
250. io2.IO.getLine.impl : Handle ->{IO} Either Failure Text
251. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text
252. io2.IO.handlePosition.impl : Handle
->{IO} Either Failure Nat
251. io2.IO.isDirectory.impl : Text
253. io2.IO.isDirectory.impl : Text
->{IO} Either Failure Boolean
252. io2.IO.isFileEOF.impl : Handle
254. io2.IO.isFileEOF.impl : Handle
->{IO} Either Failure Boolean
253. io2.IO.isFileOpen.impl : Handle
255. io2.IO.isFileOpen.impl : Handle
->{IO} Either Failure Boolean
254. io2.IO.isSeekable.impl : Handle
256. io2.IO.isSeekable.impl : Handle
->{IO} Either Failure Boolean
255. io2.IO.kill.impl : ThreadId ->{IO} Either Failure ()
256. io2.IO.listen.impl : Socket ->{IO} Either Failure ()
257. io2.IO.openFile.impl : Text
257. io2.IO.kill.impl : ThreadId ->{IO} Either Failure ()
258. io2.IO.listen.impl : Socket ->{IO} Either Failure ()
259. io2.IO.openFile.impl : Text
-> FileMode
->{IO} Either Failure Handle
258. io2.IO.putBytes.impl : Handle
260. io2.IO.putBytes.impl : Handle
-> Bytes
->{IO} Either Failure ()
259. io2.IO.removeDirectory.impl : Text
261. io2.IO.removeDirectory.impl : Text
->{IO} Either Failure ()
260. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
261. io2.IO.renameDirectory.impl : Text
262. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
263. io2.IO.renameDirectory.impl : Text
-> Text
->{IO} Either Failure ()
262. io2.IO.renameFile.impl : Text
264. io2.IO.renameFile.impl : Text
-> Text
->{IO} Either Failure ()
263. io2.IO.seekHandle.impl : Handle
265. io2.IO.seekHandle.impl : Handle
-> SeekMode
-> Int
->{IO} Either Failure ()
264. io2.IO.serverSocket.impl : Optional Text
266. io2.IO.serverSocket.impl : Optional Text
-> Text
->{IO} Either Failure Socket
265. io2.IO.setBuffering.impl : Handle
267. io2.IO.setBuffering.impl : Handle
-> BufferMode
->{IO} Either Failure ()
266. io2.IO.setCurrentDirectory.impl : Text
268. io2.IO.setCurrentDirectory.impl : Text
->{IO} Either
Failure ()
267. io2.IO.socketAccept.impl : Socket
269. io2.IO.socketAccept.impl : Socket
->{IO} Either Failure Socket
268. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
269. io2.IO.socketReceive.impl : Socket
270. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
271. io2.IO.socketReceive.impl : Socket
-> Nat
->{IO} Either Failure Bytes
270. io2.IO.socketSend.impl : Socket
272. io2.IO.socketSend.impl : Socket
-> Bytes
->{IO} Either Failure ()
271. io2.IO.stdHandle : StdHandle -> Handle
272. io2.IO.systemTime.impl : '{IO} Either Failure Nat
273. unique type io2.IOError
274. io2.IOError.AlreadyExists : IOError
275. io2.IOError.EOF : IOError
276. io2.IOError.IllegalOperation : IOError
277. io2.IOError.NoSuchThing : IOError
278. io2.IOError.PermissionDenied : IOError
279. io2.IOError.ResourceBusy : IOError
280. io2.IOError.ResourceExhausted : IOError
281. io2.IOError.UserError : IOError
282. unique type io2.IOFailure
283. builtin type io2.MVar
284. io2.MVar.isEmpty : MVar a ->{IO} Boolean
285. io2.MVar.new : a ->{IO} MVar a
286. io2.MVar.newEmpty : '{IO} MVar a
287. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
288. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
289. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
290. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
291. io2.MVar.tryPut.impl : MVar a
273. io2.IO.stdHandle : StdHandle -> Handle
274. io2.IO.systemTime.impl : '{IO} Either Failure Nat
275. unique type io2.IOError
276. io2.IOError.AlreadyExists : IOError
277. io2.IOError.EOF : IOError
278. io2.IOError.IllegalOperation : IOError
279. io2.IOError.NoSuchThing : IOError
280. io2.IOError.PermissionDenied : IOError
281. io2.IOError.ResourceBusy : IOError
282. io2.IOError.ResourceExhausted : IOError
283. io2.IOError.UserError : IOError
284. unique type io2.IOFailure
285. builtin type io2.MVar
286. io2.MVar.isEmpty : MVar a ->{IO} Boolean
287. io2.MVar.new : a ->{IO} MVar a
288. io2.MVar.newEmpty : '{IO} MVar a
289. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
290. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
291. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
292. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
293. io2.MVar.tryPut.impl : MVar a
-> a
->{IO} Either Failure Boolean
292. io2.MVar.tryRead.impl : MVar a
294. io2.MVar.tryRead.impl : MVar a
->{IO} Either
Failure (Optional a)
293. io2.MVar.tryTake : MVar a ->{IO} Optional a
294. builtin type io2.STM
295. io2.STM.atomically : '{STM} a ->{IO} a
296. io2.STM.retry : '{STM} a
297. unique type io2.SeekMode
298. io2.SeekMode.AbsoluteSeek : SeekMode
299. io2.SeekMode.RelativeSeek : SeekMode
300. io2.SeekMode.SeekFromEnd : SeekMode
301. builtin type io2.Socket
302. unique type io2.StdHandle
303. io2.StdHandle.StdErr : StdHandle
304. io2.StdHandle.StdIn : StdHandle
305. io2.StdHandle.StdOut : StdHandle
306. io2.TLS.ClientConfig.ciphers.set : [Cipher]
295. io2.MVar.tryTake : MVar a ->{IO} Optional a
296. builtin type io2.STM
297. io2.STM.atomically : '{STM} a ->{IO} a
298. io2.STM.retry : '{STM} a
299. unique type io2.SeekMode
300. io2.SeekMode.AbsoluteSeek : SeekMode
301. io2.SeekMode.RelativeSeek : SeekMode
302. io2.SeekMode.SeekFromEnd : SeekMode
303. builtin type io2.Socket
304. unique type io2.StdHandle
305. io2.StdHandle.StdErr : StdHandle
306. io2.StdHandle.StdIn : StdHandle
307. io2.StdHandle.StdOut : StdHandle
308. io2.TLS.ClientConfig.ciphers.set : [Cipher]
-> ClientConfig
-> ClientConfig
307. builtin type io2.TVar
308. io2.TVar.new : a ->{STM} TVar a
309. io2.TVar.newIO : a ->{IO} TVar a
310. io2.TVar.read : TVar a ->{STM} a
311. io2.TVar.readIO : TVar a ->{IO} a
312. io2.TVar.swap : TVar a -> a ->{STM} a
313. io2.TVar.write : TVar a -> a ->{STM} ()
314. builtin type io2.ThreadId
315. builtin type io2.Tls
316. builtin type io2.Tls.Cipher
317. builtin type io2.Tls.ClientConfig
318. io2.Tls.ClientConfig.certificates.set : [SignedCert]
309. builtin type io2.TVar
310. io2.TVar.new : a ->{STM} TVar a
311. io2.TVar.newIO : a ->{IO} TVar a
312. io2.TVar.read : TVar a ->{STM} a
313. io2.TVar.readIO : TVar a ->{IO} a
314. io2.TVar.swap : TVar a -> a ->{STM} a
315. io2.TVar.write : TVar a -> a ->{STM} ()
316. builtin type io2.ThreadId
317. builtin type io2.Tls
318. builtin type io2.Tls.Cipher
319. builtin type io2.Tls.ClientConfig
320. io2.Tls.ClientConfig.certificates.set : [SignedCert]
-> ClientConfig
-> ClientConfig
319. io2.Tls.ClientConfig.default : Text
321. io2.Tls.ClientConfig.default : Text
-> Bytes
-> ClientConfig
320. io2.Tls.ClientConfig.versions.set : [Version]
322. io2.Tls.ClientConfig.versions.set : [Version]
-> ClientConfig
-> ClientConfig
321. builtin type io2.Tls.PrivateKey
322. builtin type io2.Tls.ServerConfig
323. io2.Tls.ServerConfig.certificates.set : [SignedCert]
323. builtin type io2.Tls.PrivateKey
324. builtin type io2.Tls.ServerConfig
325. io2.Tls.ServerConfig.certificates.set : [SignedCert]
-> ServerConfig
-> ServerConfig
324. io2.Tls.ServerConfig.ciphers.set : [Cipher]
326. io2.Tls.ServerConfig.ciphers.set : [Cipher]
-> ServerConfig
-> ServerConfig
325. io2.Tls.ServerConfig.default : [SignedCert]
327. io2.Tls.ServerConfig.default : [SignedCert]
-> PrivateKey
-> ServerConfig
326. io2.Tls.ServerConfig.versions.set : [Version]
328. io2.Tls.ServerConfig.versions.set : [Version]
-> ServerConfig
-> ServerConfig
327. builtin type io2.Tls.SignedCert
328. builtin type io2.Tls.Version
329. io2.Tls.decodeCert.impl : Bytes
329. builtin type io2.Tls.SignedCert
330. builtin type io2.Tls.Version
331. io2.Tls.decodeCert.impl : Bytes
-> Either Failure SignedCert
330. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
331. io2.Tls.encodeCert : SignedCert -> Bytes
332. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
333. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
334. io2.Tls.newClient.impl : ClientConfig
332. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
333. io2.Tls.encodeCert : SignedCert -> Bytes
334. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
335. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
336. io2.Tls.newClient.impl : ClientConfig
-> Socket
->{IO} Either Failure Tls
335. io2.Tls.newServer.impl : ServerConfig
337. io2.Tls.newServer.impl : ServerConfig
-> Socket
->{IO} Either Failure Tls
336. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
337. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
338. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
339. unique type io2.TlsFailure
340. metadata.isPropagated : IsPropagated
341. metadata.isTest : IsTest
342. todo : a -> b
338. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
339. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
340. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
341. unique type io2.TlsFailure
342. metadata.isPropagated : IsPropagated
343. metadata.isTest : IsTest
344. todo : a -> b
.builtin> alias.many 94-104 .mylib
@ -438,17 +440,17 @@ Let's try it!
Added definitions:
1. Int.isEven : Int -> Boolean
2. Int.isOdd : Int -> Boolean
3. Int.leadingZeros : Int -> Nat
4. Int.lt : Int -> Int -> Boolean
5. Int.lteq : Int -> Int -> Boolean
6. Int.mod : Int -> Int -> Int
7. Int.negate : Int -> Int
8. Int.or : Int -> Int -> Int
9. Int.popCount : Int -> Nat
10. Int.pow : Int -> Nat -> Int
11. Int.shiftLeft : Int -> Nat -> Int
1. Int.gteq : Int -> Int -> Boolean
2. Int.increment : Int -> Int
3. Int.isEven : Int -> Boolean
4. Int.isOdd : Int -> Boolean
5. Int.leadingZeros : Int -> Nat
6. Int.lt : Int -> Int -> Boolean
7. Int.lteq : Int -> Int -> Boolean
8. Int.mod : Int -> Int -> Int
9. Int.negate : Int -> Int
10. Int.or : Int -> Int -> Int
11. Int.popCount : Int -> Nat
Tip: You can use `undo` or `reflog` to undo this change.
@ -508,17 +510,17 @@ I want to incorporate a few more from another namespace:
.mylib> find
1. Int.isEven : Int -> Boolean
2. Int.isOdd : Int -> Boolean
3. Int.leadingZeros : Int -> Nat
4. Int.lt : Int -> Int -> Boolean
5. Int.lteq : Int -> Int -> Boolean
6. Int.mod : Int -> Int -> Int
7. Int.negate : Int -> Int
8. Int.or : Int -> Int -> Int
9. Int.popCount : Int -> Nat
10. Int.pow : Int -> Nat -> Int
11. Int.shiftLeft : Int -> Nat -> Int
1. Int.gteq : Int -> Int -> Boolean
2. Int.increment : Int -> Int
3. Int.isEven : Int -> Boolean
4. Int.isOdd : Int -> Boolean
5. Int.leadingZeros : Int -> Nat
6. Int.lt : Int -> Int -> Boolean
7. Int.lteq : Int -> Int -> Boolean
8. Int.mod : Int -> Int -> Int
9. Int.negate : Int -> Int
10. Int.or : Int -> Int -> Int
11. Int.popCount : Int -> Nat
12. List.adjacentPairs : [a] -> [(a, a)]
13. List.all : (a ->{g} Boolean) -> [a] ->{g} Boolean
14. List.any : (a ->{g} Boolean) -> [a] ->{g} Boolean

View File

@ -24,39 +24,41 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
13. Doc/ (6 definitions)
14. Either (type)
15. Either/ (2 definitions)
16. Float (builtin type)
17. Float/ (36 definitions)
18. Int (builtin type)
19. Int/ (29 definitions)
20. IsPropagated (type)
21. IsPropagated/ (1 definition)
22. IsTest (type)
23. IsTest/ (1 definition)
24. Link (type)
25. Link/ (4 definitions)
26. List (builtin type)
27. List/ (10 definitions)
28. Nat (builtin type)
29. Nat/ (28 definitions)
30. Optional (type)
31. Optional/ (2 definitions)
32. Request (builtin type)
33. SeqView (type)
34. SeqView/ (2 definitions)
35. Test/ (3 definitions)
36. Text (builtin type)
37. Text/ (18 definitions)
38. Tuple (type)
39. Tuple/ (1 definition)
40. Unit (type)
41. Unit/ (1 definition)
42. Universal/ (6 definitions)
43. Value (builtin type)
44. Value/ (5 definitions)
45. bug (a -> b)
46. crypto/ (12 definitions)
47. io2/ (121 definitions)
48. metadata/ (2 definitions)
49. todo (a -> b)
16. Exception (type)
17. Exception/ (1 definition)
18. Float (builtin type)
19. Float/ (36 definitions)
20. Int (builtin type)
21. Int/ (29 definitions)
22. IsPropagated (type)
23. IsPropagated/ (1 definition)
24. IsTest (type)
25. IsTest/ (1 definition)
26. Link (type)
27. Link/ (4 definitions)
28. List (builtin type)
29. List/ (10 definitions)
30. Nat (builtin type)
31. Nat/ (28 definitions)
32. Optional (type)
33. Optional/ (2 definitions)
34. Request (builtin type)
35. SeqView (type)
36. SeqView/ (2 definitions)
37. Test/ (3 definitions)
38. Text (builtin type)
39. Text/ (18 definitions)
40. Tuple (type)
41. Tuple/ (1 definition)
42. Unit (type)
43. Unit/ (1 definition)
44. Universal/ (6 definitions)
45. Value (builtin type)
46. Value/ (5 definitions)
47. bug (a -> b)
48. crypto/ (12 definitions)
49. io2/ (121 definitions)
50. metadata/ (2 definitions)
51. todo (a -> b)
```

View File

@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge`
.foo> ls
1. builtin/ (342 definitions)
1. builtin/ (344 definitions)
```
And for a limited time, you can get even more builtin goodies:
@ -35,7 +35,7 @@ And for a limited time, you can get even more builtin goodies:
.foo> ls
1. builtin/ (510 definitions)
1. builtin/ (512 definitions)
```
More typically, you'd start out by pulling `base.

View File

@ -83,7 +83,7 @@ This shouldn't work since `main4` and `main5` don't have the right type.
but in order for me to `run` it it needs to have the type:
main4 : '{IO} ()
main4 : '{IO, Exception} ()
```
```ucm
@ -97,6 +97,6 @@ This shouldn't work since `main4` and `main5` don't have the right type.
but in order for me to `run` it it needs to have the type:
main5 : '{IO} ()
main5 : '{IO, Exception} ()
```

View File

@ -44,6 +44,7 @@ Exception.unsafeRun! e _ =
⍟ These new definitions are ok to `add`:
ability Exception
(also named builtin.Exception)
Exception.unsafeRun! : '{g, Exception} a -> '{g} a
compose2 : (c ->{𝕖1} d)
-> (a ->{𝕖2} b ->{𝕖3} c)

View File

@ -112,13 +112,13 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
Note: The most recent namespace hash is immediately below this
message.
#hf0r2vielv
#eraul07f6n
- Deletes:
feature1.y
#78l05i95dg
#oa2kh8deo4
+ Adds / updates:
@ -129,26 +129,26 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
Original name New name(s)
feature1.y master.y
#020p2ctrf9
#cbbrgnuo8e
+ Adds / updates:
feature1.y
#oc4ih372qb
#4f06hp17pe
> Moves:
Original name New name
x master.x
#6ndmntmtke
#ipq9jkfidc
+ Adds / updates:
x
#5q4a1uakk0 (start of history)
#h7afdpjcd7 (start of history)
```
To resurrect an old version of a namespace, you can learn its hash via the `history` command, then use `fork #namespacehash .newname`.

View File

@ -59,16 +59,16 @@ y = 2
most recent, along with the command that got us there. Try:
`fork 2 .old`
`fork #lb11cgjfoj .old` to make an old namespace
`fork #rrthe3dfnk .old` to make an old namespace
accessible again,
`reset-root #lb11cgjfoj` to reset the root namespace and
`reset-root #rrthe3dfnk` to reset the root namespace and
its history to that of the
specified namespace.
1. #aagqlgmprq : add
2. #lb11cgjfoj : add
3. #5q4a1uakk0 : builtins.merge
1. #lpbpk60m5g : add
2. #rrthe3dfnk : add
3. #h7afdpjcd7 : builtins.merge
4. #sjg2v58vn2 : (initial reflogged namespace)
```

View File

@ -13,7 +13,7 @@ Let's look at some examples. We'll start with a namespace with just the builtins
#v458a2k4fj (start of history)
#nnblbf478i (start of history)
.> fork builtin builtin2
@ -42,21 +42,21 @@ Now suppose we `fork` a copy of builtin, then rename `Nat.+` to `frobnicate`, th
Note: The most recent namespace hash is immediately below this
message.
#krcds8876f
#0upg8161p3
> Moves:
Original name New name
Nat.frobnicate Nat.+
#293sdub4p4
#qqpckf5btu
> Moves:
Original name New name
Nat.+ Nat.frobnicate
#v458a2k4fj (start of history)
#nnblbf478i (start of history)
```
If we merge that back into `builtin`, we get that same chain of history:
@ -71,21 +71,21 @@ If we merge that back into `builtin`, we get that same chain of history:
Note: The most recent namespace hash is immediately below this
message.
#krcds8876f
#0upg8161p3
> Moves:
Original name New name
Nat.frobnicate Nat.+
#293sdub4p4
#qqpckf5btu
> Moves:
Original name New name
Nat.+ Nat.frobnicate
#v458a2k4fj (start of history)
#nnblbf478i (start of history)
```
Let's try again, but using a `merge.squash` (or just `squash`) instead. The history will be unchanged:
@ -106,7 +106,7 @@ Let's try again, but using a `merge.squash` (or just `squash`) instead. The hist
#v458a2k4fj (start of history)
#nnblbf478i (start of history)
```
The churn that happened in `mybuiltin` namespace ended up back in the same spot, so the squash merge of that namespace with our original namespace had no effect.
@ -485,13 +485,13 @@ This checks to see that squashing correctly preserves deletions:
Note: The most recent namespace hash is immediately below this
message.
#n8ab4r778i
#pg8337afdk
- Deletes:
Nat.* Nat.+
#v458a2k4fj (start of history)
#nnblbf478i (start of history)
```
Notice that `Nat.+` and `Nat.*` are deleted by the squash, and we see them deleted in one atomic step in the history.

View File

@ -0,0 +1,46 @@
A simple transcript to test the use of exceptions that bubble to the top level.
```ucm:hide
.> builtins.merge
```
FYI, here are the `Exception` and `Failure` types:
```ucm
.> view Exception Failure
```
Here's a sample program just to verify that the typechecker allows `run` to throw exceptions:
```unison
use builtin IO Exception Test.Result
main : '{IO, Exception} ()
main _ = ()
mytest : '{IO, Exception} [Test.Result]
mytest _ = [Ok "Great"]
```
```ucm
.> run main
.> add
.> io.test mytest
```
Now a test to show the handling of uncaught exceptions:
```unison
main2 = '(error "oh noes!" ())
error : Text -> a ->{Exception} x
error msg a =
builtin.Exception.raise (Failure (typeLink RuntimeError) msg (Any a))
unique type RuntimeError =
```
```ucm:error
.> run main2
```

View File

@ -0,0 +1,96 @@
A simple transcript to test the use of exceptions that bubble to the top level.
FYI, here are the `Exception` and `Failure` types:
```ucm
.> view Exception Failure
ability builtin.Exception where
raise : Failure ->{builtin.Exception} x
unique type builtin.io2.Failure
= Failure Type Text Any
```
Here's a sample program just to verify that the typechecker allows `run` to throw exceptions:
```unison
use builtin IO Exception Test.Result
main : '{IO, Exception} ()
main _ = ()
mytest : '{IO, Exception} [Test.Result]
mytest _ = [Ok "Great"]
```
```ucm
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
main : '{IO, Exception} ()
mytest : '{IO, Exception} [Result]
```
```ucm
.> run main
.> add
⍟ I've added these definitions:
main : '{IO, Exception} ()
mytest : '{IO, Exception} [Result]
.> io.test mytest
New test results:
◉ mytest Great
✅ 1 test(s) passing
Tip: Use view mytest to view the source of a test.
```
Now a test to show the handling of uncaught exceptions:
```unison
main2 = '(error "oh noes!" ())
error : Text -> a ->{Exception} x
error msg a =
builtin.Exception.raise (Failure (typeLink RuntimeError) msg (Any a))
unique type RuntimeError =
```
```ucm
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
unique type RuntimeError
error : Text -> a ->{Exception} x
main2 : '{Exception} r
```
```ucm
.> run main2
💔💥
The program halted with an unhandled exception:
builtin.io2.Failure.Failure
(typeLink RuntimeError) "oh noes!" !builtin.Any.Any
```