mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-21 15:28:15 +03:00
Merge branch 'trunk' into structural-kw#2251
This commit is contained in:
commit
0b2053ae8f
@ -179,6 +179,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
|
||||
@ -465,6 +467,14 @@ builtinsSrc =
|
||||
, 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)
|
||||
@ -576,6 +586,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)
|
||||
@ -648,6 +660,15 @@ 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
|
||||
@ -694,6 +715,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 ()
|
||||
|
@ -77,6 +77,12 @@ import Network.Simple.TCP as SYS
|
||||
import Network.TLS as TLS
|
||||
import Network.TLS.Extra.Cipher as Cipher
|
||||
|
||||
import Data.IORef as SYS
|
||||
( IORef
|
||||
, newIORef
|
||||
, readIORef
|
||||
, writeIORef
|
||||
)
|
||||
import System.IO as SYS
|
||||
( IOMode(..)
|
||||
, openFile
|
||||
@ -672,6 +678,12 @@ poly'coerce = unop0 0 $ \[x] -> TVar x
|
||||
jumpk :: Var v => SuperNormal v
|
||||
jumpk = binop0 0 $ \[k,a] -> TKon k [a]
|
||||
|
||||
scope'run :: Var v => SuperNormal v
|
||||
scope'run
|
||||
= unop0 1 $ \[e, un]
|
||||
-> TLetD un BX (TCon Ty.unitRef 0 [])
|
||||
$ TApp (FVar e) [un]
|
||||
|
||||
fork'comp :: Var v => SuperNormal v
|
||||
fork'comp
|
||||
= Lambda [BX]
|
||||
@ -1417,6 +1429,8 @@ builtinLookup
|
||||
|
||||
, ("IO.forkComp.v2", fork'comp)
|
||||
|
||||
, ("Scope.run", scope'run)
|
||||
|
||||
, ("Code.isMissing", code'missing)
|
||||
, ("Code.cache_", code'cache)
|
||||
, ("Code.lookup", code'lookup)
|
||||
@ -1620,6 +1634,7 @@ declareForeigns = do
|
||||
declareForeign "MVar.tryRead.impl.v3" boxToEFMBox
|
||||
. mkForeignIOF $ \(mv :: MVar Closure) -> tryReadMVar mv
|
||||
|
||||
|
||||
declareForeign "Char.toText" (wordDirect Ty.charRef) . mkForeign $
|
||||
\(ch :: Char) -> pure (Text.singleton ch)
|
||||
|
||||
@ -1679,6 +1694,19 @@ declareForeigns = do
|
||||
declareForeign "STM.retry" unitDirect . mkForeign
|
||||
$ \() -> unsafeSTMToIO STM.retry :: IO Closure
|
||||
|
||||
-- Scope and Ref stuff
|
||||
declareForeign "Scope.ref" boxDirect
|
||||
. mkForeign $ \(c :: Closure) -> newIORef c
|
||||
|
||||
declareForeign "IO.ref" boxDirect
|
||||
. mkForeign $ \(c :: Closure) -> newIORef c
|
||||
|
||||
declareForeign "Ref.read" boxDirect . mkForeign $
|
||||
\(r :: IORef Closure) -> readIORef r
|
||||
|
||||
declareForeign "Ref.write" boxBoxTo0 . mkForeign $
|
||||
\(r :: IORef Closure, c :: Closure) -> writeIORef r c
|
||||
|
||||
let
|
||||
defaultSupported :: TLS.Supported
|
||||
defaultSupported = def { TLS.supportedCiphers = Cipher.ciphersuite_strong }
|
||||
|
@ -17,6 +17,7 @@ module Unison.Runtime.Foreign
|
||||
) where
|
||||
|
||||
import Control.Concurrent (ThreadId, MVar)
|
||||
import Data.IORef (IORef)
|
||||
import Data.Text (Text, unpack)
|
||||
import Data.Tagged (Tagged(..))
|
||||
import Network.Socket (Socket)
|
||||
@ -47,6 +48,8 @@ ref2eq r
|
||||
-- Note: MVar equality is just reference equality, so it shouldn't
|
||||
-- matter what type the MVar holds.
|
||||
| r == Ty.mvarRef = Just $ promote ((==) @(MVar ()))
|
||||
-- Ditto
|
||||
| r == Ty.refRef = Just $ promote ((==) @(IORef ()))
|
||||
| otherwise = Nothing
|
||||
|
||||
ref2cmp :: Reference -> Maybe (a -> b -> Ordering)
|
||||
|
@ -18,6 +18,7 @@ import Control.Concurrent.MVar (MVar)
|
||||
import Control.Concurrent.STM (TVar)
|
||||
import Control.Exception (evaluate)
|
||||
import qualified Data.Char as Char
|
||||
import Data.IORef (IORef)
|
||||
import Data.Foldable (toList)
|
||||
import Data.Text (Text, pack, unpack)
|
||||
import Data.Time.Clock.POSIX (POSIXTime)
|
||||
@ -28,7 +29,7 @@ import System.IO (BufferMode(..), SeekMode, Handle, IOMode)
|
||||
import Unison.Util.Bytes (Bytes)
|
||||
|
||||
import Unison.Reference (Reference)
|
||||
import Unison.Type (mvarRef, tvarRef, typeLinkRef)
|
||||
import Unison.Type (mvarRef, tvarRef, typeLinkRef, refRef)
|
||||
import Unison.Symbol (Symbol)
|
||||
|
||||
import Unison.Runtime.ANF (SuperGroup, Mem(..), Value, internalBug)
|
||||
@ -348,6 +349,10 @@ instance ForeignConvention (TVar Closure) where
|
||||
readForeign = readForeignAs (unwrapForeign . marshalToForeign)
|
||||
writeForeign = writeForeignAs (Foreign . Wrap tvarRef)
|
||||
|
||||
instance ForeignConvention (IORef Closure) where
|
||||
readForeign = readForeignAs (unwrapForeign . marshalToForeign)
|
||||
writeForeign = writeForeignAs (Foreign . Wrap refRef)
|
||||
|
||||
instance ForeignConvention (SuperGroup Symbol) where
|
||||
readForeign = readForeignBuiltin
|
||||
writeForeign = writeForeignBuiltin
|
||||
|
@ -22,7 +22,7 @@ packages:
|
||||
- codebase2/util-term
|
||||
|
||||
#compiler-check: match-exact
|
||||
resolver: lts-17.15
|
||||
resolver: lts-18.7
|
||||
|
||||
extra-deps:
|
||||
- github: unisonweb/configurator
|
||||
|
@ -227,6 +227,10 @@ filePathRef = Reference.Builtin "FilePath"
|
||||
threadIdRef = Reference.Builtin "ThreadId"
|
||||
socketRef = Reference.Builtin "Socket"
|
||||
|
||||
scopeRef, refRef :: Reference
|
||||
scopeRef = Reference.Builtin "Scope"
|
||||
refRef = Reference.Builtin "Ref"
|
||||
|
||||
mvarRef, tvarRef :: Reference
|
||||
mvarRef = Reference.Builtin "MVar"
|
||||
tvarRef = Reference.Builtin "TVar"
|
||||
@ -298,6 +302,12 @@ threadId a = ref a threadIdRef
|
||||
builtinIO :: Ord v => a -> Type v a
|
||||
builtinIO a = ref a builtinIORef
|
||||
|
||||
scopeType :: Ord v => a -> Type v a
|
||||
scopeType a = ref a scopeRef
|
||||
|
||||
refType :: Ord v => a -> Type v a
|
||||
refType a = ref a refRef
|
||||
|
||||
socket :: Ord v => a -> Type v a
|
||||
socket a = ref a socketRef
|
||||
|
||||
|
@ -226,229 +226,236 @@ Let's try it!
|
||||
182. io2.IO.putBytes.impl : Handle
|
||||
-> Bytes
|
||||
->{IO} Either Failure ()
|
||||
183. io2.IO.removeDirectory.impl : Text
|
||||
183. io2.IO.ref : a ->{IO} Ref {IO} a
|
||||
184. io2.IO.removeDirectory.impl : Text
|
||||
->{IO} Either Failure ()
|
||||
184. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
|
||||
185. io2.IO.renameDirectory.impl : Text
|
||||
185. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
|
||||
186. io2.IO.renameDirectory.impl : Text
|
||||
-> Text
|
||||
->{IO} Either Failure ()
|
||||
186. io2.IO.renameFile.impl : Text
|
||||
187. io2.IO.renameFile.impl : Text
|
||||
-> Text
|
||||
->{IO} Either Failure ()
|
||||
187. io2.IO.seekHandle.impl : Handle
|
||||
188. io2.IO.seekHandle.impl : Handle
|
||||
-> SeekMode
|
||||
-> Int
|
||||
->{IO} Either Failure ()
|
||||
188. io2.IO.serverSocket.impl : Optional Text
|
||||
189. io2.IO.serverSocket.impl : Optional Text
|
||||
-> Text
|
||||
->{IO} Either Failure Socket
|
||||
189. io2.IO.setBuffering.impl : Handle
|
||||
190. io2.IO.setBuffering.impl : Handle
|
||||
-> BufferMode
|
||||
->{IO} Either Failure ()
|
||||
190. io2.IO.setCurrentDirectory.impl : Text
|
||||
191. io2.IO.setCurrentDirectory.impl : Text
|
||||
->{IO} Either
|
||||
Failure ()
|
||||
191. io2.IO.socketAccept.impl : Socket
|
||||
192. io2.IO.socketAccept.impl : Socket
|
||||
->{IO} Either Failure Socket
|
||||
192. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
|
||||
193. io2.IO.socketReceive.impl : Socket
|
||||
193. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
|
||||
194. io2.IO.socketReceive.impl : Socket
|
||||
-> Nat
|
||||
->{IO} Either Failure Bytes
|
||||
194. io2.IO.socketSend.impl : Socket
|
||||
195. io2.IO.socketSend.impl : Socket
|
||||
-> Bytes
|
||||
->{IO} Either Failure ()
|
||||
195. io2.IO.stdHandle : StdHandle -> Handle
|
||||
196. io2.IO.systemTime.impl : '{IO} Either Failure Nat
|
||||
197. unique type io2.IOError
|
||||
198. io2.IOError.AlreadyExists : IOError
|
||||
199. io2.IOError.EOF : IOError
|
||||
200. io2.IOError.IllegalOperation : IOError
|
||||
201. io2.IOError.NoSuchThing : IOError
|
||||
202. io2.IOError.PermissionDenied : IOError
|
||||
203. io2.IOError.ResourceBusy : IOError
|
||||
204. io2.IOError.ResourceExhausted : IOError
|
||||
205. io2.IOError.UserError : IOError
|
||||
206. unique type io2.IOFailure
|
||||
207. builtin type io2.MVar
|
||||
208. io2.MVar.isEmpty : MVar a ->{IO} Boolean
|
||||
209. io2.MVar.new : a ->{IO} MVar a
|
||||
210. io2.MVar.newEmpty : '{IO} MVar a
|
||||
211. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
|
||||
212. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
|
||||
213. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
|
||||
214. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
|
||||
215. io2.MVar.tryPut.impl : MVar a
|
||||
196. io2.IO.stdHandle : StdHandle -> Handle
|
||||
197. io2.IO.systemTime.impl : '{IO} Either Failure Nat
|
||||
198. unique type io2.IOError
|
||||
199. io2.IOError.AlreadyExists : IOError
|
||||
200. io2.IOError.EOF : IOError
|
||||
201. io2.IOError.IllegalOperation : IOError
|
||||
202. io2.IOError.NoSuchThing : IOError
|
||||
203. io2.IOError.PermissionDenied : IOError
|
||||
204. io2.IOError.ResourceBusy : IOError
|
||||
205. io2.IOError.ResourceExhausted : IOError
|
||||
206. io2.IOError.UserError : IOError
|
||||
207. unique type io2.IOFailure
|
||||
208. builtin type io2.MVar
|
||||
209. io2.MVar.isEmpty : MVar a ->{IO} Boolean
|
||||
210. io2.MVar.new : a ->{IO} MVar a
|
||||
211. io2.MVar.newEmpty : '{IO} MVar a
|
||||
212. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
|
||||
213. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
|
||||
214. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
|
||||
215. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
|
||||
216. io2.MVar.tryPut.impl : MVar a
|
||||
-> a
|
||||
->{IO} Either Failure Boolean
|
||||
216. io2.MVar.tryRead.impl : MVar a
|
||||
217. io2.MVar.tryRead.impl : MVar a
|
||||
->{IO} Either
|
||||
Failure (Optional a)
|
||||
217. io2.MVar.tryTake : MVar a ->{IO} Optional a
|
||||
218. unique type io2.SeekMode
|
||||
219. io2.SeekMode.AbsoluteSeek : SeekMode
|
||||
220. io2.SeekMode.RelativeSeek : SeekMode
|
||||
221. io2.SeekMode.SeekFromEnd : SeekMode
|
||||
222. builtin type io2.Socket
|
||||
223. unique type io2.StdHandle
|
||||
224. io2.StdHandle.StdErr : StdHandle
|
||||
225. io2.StdHandle.StdIn : StdHandle
|
||||
226. io2.StdHandle.StdOut : StdHandle
|
||||
227. builtin type io2.STM
|
||||
228. io2.STM.atomically : '{STM} a ->{IO} a
|
||||
229. io2.STM.retry : '{STM} a
|
||||
230. builtin type io2.ThreadId
|
||||
231. builtin type io2.Tls
|
||||
232. builtin type io2.Tls.Cipher
|
||||
233. builtin type io2.Tls.ClientConfig
|
||||
234. io2.Tls.ClientConfig.certificates.set : [SignedCert]
|
||||
218. io2.MVar.tryTake : MVar a ->{IO} Optional a
|
||||
219. unique type io2.SeekMode
|
||||
220. io2.SeekMode.AbsoluteSeek : SeekMode
|
||||
221. io2.SeekMode.RelativeSeek : SeekMode
|
||||
222. io2.SeekMode.SeekFromEnd : SeekMode
|
||||
223. builtin type io2.Socket
|
||||
224. unique type io2.StdHandle
|
||||
225. io2.StdHandle.StdErr : StdHandle
|
||||
226. io2.StdHandle.StdIn : StdHandle
|
||||
227. io2.StdHandle.StdOut : StdHandle
|
||||
228. builtin type io2.STM
|
||||
229. io2.STM.atomically : '{STM} a ->{IO} a
|
||||
230. io2.STM.retry : '{STM} a
|
||||
231. builtin type io2.ThreadId
|
||||
232. builtin type io2.Tls
|
||||
233. builtin type io2.Tls.Cipher
|
||||
234. builtin type io2.Tls.ClientConfig
|
||||
235. io2.Tls.ClientConfig.certificates.set : [SignedCert]
|
||||
-> ClientConfig
|
||||
-> ClientConfig
|
||||
235. io2.TLS.ClientConfig.ciphers.set : [Cipher]
|
||||
236. io2.TLS.ClientConfig.ciphers.set : [Cipher]
|
||||
-> ClientConfig
|
||||
-> ClientConfig
|
||||
236. io2.Tls.ClientConfig.default : Text
|
||||
237. io2.Tls.ClientConfig.default : Text
|
||||
-> Bytes
|
||||
-> ClientConfig
|
||||
237. io2.Tls.ClientConfig.versions.set : [Version]
|
||||
238. io2.Tls.ClientConfig.versions.set : [Version]
|
||||
-> ClientConfig
|
||||
-> ClientConfig
|
||||
238. io2.Tls.decodeCert.impl : Bytes
|
||||
239. io2.Tls.decodeCert.impl : Bytes
|
||||
-> Either Failure SignedCert
|
||||
239. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
|
||||
240. io2.Tls.encodeCert : SignedCert -> Bytes
|
||||
241. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
|
||||
242. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
|
||||
243. io2.Tls.newClient.impl : ClientConfig
|
||||
240. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
|
||||
241. io2.Tls.encodeCert : SignedCert -> Bytes
|
||||
242. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
|
||||
243. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
|
||||
244. io2.Tls.newClient.impl : ClientConfig
|
||||
-> Socket
|
||||
->{IO} Either Failure Tls
|
||||
244. io2.Tls.newServer.impl : ServerConfig
|
||||
245. io2.Tls.newServer.impl : ServerConfig
|
||||
-> Socket
|
||||
->{IO} Either Failure Tls
|
||||
245. builtin type io2.Tls.PrivateKey
|
||||
246. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
|
||||
247. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
|
||||
248. builtin type io2.Tls.ServerConfig
|
||||
249. io2.Tls.ServerConfig.certificates.set : [SignedCert]
|
||||
246. builtin type io2.Tls.PrivateKey
|
||||
247. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
|
||||
248. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
|
||||
249. builtin type io2.Tls.ServerConfig
|
||||
250. io2.Tls.ServerConfig.certificates.set : [SignedCert]
|
||||
-> ServerConfig
|
||||
-> ServerConfig
|
||||
250. io2.Tls.ServerConfig.ciphers.set : [Cipher]
|
||||
251. io2.Tls.ServerConfig.ciphers.set : [Cipher]
|
||||
-> ServerConfig
|
||||
-> ServerConfig
|
||||
251. io2.Tls.ServerConfig.default : [SignedCert]
|
||||
252. io2.Tls.ServerConfig.default : [SignedCert]
|
||||
-> PrivateKey
|
||||
-> ServerConfig
|
||||
252. io2.Tls.ServerConfig.versions.set : [Version]
|
||||
253. io2.Tls.ServerConfig.versions.set : [Version]
|
||||
-> ServerConfig
|
||||
-> ServerConfig
|
||||
253. builtin type io2.Tls.SignedCert
|
||||
254. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
|
||||
255. builtin type io2.Tls.Version
|
||||
256. unique type io2.TlsFailure
|
||||
257. builtin type io2.TVar
|
||||
258. io2.TVar.new : a ->{STM} TVar a
|
||||
259. io2.TVar.newIO : a ->{IO} TVar a
|
||||
260. io2.TVar.read : TVar a ->{STM} a
|
||||
261. io2.TVar.readIO : TVar a ->{IO} a
|
||||
262. io2.TVar.swap : TVar a -> a ->{STM} a
|
||||
263. io2.TVar.write : TVar a -> a ->{STM} ()
|
||||
264. unique type IsPropagated
|
||||
265. IsPropagated.IsPropagated : IsPropagated
|
||||
266. unique type IsTest
|
||||
267. IsTest.IsTest : IsTest
|
||||
268. unique type Link
|
||||
269. builtin type Link.Term
|
||||
270. Link.Term : Term -> Link
|
||||
271. builtin type Link.Type
|
||||
272. Link.Type : Type -> Link
|
||||
273. builtin type List
|
||||
274. List.++ : [a] -> [a] -> [a]
|
||||
275. List.+: : a -> [a] -> [a]
|
||||
276. List.:+ : [a] -> a -> [a]
|
||||
277. List.at : Nat -> [a] -> Optional a
|
||||
278. List.cons : a -> [a] -> [a]
|
||||
279. List.drop : Nat -> [a] -> [a]
|
||||
280. List.empty : [a]
|
||||
281. List.size : [a] -> Nat
|
||||
282. List.snoc : [a] -> a -> [a]
|
||||
283. List.take : Nat -> [a] -> [a]
|
||||
284. metadata.isPropagated : IsPropagated
|
||||
285. metadata.isTest : IsTest
|
||||
286. builtin type Nat
|
||||
287. Nat.* : Nat -> Nat -> Nat
|
||||
288. Nat.+ : Nat -> Nat -> Nat
|
||||
289. Nat./ : Nat -> Nat -> Nat
|
||||
290. Nat.and : Nat -> Nat -> Nat
|
||||
291. Nat.complement : Nat -> Nat
|
||||
292. Nat.drop : Nat -> Nat -> Nat
|
||||
293. Nat.eq : Nat -> Nat -> Boolean
|
||||
294. Nat.fromText : Text -> Optional Nat
|
||||
295. Nat.gt : Nat -> Nat -> Boolean
|
||||
296. Nat.gteq : Nat -> Nat -> Boolean
|
||||
297. Nat.increment : Nat -> Nat
|
||||
298. Nat.isEven : Nat -> Boolean
|
||||
299. Nat.isOdd : Nat -> Boolean
|
||||
300. Nat.leadingZeros : Nat -> Nat
|
||||
301. Nat.lt : Nat -> Nat -> Boolean
|
||||
302. Nat.lteq : Nat -> Nat -> Boolean
|
||||
303. Nat.mod : Nat -> Nat -> Nat
|
||||
304. Nat.or : Nat -> Nat -> Nat
|
||||
305. Nat.popCount : Nat -> Nat
|
||||
306. Nat.pow : Nat -> Nat -> Nat
|
||||
307. Nat.shiftLeft : Nat -> Nat -> Nat
|
||||
308. Nat.shiftRight : Nat -> Nat -> Nat
|
||||
309. Nat.sub : Nat -> Nat -> Int
|
||||
310. Nat.toFloat : Nat -> Float
|
||||
311. Nat.toInt : Nat -> Int
|
||||
312. Nat.toText : Nat -> Text
|
||||
313. Nat.trailingZeros : Nat -> Nat
|
||||
314. Nat.xor : Nat -> Nat -> Nat
|
||||
315. structural type Optional a
|
||||
316. Optional.None : Optional a
|
||||
317. Optional.Some : a -> Optional a
|
||||
318. builtin type Request
|
||||
319. structural type SeqView a b
|
||||
320. SeqView.VElem : a -> b -> SeqView a b
|
||||
321. SeqView.VEmpty : SeqView a b
|
||||
322. unique type Test.Result
|
||||
323. Test.Result.Fail : Text -> Result
|
||||
324. Test.Result.Ok : Text -> Result
|
||||
325. builtin type Text
|
||||
326. Text.!= : Text -> Text -> Boolean
|
||||
327. Text.++ : Text -> Text -> Text
|
||||
328. Text.drop : Nat -> Text -> Text
|
||||
329. Text.empty : Text
|
||||
330. Text.eq : Text -> Text -> Boolean
|
||||
331. Text.fromCharList : [Char] -> Text
|
||||
332. Text.fromUtf8.impl : Bytes -> Either Failure Text
|
||||
333. Text.gt : Text -> Text -> Boolean
|
||||
334. Text.gteq : Text -> Text -> Boolean
|
||||
335. Text.lt : Text -> Text -> Boolean
|
||||
336. Text.lteq : Text -> Text -> Boolean
|
||||
337. Text.repeat : Nat -> Text -> Text
|
||||
338. Text.size : Text -> Nat
|
||||
339. Text.take : Nat -> Text -> Text
|
||||
340. Text.toCharList : Text -> [Char]
|
||||
341. Text.toUtf8 : Text -> Bytes
|
||||
342. Text.uncons : Text -> Optional (Char, Text)
|
||||
343. Text.unsnoc : Text -> Optional (Text, Char)
|
||||
344. todo : a -> b
|
||||
345. structural type Tuple a b
|
||||
346. Tuple.Cons : a -> b -> Tuple a b
|
||||
347. structural type Unit
|
||||
348. Unit.Unit : ()
|
||||
349. Universal.< : a -> a -> Boolean
|
||||
350. Universal.<= : a -> a -> Boolean
|
||||
351. Universal.== : a -> a -> Boolean
|
||||
352. Universal.> : a -> a -> Boolean
|
||||
353. Universal.>= : a -> a -> Boolean
|
||||
354. Universal.compare : a -> a -> Int
|
||||
355. unsafe.coerceAbilities : (a ->{e1} b) -> a ->{e2} b
|
||||
356. builtin type Value
|
||||
357. Value.dependencies : Value -> [Term]
|
||||
358. Value.deserialize : Bytes -> Either Text Value
|
||||
359. Value.load : Value ->{IO} Either [Term] a
|
||||
360. Value.serialize : Value -> Bytes
|
||||
361. Value.value : a -> Value
|
||||
254. builtin type io2.Tls.SignedCert
|
||||
255. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
|
||||
256. builtin type io2.Tls.Version
|
||||
257. unique type io2.TlsFailure
|
||||
258. builtin type io2.TVar
|
||||
259. io2.TVar.new : a ->{STM} TVar a
|
||||
260. io2.TVar.newIO : a ->{IO} TVar a
|
||||
261. io2.TVar.read : TVar a ->{STM} a
|
||||
262. io2.TVar.readIO : TVar a ->{IO} a
|
||||
263. io2.TVar.swap : TVar a -> a ->{STM} a
|
||||
264. io2.TVar.write : TVar a -> a ->{STM} ()
|
||||
265. unique type IsPropagated
|
||||
266. IsPropagated.IsPropagated : IsPropagated
|
||||
267. unique type IsTest
|
||||
268. IsTest.IsTest : IsTest
|
||||
269. unique type Link
|
||||
270. builtin type Link.Term
|
||||
271. Link.Term : Term -> Link
|
||||
272. builtin type Link.Type
|
||||
273. Link.Type : Type -> Link
|
||||
274. builtin type List
|
||||
275. List.++ : [a] -> [a] -> [a]
|
||||
276. List.+: : a -> [a] -> [a]
|
||||
277. List.:+ : [a] -> a -> [a]
|
||||
278. List.at : Nat -> [a] -> Optional a
|
||||
279. List.cons : a -> [a] -> [a]
|
||||
280. List.drop : Nat -> [a] -> [a]
|
||||
281. List.empty : [a]
|
||||
282. List.size : [a] -> Nat
|
||||
283. List.snoc : [a] -> a -> [a]
|
||||
284. List.take : Nat -> [a] -> [a]
|
||||
285. metadata.isPropagated : IsPropagated
|
||||
286. metadata.isTest : IsTest
|
||||
287. builtin type Nat
|
||||
288. Nat.* : Nat -> Nat -> Nat
|
||||
289. Nat.+ : Nat -> Nat -> Nat
|
||||
290. Nat./ : Nat -> Nat -> Nat
|
||||
291. Nat.and : Nat -> Nat -> Nat
|
||||
292. Nat.complement : Nat -> Nat
|
||||
293. Nat.drop : Nat -> Nat -> Nat
|
||||
294. Nat.eq : Nat -> Nat -> Boolean
|
||||
295. Nat.fromText : Text -> Optional Nat
|
||||
296. Nat.gt : Nat -> Nat -> Boolean
|
||||
297. Nat.gteq : Nat -> Nat -> Boolean
|
||||
298. Nat.increment : Nat -> Nat
|
||||
299. Nat.isEven : Nat -> Boolean
|
||||
300. Nat.isOdd : Nat -> Boolean
|
||||
301. Nat.leadingZeros : Nat -> Nat
|
||||
302. Nat.lt : Nat -> Nat -> Boolean
|
||||
303. Nat.lteq : Nat -> Nat -> Boolean
|
||||
304. Nat.mod : Nat -> Nat -> Nat
|
||||
305. Nat.or : Nat -> Nat -> Nat
|
||||
306. Nat.popCount : Nat -> Nat
|
||||
307. Nat.pow : Nat -> Nat -> Nat
|
||||
308. Nat.shiftLeft : Nat -> Nat -> Nat
|
||||
309. Nat.shiftRight : Nat -> Nat -> Nat
|
||||
310. Nat.sub : Nat -> Nat -> Int
|
||||
311. Nat.toFloat : Nat -> Float
|
||||
312. Nat.toInt : Nat -> Int
|
||||
313. Nat.toText : Nat -> Text
|
||||
314. Nat.trailingZeros : Nat -> Nat
|
||||
315. Nat.xor : Nat -> Nat -> Nat
|
||||
316. structural type Optional a
|
||||
317. Optional.None : Optional a
|
||||
318. Optional.Some : a -> Optional a
|
||||
319. builtin type Ref
|
||||
320. Ref.read : Ref g a ->{g} a
|
||||
321. Ref.write : Ref g a -> a ->{g} ()
|
||||
322. builtin type Request
|
||||
323. builtin type Scope
|
||||
324. Scope.ref : a ->{Scope s} Ref {Scope s} a
|
||||
325. Scope.run : (∀ s. '{g, Scope s} r) ->{g} r
|
||||
326. structural type SeqView a b
|
||||
327. SeqView.VElem : a -> b -> SeqView a b
|
||||
328. SeqView.VEmpty : SeqView a b
|
||||
329. unique type Test.Result
|
||||
330. Test.Result.Fail : Text -> Result
|
||||
331. Test.Result.Ok : Text -> Result
|
||||
332. builtin type Text
|
||||
333. Text.!= : Text -> Text -> Boolean
|
||||
334. Text.++ : Text -> Text -> Text
|
||||
335. Text.drop : Nat -> Text -> Text
|
||||
336. Text.empty : Text
|
||||
337. Text.eq : Text -> Text -> Boolean
|
||||
338. Text.fromCharList : [Char] -> Text
|
||||
339. Text.fromUtf8.impl : Bytes -> Either Failure Text
|
||||
340. Text.gt : Text -> Text -> Boolean
|
||||
341. Text.gteq : Text -> Text -> Boolean
|
||||
342. Text.lt : Text -> Text -> Boolean
|
||||
343. Text.lteq : Text -> Text -> Boolean
|
||||
344. Text.repeat : Nat -> Text -> Text
|
||||
345. Text.size : Text -> Nat
|
||||
346. Text.take : Nat -> Text -> Text
|
||||
347. Text.toCharList : Text -> [Char]
|
||||
348. Text.toUtf8 : Text -> Bytes
|
||||
349. Text.uncons : Text -> Optional (Char, Text)
|
||||
350. Text.unsnoc : Text -> Optional (Text, Char)
|
||||
351. todo : a -> b
|
||||
352. structural type Tuple a b
|
||||
353. Tuple.Cons : a -> b -> Tuple a b
|
||||
354. structural type Unit
|
||||
355. Unit.Unit : ()
|
||||
356. Universal.< : a -> a -> Boolean
|
||||
357. Universal.<= : a -> a -> Boolean
|
||||
358. Universal.== : a -> a -> Boolean
|
||||
359. Universal.> : a -> a -> Boolean
|
||||
360. Universal.>= : a -> a -> Boolean
|
||||
361. Universal.compare : a -> a -> Int
|
||||
362. unsafe.coerceAbilities : (a ->{e1} b) -> a ->{e2} b
|
||||
363. builtin type Value
|
||||
364. Value.dependencies : Value -> [Term]
|
||||
365. Value.deserialize : Bytes -> Either Text Value
|
||||
366. Value.load : Value ->{IO} Either [Term] a
|
||||
367. Value.serialize : Value -> Bytes
|
||||
368. Value.value : a -> Value
|
||||
|
||||
|
||||
.builtin> alias.many 94-104 .mylib
|
||||
|
@ -42,24 +42,28 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
|
||||
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)
|
||||
52. unsafe/ (1 definition)
|
||||
34. Ref (builtin type)
|
||||
35. Ref/ (2 definitions)
|
||||
36. Request (builtin type)
|
||||
37. Scope (builtin type)
|
||||
38. Scope/ (2 definitions)
|
||||
39. SeqView (type)
|
||||
40. SeqView/ (2 definitions)
|
||||
41. Test/ (3 definitions)
|
||||
42. Text (builtin type)
|
||||
43. Text/ (18 definitions)
|
||||
44. Tuple (type)
|
||||
45. Tuple/ (1 definition)
|
||||
46. Unit (type)
|
||||
47. Unit/ (1 definition)
|
||||
48. Universal/ (6 definitions)
|
||||
49. Value (builtin type)
|
||||
50. Value/ (5 definitions)
|
||||
51. bug (a -> b)
|
||||
52. crypto/ (12 definitions)
|
||||
53. io2/ (122 definitions)
|
||||
54. metadata/ (2 definitions)
|
||||
55. todo (a -> b)
|
||||
56. unsafe/ (1 definition)
|
||||
|
||||
```
|
||||
|
@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge`
|
||||
|
||||
.foo> ls
|
||||
|
||||
1. builtin/ (361 definitions)
|
||||
1. builtin/ (368 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/ (529 definitions)
|
||||
1. builtin/ (536 definitions)
|
||||
|
||||
```
|
||||
More typically, you'd start out by pulling `base.
|
||||
|
@ -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.
|
||||
|
||||
⊙ #hbh1v5maor
|
||||
⊙ #nl3sdb3eid
|
||||
|
||||
- Deletes:
|
||||
|
||||
feature1.y
|
||||
|
||||
⊙ #2l42rrsvar
|
||||
⊙ #nt4hpgmam9
|
||||
|
||||
+ 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
|
||||
|
||||
⊙ #dib06cmchm
|
||||
⊙ #hjtrj2kgl4
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
feature1.y
|
||||
|
||||
⊙ #l8dl4cfm6g
|
||||
⊙ #04vktkvglu
|
||||
|
||||
> Moves:
|
||||
|
||||
Original name New name
|
||||
x master.x
|
||||
|
||||
⊙ #ckfepuvh4m
|
||||
⊙ #0g638hmb59
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
x
|
||||
|
||||
□ #u474t1parv (start of history)
|
||||
□ #2f9h2uhlk9 (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`.
|
||||
|
@ -59,16 +59,16 @@ y = 2
|
||||
most recent, along with the command that got us there. Try:
|
||||
|
||||
`fork 2 .old`
|
||||
`fork #no7ag5futf .old` to make an old namespace
|
||||
`fork #3n9h2vkhe3 .old` to make an old namespace
|
||||
accessible again,
|
||||
|
||||
`reset-root #no7ag5futf` to reset the root namespace and
|
||||
`reset-root #3n9h2vkhe3` to reset the root namespace and
|
||||
its history to that of the
|
||||
specified namespace.
|
||||
|
||||
1. #m3jpo289fj : add
|
||||
2. #no7ag5futf : add
|
||||
3. #u474t1parv : builtins.merge
|
||||
1. #vfl0sjr6kg : add
|
||||
2. #3n9h2vkhe3 : add
|
||||
3. #2f9h2uhlk9 : builtins.merge
|
||||
4. #sjg2v58vn2 : (initial reflogged namespace)
|
||||
|
||||
```
|
||||
|
19
unison-src/transcripts/scope-ref.md
Normal file
19
unison-src/transcripts/scope-ref.md
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
A short script to test mutable references with local scope.
|
||||
|
||||
```ucm:hide
|
||||
.> builtins.mergeio
|
||||
```
|
||||
|
||||
```unison
|
||||
test = Scope.run 'let
|
||||
r = Scope.ref 0
|
||||
Ref.write r 1
|
||||
i = Ref.read r
|
||||
Ref.write r 2
|
||||
j = Ref.read r
|
||||
Ref.write r 5
|
||||
(i, j, Ref.read r)
|
||||
|
||||
> test
|
||||
```
|
34
unison-src/transcripts/scope-ref.output.md
Normal file
34
unison-src/transcripts/scope-ref.output.md
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
A short script to test mutable references with local scope.
|
||||
|
||||
```unison
|
||||
test = Scope.run 'let
|
||||
r = Scope.ref 0
|
||||
Ref.write r 1
|
||||
i = Ref.read r
|
||||
Ref.write r 2
|
||||
j = Ref.read r
|
||||
Ref.write r 5
|
||||
(i, j, Ref.read r)
|
||||
|
||||
> test
|
||||
```
|
||||
|
||||
```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`:
|
||||
|
||||
test : (Nat, Nat, Nat)
|
||||
|
||||
Now evaluating any watch expressions (lines starting with
|
||||
`>`)... Ctrl+C cancels.
|
||||
|
||||
10 | > test
|
||||
⧩
|
||||
(1, 2, 5)
|
||||
|
||||
```
|
@ -13,7 +13,7 @@ Let's look at some examples. We'll start with a namespace with just the builtins
|
||||
|
||||
|
||||
|
||||
□ #rmo1p21ibg (start of history)
|
||||
□ #fhun4m3q9g (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.
|
||||
|
||||
⊙ #nd5bbpuhc0
|
||||
⊙ #565pe56252
|
||||
|
||||
> Moves:
|
||||
|
||||
Original name New name
|
||||
Nat.frobnicate Nat.+
|
||||
|
||||
⊙ #3sguitlvgr
|
||||
⊙ #oavs87p39a
|
||||
|
||||
> Moves:
|
||||
|
||||
Original name New name
|
||||
Nat.+ Nat.frobnicate
|
||||
|
||||
□ #rmo1p21ibg (start of history)
|
||||
□ #fhun4m3q9g (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.
|
||||
|
||||
⊙ #nd5bbpuhc0
|
||||
⊙ #565pe56252
|
||||
|
||||
> Moves:
|
||||
|
||||
Original name New name
|
||||
Nat.frobnicate Nat.+
|
||||
|
||||
⊙ #3sguitlvgr
|
||||
⊙ #oavs87p39a
|
||||
|
||||
> Moves:
|
||||
|
||||
Original name New name
|
||||
Nat.+ Nat.frobnicate
|
||||
|
||||
□ #rmo1p21ibg (start of history)
|
||||
□ #fhun4m3q9g (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
|
||||
|
||||
|
||||
|
||||
□ #rmo1p21ibg (start of history)
|
||||
□ #fhun4m3q9g (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.
|
||||
|
||||
⊙ #iedv81ls6h
|
||||
⊙ #jqps95msh5
|
||||
|
||||
- Deletes:
|
||||
|
||||
Nat.* Nat.+
|
||||
|
||||
□ #rmo1p21ibg (start of history)
|
||||
□ #fhun4m3q9g (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.
|
||||
|
Loading…
Reference in New Issue
Block a user