Merge pull request #3104 from unisonweb/work/arrays

Add builtin array types and functions
This commit is contained in:
Paul Chiusano 2022-06-20 23:30:00 -04:00 committed by GitHub
commit 8677aef155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1794 additions and 755 deletions

View File

@ -234,7 +234,11 @@ builtinTypesSrc =
B' "Ref" CT.Data,
B' "Scope" CT.Effect,
B' "TimeSpec" CT.Data,
Rename' "TimeSpec" "io2.Clock.internals.TimeSpec"
Rename' "TimeSpec" "io2.Clock.internals.TimeSpec",
B' "ImmutableArray" CT.Data,
B' "MutableArray" CT.Data,
B' "ImmutableByteArray" CT.Data,
B' "MutableByteArray" CT.Data
]
-- rename these to "builtin" later, when builtin means intrinsic as opposed to
@ -523,7 +527,65 @@ builtinsSrc =
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
reft g a --> a --> Type.effect1 () g unit,
B "MutableArray.copyTo!" . forall2 "g" "a" $ \g a ->
marrayt g a --> nat --> marrayt g a --> nat --> nat
--> Type.effect () [g, DD.exceptionType ()] unit,
B "MutableByteArray.copyTo!" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> mbytearrayt g --> nat --> nat
--> Type.effect () [g, DD.exceptionType ()] unit,
B "MutableArray.read" . forall2 "g" "a" $ \g a ->
marrayt g a --> nat --> Type.effect () [g, DD.exceptionType ()] a,
B "MutableByteArray.read8" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> Type.effect () [g, DD.exceptionType ()] nat,
B "MutableByteArray.read16be" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> Type.effect () [g, DD.exceptionType ()] nat,
B "MutableByteArray.read32be" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> Type.effect () [g, DD.exceptionType ()] nat,
B "MutableByteArray.read64be" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> Type.effect () [g, DD.exceptionType ()] nat,
B "MutableArray.write" . forall2 "g" "a" $ \g a ->
marrayt g a --> nat --> a --> Type.effect () [g, DD.exceptionType ()] unit,
B "MutableByteArray.write8" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> nat --> Type.effect () [g, DD.exceptionType ()] unit,
B "MutableByteArray.write16be" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> nat --> Type.effect () [g, DD.exceptionType ()] unit,
B "MutableByteArray.write32be" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> nat --> Type.effect () [g, DD.exceptionType ()] unit,
B "MutableByteArray.write64be" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> nat --> Type.effect () [g, DD.exceptionType ()] unit,
B "ImmutableArray.copyTo!" . forall2 "g" "a" $ \g a ->
marrayt g a --> nat --> iarrayt a --> nat --> nat
--> Type.effect () [g, DD.exceptionType ()] unit,
B "ImmutableByteArray.copyTo!" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> ibytearrayt --> nat --> nat
--> Type.effect () [g, DD.exceptionType ()] unit,
B "ImmutableArray.read" . forall1 "a" $ \a ->
iarrayt a --> nat --> Type.effect1 () (DD.exceptionType ()) a,
B "ImmutableByteArray.read8" $
ibytearrayt --> nat --> Type.effect1 () (DD.exceptionType ()) nat,
B "ImmutableByteArray.read16be" $
ibytearrayt --> nat --> Type.effect1 () (DD.exceptionType ()) nat,
B "ImmutableByteArray.read32be" $
ibytearrayt --> nat --> Type.effect1 () (DD.exceptionType ()) nat,
B "ImmutableByteArray.read64be" $
ibytearrayt --> nat --> Type.effect1 () (DD.exceptionType ()) nat,
B "MutableArray.freeze!" . forall2 "g" "a" $ \g a ->
marrayt g a --> Type.effect1 () g (iarrayt a),
B "MutableByteArray.freeze!" . forall1 "g" $ \g ->
mbytearrayt g --> Type.effect1 () g ibytearrayt,
B "MutableArray.freeze" . forall2 "g" "a" $ \g a ->
marrayt g a --> nat --> nat --> Type.effect1 () g (iarrayt a),
B "MutableByteArray.freeze" . forall1 "g" $ \g ->
mbytearrayt g --> nat --> nat --> Type.effect1 () g ibytearrayt,
B "Scope.array" . forall2 "s" "a" $ \s a ->
nat --> Type.effect1 () (scopet s) (marrayt (scopet s) a),
B "Scope.arrayOf" . forall2 "s" "a" $ \s a ->
a --> nat --> Type.effect1 () (scopet s) (marrayt (scopet s) a),
B "Scope.bytearray" . forall1 "s" $ \s ->
nat --> Type.effect1 () (scopet s) (mbytearrayt (scopet s)),
B "Scope.bytearrayOf" . forall1 "s" $ \s ->
nat --> nat --> Type.effect1 () (scopet s) (mbytearrayt (scopet s))
]
++
-- avoid name conflicts with Universal == < > <= >=
@ -673,7 +735,21 @@ ioBuiltins =
("Clock.internals.threadCPUTime.v1", unit --> iof timeSpec),
("Clock.internals.realtime.v1", unit --> iof timeSpec),
("Clock.internals.sec.v1", timeSpec --> int),
("Clock.internals.nsec.v1", timeSpec --> nat)
("Clock.internals.nsec.v1", timeSpec --> nat),
( "IO.array",
forall1 "a" $ \a ->
nat --> io (marrayt (Type.effects () [Type.builtinIO ()]) a)
),
( "IO.arrayOf",
forall1 "a" $ \a ->
a --> nat --> io (marrayt (Type.effects () [Type.builtinIO ()]) a)
),
( "IO.bytearray",
nat --> io (mbytearrayt (Type.effects () [Type.builtinIO ()]))
),
( "IO.bytearrayOf",
nat --> nat --> io (mbytearrayt (Type.effects () [Type.builtinIO ()]))
)
]
mvarBuiltins :: [(Text, Type)]
@ -794,6 +870,18 @@ scopet s = Type.scopeType () `app` s
reft :: Type -> Type -> Type
reft s a = Type.refType () `app` s `app` a
ibytearrayt :: Type
ibytearrayt = Type.ibytearrayType ()
mbytearrayt :: Type -> Type
mbytearrayt g = Type.mbytearrayType () `app` g
iarrayt :: Type -> Type
iarrayt a = Type.iarrayType () `app` a
marrayt :: Type -> Type -> Type
marrayt g a = Type.marrayType () `app` g `app` a
socket, threadId, handle, unit :: Type
socket = Type.socket ()
threadId = Type.threadId ()

View File

@ -52,7 +52,7 @@ optionalRef = lookupDeclRef "Optional"
eitherRef = lookupDeclRef "Either"
testResultRef, linkRef, docRef, ioErrorRef, stdHandleRef :: Reference
failureRef, ioFailureRef, tlsFailureRef :: Reference
failureRef, ioFailureRef, tlsFailureRef, arrayFailureRef :: Reference
exceptionRef, tlsSignedCertRef, tlsPrivateKeyRef :: Reference
isPropagatedRef, isTestRef :: Reference
isPropagatedRef = lookupDeclRef "IsPropagated"
@ -77,6 +77,8 @@ ioFailureRef = lookupDeclRef "io2.IOFailure"
tlsFailureRef = lookupDeclRef "io2.TlsFailure"
arrayFailureRef = lookupDeclRef "io2.ArrayFailure"
tlsSignedCertRef = lookupDeclRef "io2.Tls.SignedCert"
tlsPrivateKeyRef = lookupDeclRef "io2.Tls.PrivateKey"
@ -176,7 +178,8 @@ builtinDataDecls = rs1 ++ rs
(v "io2.StdHandle", stdhnd),
(v "io2.Failure", failure),
(v "io2.TlsFailure", tlsFailure),
(v "io2.IOFailure", ioFailure)
(v "io2.IOFailure", ioFailure),
(v "io2.ArrayFailure", arrayFailure)
] of
Right a -> a
Left e -> error $ "builtinDataDecls: " <> show e
@ -318,6 +321,13 @@ builtinDataDecls = rs1 ++ rs
[]
[]
arrayFailure =
DataDeclaration
(Unique "8e877b3a45a3029904dbca9cbd8dda0ec0d147d67bd5b89027a90632c9e927fb")
()
[]
[]
stdhnd =
DataDeclaration
(Unique "67bf7a8e517cbb1e9f42bc078e35498212d3be3c")

View File

@ -30,9 +30,11 @@ import qualified Control.Concurrent.STM as STM
import Control.DeepSeq (NFData)
import qualified Control.Exception.Safe as Exception
import Control.Monad.Catch (MonadCatch)
import qualified Control.Monad.Primitive as PA
import Control.Monad.State.Strict (State, execState, modify)
import qualified Crypto.Hash as Hash
import qualified Crypto.MAC.HMAC as HMAC
import Data.Bits (shiftL, shiftR, (.|.))
import qualified Data.ByteArray as BA
import Data.ByteString (hGet, hGetSome, hPut)
import qualified Data.ByteString.Lazy as L
@ -45,6 +47,7 @@ import Data.IORef as SYS
)
import qualified Data.Map as Map
import Data.PEM (PEM, pemContent, pemParseLBS)
import qualified Data.Primitive as PA
import Data.Set (insert)
import qualified Data.Set as Set
import qualified Data.Text
@ -133,6 +136,7 @@ import Unison.Symbol
import qualified Unison.Type as Ty
import qualified Unison.Util.Bytes as Bytes
import Unison.Util.EnumContainers as EC
import Unison.Util.Text (Text)
import qualified Unison.Util.Text as Util.Text
import Unison.Var
@ -182,11 +186,26 @@ fresh8 = (v1, v2, v3, v4, v5, v6, v7, v8)
where
[v1, v2, v3, v4, v5, v6, v7, v8] = freshes 8
fresh9 :: Var v => (v, v, v, v, v, v, v, v, v)
fresh9 = (v1, v2, v3, v4, v5, v6, v7, v8, v9)
where
[v1, v2, v3, v4, v5, v6, v7, v8, v9] = freshes 9
fresh10 :: Var v => (v, v, v, v, v, v, v, v, v, v)
fresh10 = (v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)
where
[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10] = freshes 10
fresh11 :: Var v => (v, v, v, v, v, v, v, v, v, v, v)
fresh11 = (v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
where
[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11] = freshes 11
fresh13 :: Var v => (v, v, v, v, v, v, v, v, v, v, v, v, v)
fresh13 = (v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
where
[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13] = freshes 13
fls, tru :: Var v => ANormal v
fls = TCon Ty.booleanRef 0 []
tru = TCon Ty.booleanRef 1 []
@ -1086,6 +1105,22 @@ inBxNat arg1 arg2 nat result cont instr =
. unbox arg2 Ty.natRef nat
$ TLetD result UN (TFOp instr [arg1, nat]) cont
inBxNatNat ::
Var v => v -> v -> v -> v -> v -> v -> ANormal v -> FOp -> ([Mem], ANormal v)
inBxNatNat arg1 arg2 arg3 nat1 nat2 result cont instr =
([BX, BX, BX],)
. TAbss [arg1, arg2, arg3]
. unbox arg2 Ty.natRef nat1
. unbox arg3 Ty.natRef nat2
$ TLetD result UN (TFOp instr [arg1, nat1, nat2]) cont
inBxNatBx :: Var v => v -> v -> v -> v -> v -> ANormal v -> FOp -> ([Mem], ANormal v)
inBxNatBx arg1 arg2 arg3 nat result cont instr =
([BX, BX, BX],)
. TAbss [arg1, arg2, arg3]
. unbox arg2 Ty.natRef nat
$ TLetD result UN (TFOp instr [arg1, nat, arg3]) cont
-- a -> IOMode -> ...
inBxIomr :: forall v. Var v => v -> v -> v -> v -> ANormal v -> FOp -> ([Mem], ANormal v)
inBxIomr arg1 arg2 fm result cont instr =
@ -1161,6 +1196,41 @@ outIoFailNat stack1 stack2 stack3 fail nat result =
)
]
exnCase :: Var v => v -> v -> v -> v -> (Word64, ([Mem], ANormal v))
exnCase stack1 stack2 stack3 fail =
(0,) . ([BX, BX, BX],)
. TAbss [stack1, stack2, stack3]
. TLetD fail BX (TCon Ty.failureRef 0 [stack1, stack2, stack3])
$ TReq Ty.exceptionRef 1 [fail]
outIoExnNat :: forall v. Var v => v -> v -> v -> v -> v -> ANormal v
outIoExnNat stack1 stack2 stack3 fail result =
TMatch result . MatchSum $
mapFromList
[ exnCase stack1 stack2 stack3 fail,
( 1,
([UN],)
. TAbs stack1
$ TCon Ty.natRef 0 [stack1]
)
]
outIoExnUnit :: forall v. Var v => v -> v -> v -> v -> v -> ANormal v
outIoExnUnit stack1 stack2 stack3 fail result =
TMatch result . MatchSum $
mapFromList
[ exnCase stack1 stack2 stack3 fail,
(1, ([], TCon Ty.unitRef 0 []))
]
outIoExnBox :: Var v => v -> v -> v -> v -> v -> ANormal v
outIoExnBox stack1 stack2 stack3 fail result =
TMatch result . MatchSum $
mapFromList
[ exnCase stack1 stack2 stack3 fail,
(1, ([BX], TAbs stack1 $ TVar stack1))
]
outIoFailBox :: forall v. Var v => v -> v -> v -> v -> v -> ANormal v
outIoFailBox stack1 stack2 stack3 fail result =
TMatch result . MatchSum $
@ -1344,6 +1414,17 @@ wordDirect wordType instr =
where
(b1, ub1) = fresh2
-- Nat -> Nat -> c
wordWordDirect :: Reference -> Reference -> ForeignOp
wordWordDirect word1 word2 instr =
([BX, BX],)
. TAbss [b1, b2]
. unbox b1 word1 ub1
. unbox b2 word2 ub2
$ TFOp instr [ub1, ub2]
where
(b1, b2, ub1, ub2) = fresh4
-- Nat -> a -> c
-- Works for an type that's packed into a word, just
-- pass `wordBoxDirect Ty.natRef`, `wordBoxDirect Ty.floatRef`
@ -1357,6 +1438,17 @@ wordBoxDirect wordType instr =
where
(b1, b2, ub1) = fresh3
-- a -> Nat -> c
-- works for any second argument type that is packed into a word
boxWordDirect :: Reference -> ForeignOp
boxWordDirect wordType instr =
([BX, BX],)
. TAbss [b1, b2]
. unbox b2 wordType ub2
$ TFOp instr [b1, ub2]
where
(b1, b2, ub2) = fresh3
-- a -> b -> c
boxBoxDirect :: ForeignOp
boxBoxDirect instr =
@ -1469,6 +1561,21 @@ boxBoxToEFBox =
where
(arg1, arg2, result, stack1, stack2, fail) = fresh6
-- Nat -> a
-- Nat only
natToBox :: ForeignOp
natToBox = wordDirect Ty.natRef
-- Nat -> Nat -> a
-- Nat only
natNatToBox :: ForeignOp
natNatToBox = wordWordDirect Ty.natRef Ty.natRef
-- a -> Nat -> c
-- Nat only
boxNatToBox :: ForeignOp
boxNatToBox = boxWordDirect Ty.natRef
-- a -> Nat -> Either Failure b
boxNatToEFBox :: ForeignOp
boxNatToEFBox =
@ -1477,6 +1584,59 @@ boxNatToEFBox =
where
(arg1, arg2, nat, stack1, stack2, fail, result) = fresh7
-- a -> Nat ->{Exception} b
boxNatToExnBox :: ForeignOp
boxNatToExnBox =
inBxNat arg1 arg2 nat result $
outIoExnBox stack1 stack2 stack3 fail result
where
(arg1, arg2, nat, stack1, stack2, stack3, fail, result) = fresh8
-- a -> Nat -> b ->{Exception} ()
boxNatBoxToExnUnit :: ForeignOp
boxNatBoxToExnUnit =
inBxNatBx arg1 arg2 arg3 nat result $
outIoExnUnit stack1 stack2 stack3 fail result
where
(arg1, arg2, arg3, nat, stack1, stack2, stack3, fail, result) = fresh9
-- a -> Nat ->{Exception} Nat
boxNatToExnNat :: ForeignOp
boxNatToExnNat =
inBxNat arg1 arg2 nat result $
outIoExnNat stack1 stack2 stack3 fail result
where
(arg1, arg2, nat, stack1, stack2, stack3, fail, result) = fresh8
-- a -> Nat -> Nat ->{Exception} ()
boxNatNatToExnUnit :: ForeignOp
boxNatNatToExnUnit =
inBxNatNat arg1 arg2 arg3 nat1 nat2 result $
outIoExnUnit stack1 stack2 stack3 fail result
where
(arg1, arg2, arg3, nat1, nat2, result, stack1, stack2, stack3, fail) = fresh10
-- a -> Nat -> Nat ->{Exception} b
boxNatNatToExnBox :: ForeignOp
boxNatNatToExnBox =
inBxNatNat arg1 arg2 arg3 nat1 nat2 result $
outIoExnBox stack1 stack2 stack3 fail result
where
(arg1, arg2, arg3, nat1, nat2, result, stack1, stack2, stack3, fail) = fresh10
-- a -> Nat -> b -> Nat -> Nat ->{Exception} ()
boxNatBoxNatNatToExnUnit :: ForeignOp
boxNatBoxNatNatToExnUnit instr =
([BX, BX, BX, BX, BX],)
. TAbss [a0, a1, a2, a3, a4]
. unbox a1 Ty.natRef ua1
. unbox a3 Ty.natRef ua3
. unbox a4 Ty.natRef ua4
. TLetD result UN (TFOp instr [a0, ua1, a2, ua3, ua4])
$ outIoExnUnit stack1 stack2 stack3 fail result
where
(a0, a1, a2, a3, a4, ua1, ua3, ua4, result, stack1, stack2, stack3, fail) = fresh13
-- Nat -> Either Failure b
-- natToEFBox :: ForeignOp
-- natToEFBox = inNat arg nat result $ outIoFail stack1 stack2 fail result
@ -1730,6 +1890,9 @@ mkForeignIOF f = mkForeign $ \a -> tryIOE (f a)
unitValue :: Closure
unitValue = Closure.Enum Ty.unitRef 0
natValue :: Word64 -> Closure
natValue w = Closure.DataU1 Ty.natRef 0 (fromIntegral w)
mkForeignTls ::
forall a r.
(ForeignConvention a, ForeignConvention r) =>
@ -2229,6 +2392,392 @@ declareForeigns = do
declareForeign Untracked "Bytes.encodeNat16be" (wordDirect Ty.natRef) . mkForeign $ pure . Bytes.encodeNat16be
declareForeign Untracked "Bytes.encodeNat16le" (wordDirect Ty.natRef) . mkForeign $ pure . Bytes.encodeNat16le
declareForeign Tracked "MutableArray.copyTo!" boxNatBoxNatNatToExnUnit
. mkForeign
$ \(dst, doff, src, soff, l) ->
let name = "MutableArray.copyTo!"
in if l == 0
then pure (Right ())
else
checkBounds name (PA.sizeofMutableArray dst) (doff + l - 1) $
checkBounds name (PA.sizeofMutableArray src) (soff + l - 1) $
Right
<$> PA.copyMutableArray @IO @Closure
dst
(fromIntegral doff)
src
(fromIntegral soff)
(fromIntegral l)
declareForeign Tracked "MutableByteArray.copyTo!" boxNatBoxNatNatToExnUnit
. mkForeign
$ \(dst, doff, src, soff, l) ->
let name = "MutableByteArray.copyTo!"
in if l == 0
then pure (Right ())
else
checkBoundsPrim name (PA.sizeofMutableByteArray dst) (doff + l) 0 $
checkBoundsPrim name (PA.sizeofMutableByteArray src) (soff + l) 0 $
Right
<$> PA.copyMutableByteArray @IO
dst
(fromIntegral doff)
src
(fromIntegral soff)
(fromIntegral l)
declareForeign Tracked "ImmutableArray.copyTo!" boxNatBoxNatNatToExnUnit
. mkForeign
$ \(dst, doff, src, soff, l) ->
let name = "ImmutableArray.copyTo!"
in if l == 0
then pure (Right ())
else
checkBounds name (PA.sizeofMutableArray dst) (doff + l - 1) $
checkBounds name (PA.sizeofArray src) (soff + l - 1) $
Right
<$> PA.copyArray @IO @Closure
dst
(fromIntegral doff)
src
(fromIntegral soff)
(fromIntegral l)
declareForeign Tracked "ImmutableByteArray.copyTo!" boxNatBoxNatNatToExnUnit
. mkForeign
$ \(dst, doff, src, soff, l) ->
let name = "ImmutableByteArray.copyTo!"
in if l == 0
then pure (Right ())
else
checkBoundsPrim name (PA.sizeofMutableByteArray dst) (doff + l) 0 $
checkBoundsPrim name (PA.sizeofByteArray src) (soff + l) 0 $
Right
<$> PA.copyByteArray @IO
dst
(fromIntegral doff)
src
(fromIntegral soff)
(fromIntegral l)
declareForeign Tracked "MutableArray.read" boxNatToExnBox
. mkForeign
$ checkedRead "MutableArray.read"
declareForeign Tracked "MutableByteArray.read8" boxNatToExnNat
. mkForeign
$ checkedRead8 "MutableByteArray.read8"
declareForeign Tracked "MutableByteArray.read16be" boxNatToExnNat
. mkForeign
$ checkedRead16 "MutableByteArray.read16be"
declareForeign Tracked "MutableByteArray.read32be" boxNatToExnNat
. mkForeign
$ checkedRead32 "MutableByteArray.read32be"
declareForeign Tracked "MutableByteArray.read64be" boxNatToExnNat
. mkForeign
$ checkedRead64 "MutableByteArray.read64be"
declareForeign Tracked "MutableArray.write" boxNatBoxToExnUnit
. mkForeign
$ checkedWrite "MutableArray.write"
declareForeign Tracked "MutableByteArray.write8" boxNatNatToExnUnit
. mkForeign
$ checkedWrite8 "MutableByteArray.write8"
declareForeign Tracked "MutableByteArray.write16be" boxNatNatToExnUnit
. mkForeign
$ checkedWrite16 "MutableByteArray.write16be"
declareForeign Tracked "MutableByteArray.write32be" boxNatNatToExnUnit
. mkForeign
$ checkedWrite32 "MutableByteArray.write32be"
declareForeign Tracked "MutableByteArray.write64be" boxNatNatToExnUnit
. mkForeign
$ checkedWrite64 "MutableByteArray.write64be"
declareForeign Untracked "ImmutableArray.read" boxNatToExnBox
. mkForeign
$ checkedIndex "ImmutableArray.read"
declareForeign Untracked "ImmutableByteArray.read8" boxNatToExnNat
. mkForeign
$ checkedIndex8 "ImmutableByteArray.read8"
declareForeign Untracked "ImmutableByteArray.read16be" boxNatToExnNat
. mkForeign
$ checkedIndex16 "ImmutableByteArray.read16be"
declareForeign Untracked "ImmutableByteArray.read32be" boxNatToExnNat
. mkForeign
$ checkedIndex32 "ImmutableByteArray.read32be"
declareForeign Untracked "ImmutableByteArray.read64be" boxNatToExnNat
. mkForeign
$ checkedIndex64 "ImmutableByteArray.read64be"
declareForeign Tracked "MutableByteArray.freeze!" boxDirect . mkForeign $
PA.unsafeFreezeByteArray
declareForeign Tracked "MutableArray.freeze!" boxDirect . mkForeign $
PA.unsafeFreezeArray @IO @Closure
declareForeign Tracked "MutableByteArray.freeze" boxNatNatToExnBox . mkForeign $
\(src, off, len) ->
if len == 0
then fmap Right . PA.unsafeFreezeByteArray =<< PA.newByteArray 0
else
checkBoundsPrim
"MutableByteArray.freeze"
(PA.sizeofMutableByteArray src)
(off + len)
0
$ Right <$> PA.freezeByteArray src (fromIntegral off) (fromIntegral len)
declareForeign Tracked "MutableArray.freeze" boxNatNatToExnBox . mkForeign $
\(src, off, len) ->
if len == 0
then fmap Right . PA.unsafeFreezeArray =<< PA.newArray 0 Closure.BlackHole
else
checkBounds
"MutableArray.freeze"
(PA.sizeofMutableArray src)
(off + len - 1)
$ Right <$> PA.freezeArray src (fromIntegral off) (fromIntegral len)
declareForeign Untracked "MutableByteArray.length" boxToNat . mkForeign $
pure . PA.sizeofMutableByteArray @PA.RealWorld
declareForeign Untracked "ImmutableByteArray.length" boxToNat . mkForeign $
pure . PA.sizeofByteArray
declareForeign Tracked "IO.array" natToBox . mkForeign $
\n -> PA.newArray n Closure.BlackHole
declareForeign Tracked "IO.arrayOf" boxNatToBox . mkForeign $
\(v :: Closure, n) -> PA.newArray n v
declareForeign Tracked "IO.bytearray" natToBox . mkForeign $ PA.newByteArray
declareForeign Tracked "IO.bytearrayOf" natNatToBox
. mkForeign
$ \(init, sz) -> do
arr <- PA.newByteArray sz
PA.fillByteArray arr 0 sz init
pure arr
declareForeign Tracked "Scope.array" natToBox . mkForeign $
\n -> PA.newArray n Closure.BlackHole
declareForeign Tracked "Scope.arrayOf" boxNatToBox . mkForeign $
\(v :: Closure, n) -> PA.newArray n v
declareForeign Tracked "Scope.bytearray" natToBox . mkForeign $ PA.newByteArray
declareForeign Tracked "Scope.bytearrayOf" natNatToBox
. mkForeign
$ \(sz, init) -> do
arr <- PA.newByteArray sz
PA.fillByteArray arr 0 sz init
pure arr
type RW = PA.PrimState IO
checkedRead ::
Text -> (PA.MutableArray RW Closure, Word64) -> IO (Either Failure Closure)
checkedRead name (arr, w) =
checkBounds
name
(PA.sizeofMutableArray arr)
w
(Right <$> PA.readArray arr (fromIntegral w))
checkedWrite ::
Text -> (PA.MutableArray RW Closure, Word64, Closure) -> IO (Either Failure ())
checkedWrite name (arr, w, v) =
checkBounds
name
(PA.sizeofMutableArray arr)
w
(Right <$> PA.writeArray arr (fromIntegral w) v)
checkedIndex ::
Text -> (PA.Array Closure, Word64) -> IO (Either Failure Closure)
checkedIndex name (arr, w) =
checkBounds
name
(PA.sizeofArray arr)
w
(Right <$> PA.indexArrayM arr (fromIntegral w))
checkedRead8 :: Text -> (PA.MutableByteArray RW, Word64) -> IO (Either Failure Word64)
checkedRead8 name (arr, i) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 1 $
(Right . fromIntegral) <$> PA.readByteArray @Word8 arr j
where
j = fromIntegral i
checkedRead16 :: Text -> (PA.MutableByteArray RW, Word64) -> IO (Either Failure Word64)
checkedRead16 name (arr, i) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 2 $
(mk16)
<$> PA.readByteArray @Word8 arr j
<*> PA.readByteArray @Word8 arr (j + 1)
where
j = fromIntegral i
checkedRead32 :: Text -> (PA.MutableByteArray RW, Word64) -> IO (Either Failure Word64)
checkedRead32 name (arr, i) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 4 $
mk32
<$> PA.readByteArray @Word8 arr j
<*> PA.readByteArray @Word8 arr (j + 1)
<*> PA.readByteArray @Word8 arr (j + 2)
<*> PA.readByteArray @Word8 arr (j + 3)
where
j = fromIntegral i
checkedRead64 :: Text -> (PA.MutableByteArray RW, Word64) -> IO (Either Failure Word64)
checkedRead64 name (arr, i) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 8 $
mk64
<$> PA.readByteArray @Word8 arr j
<*> PA.readByteArray @Word8 arr (j + 1)
<*> PA.readByteArray @Word8 arr (j + 2)
<*> PA.readByteArray @Word8 arr (j + 3)
<*> PA.readByteArray @Word8 arr (j + 4)
<*> PA.readByteArray @Word8 arr (j + 5)
<*> PA.readByteArray @Word8 arr (j + 6)
<*> PA.readByteArray @Word8 arr (j + 7)
where
j = fromIntegral i
mk16 :: Word8 -> Word8 -> Either Failure Word64
mk16 b0 b1 = Right $ (fromIntegral $ b0 `shiftL` 8) .|. (fromIntegral b1)
mk32 :: Word8 -> Word8 -> Word8 -> Word8 -> Either Failure Word64
mk32 b0 b1 b2 b3 =
Right $
(fromIntegral $ b0 `shiftL` 24)
.|. (fromIntegral $ b1 `shiftL` 16)
.|. (fromIntegral $ b2 `shiftL` 8)
.|. (fromIntegral b3)
mk64 :: Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Either Failure Word64
mk64 b0 b1 b2 b3 b4 b5 b6 b7 =
Right $
(fromIntegral $ b0 `shiftL` 56)
.|. (fromIntegral $ b1 `shiftL` 48)
.|. (fromIntegral $ b2 `shiftL` 40)
.|. (fromIntegral $ b3 `shiftL` 32)
.|. (fromIntegral $ b4 `shiftL` 24)
.|. (fromIntegral $ b5 `shiftL` 16)
.|. (fromIntegral $ b6 `shiftL` 8)
.|. (fromIntegral b7)
checkedWrite8 :: Text -> (PA.MutableByteArray RW, Word64, Word64) -> IO (Either Failure ())
checkedWrite8 name (arr, i, v) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 1 $ do
PA.writeByteArray arr j (fromIntegral v :: Word8)
pure (Right ())
where
j = fromIntegral i
checkedWrite16 :: Text -> (PA.MutableByteArray RW, Word64, Word64) -> IO (Either Failure ())
checkedWrite16 name (arr, i, v) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 2 $ do
PA.writeByteArray arr j (fromIntegral $ v `shiftR` 8 :: Word8)
PA.writeByteArray arr (j + 1) (fromIntegral v :: Word8)
pure (Right ())
where
j = fromIntegral i
checkedWrite32 :: Text -> (PA.MutableByteArray RW, Word64, Word64) -> IO (Either Failure ())
checkedWrite32 name (arr, i, v) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 4 $ do
PA.writeByteArray arr j (fromIntegral $ v `shiftR` 24 :: Word8)
PA.writeByteArray arr (j + 1) (fromIntegral $ v `shiftR` 16 :: Word8)
PA.writeByteArray arr (j + 2) (fromIntegral $ v `shiftR` 8 :: Word8)
PA.writeByteArray arr (j + 3) (fromIntegral v :: Word8)
pure (Right ())
where
j = fromIntegral i
checkedWrite64 :: Text -> (PA.MutableByteArray RW, Word64, Word64) -> IO (Either Failure ())
checkedWrite64 name (arr, i, v) =
checkBoundsPrim name (PA.sizeofMutableByteArray arr) i 8 $ do
PA.writeByteArray arr j (fromIntegral $ v `shiftR` 56 :: Word8)
PA.writeByteArray arr (j + 1) (fromIntegral $ v `shiftR` 48 :: Word8)
PA.writeByteArray arr (j + 2) (fromIntegral $ v `shiftR` 40 :: Word8)
PA.writeByteArray arr (j + 3) (fromIntegral $ v `shiftR` 32 :: Word8)
PA.writeByteArray arr (j + 4) (fromIntegral $ v `shiftR` 24 :: Word8)
PA.writeByteArray arr (j + 5) (fromIntegral $ v `shiftR` 16 :: Word8)
PA.writeByteArray arr (j + 6) (fromIntegral $ v `shiftR` 8 :: Word8)
PA.writeByteArray arr (j + 7) (fromIntegral v :: Word8)
pure (Right ())
where
j = fromIntegral i
-- index single byte
checkedIndex8 :: Text -> (PA.ByteArray, Word64) -> IO (Either Failure Word64)
checkedIndex8 name (arr, i) =
checkBoundsPrim name (PA.sizeofByteArray arr) i 1 . pure $
let j = fromIntegral i
in Right . fromIntegral $ PA.indexByteArray @Word8 arr j
-- index 16 big-endian
checkedIndex16 :: Text -> (PA.ByteArray, Word64) -> IO (Either Failure Word64)
checkedIndex16 name (arr, i) =
checkBoundsPrim name (PA.sizeofByteArray arr) i 2 . pure $
let j = fromIntegral i
in mk16 (PA.indexByteArray arr j) (PA.indexByteArray arr (j + 1))
-- index 32 big-endian
checkedIndex32 :: Text -> (PA.ByteArray, Word64) -> IO (Either Failure Word64)
checkedIndex32 name (arr, i) =
checkBoundsPrim name (PA.sizeofByteArray arr) i 4 . pure $
let j = fromIntegral i
in mk32
(PA.indexByteArray arr j)
(PA.indexByteArray arr (j + 1))
(PA.indexByteArray arr (j + 2))
(PA.indexByteArray arr (j + 3))
-- index 64 big-endian
checkedIndex64 :: Text -> (PA.ByteArray, Word64) -> IO (Either Failure Word64)
checkedIndex64 name (arr, i) =
checkBoundsPrim name (PA.sizeofByteArray arr) i 8 . pure $
let j = fromIntegral i
in mk64
(PA.indexByteArray arr j)
(PA.indexByteArray arr (j + 1))
(PA.indexByteArray arr (j + 2))
(PA.indexByteArray arr (j + 3))
(PA.indexByteArray arr (j + 4))
(PA.indexByteArray arr (j + 5))
(PA.indexByteArray arr (j + 6))
(PA.indexByteArray arr (j + 7))
checkBounds :: Text -> Int -> Word64 -> IO (Either Failure b) -> IO (Either Failure b)
checkBounds name l w act
| w < fromIntegral l = act
| otherwise = pure $ Left err
where
msg = name <> ": array index out of bounds"
err = Failure Ty.arrayFailureRef msg (natValue w)
-- Performs a bounds check on a byte array. Strategy is as follows:
--
-- isz = signed array size-in-bytes
-- off = unsigned byte offset into the array
-- esz = unsigned number of bytes to be read
--
-- 1. Turn the signed size-in-bytes of the array unsigned
-- 2. Add the offset to the to-be-read number to get the maximum size needed
-- 3. Check that the actual array size is at least as big as the needed size
-- 4. Check that the offset is less than the size
--
-- Step 4 ensures that step 3 has not overflowed. Since an actual array size can
-- only be 63 bits (since it is signed), the only way for 3 to overflow is if
-- the offset is larger than a possible array size, since it would need to be
-- 2^64-k, where k is the small (<=8) number of bytes to be read.
checkBoundsPrim ::
Text -> Int -> Word64 -> Word64 -> IO (Either Failure b) -> IO (Either Failure b)
checkBoundsPrim name isz off esz act
| w > bsz || off > bsz = pure $ Left err
| otherwise = act
where
msg = name <> ": array index out of bounds"
err = Failure Ty.arrayFailureRef msg (natValue off)
bsz = fromIntegral isz
w = off + esz
hostPreference :: Maybe Util.Text.Text -> SYS.HostPreference
hostPreference Nothing = SYS.HostAny
hostPreference (Just host) = SYS.Host $ Util.Text.unpack host

View File

@ -21,6 +21,7 @@ where
import Control.Concurrent (MVar, ThreadId)
import qualified Crypto.Hash as Hash
import Data.IORef (IORef)
import Data.Primitive (ByteArray, MutableArray, MutableByteArray)
import Data.Tagged (Tagged (..))
import qualified Data.X509 as X509
import Network.Socket (Socket)
@ -70,6 +71,9 @@ ref2eq r
-- Ditto
| r == Ty.refRef = Just $ promote ((==) @(IORef ()))
| r == Ty.threadIdRef = Just $ promote ((==) @ThreadId)
| r == Ty.marrayRef = Just $ promote ((==) @(MutableArray () ()))
| r == Ty.mbytearrayRef = Just $ promote ((==) @(MutableByteArray ()))
| r == Ty.ibytearrayRef = Just $ promote ((==) @ByteArray)
| otherwise = Nothing
ref2cmp :: Reference -> Maybe (a -> b -> Ordering)
@ -79,6 +83,7 @@ ref2cmp r
| r == Ty.typeLinkRef = Just $ promote tylCmp
| r == Ty.bytesRef = Just $ promote (compare @Bytes)
| r == Ty.threadIdRef = Just $ promote (compare @ThreadId)
| r == Ty.ibytearrayRef = Just $ promote (compare @ByteArray)
| otherwise = Nothing
instance Eq Foreign where
@ -110,6 +115,7 @@ maybeUnwrapForeign :: Reference -> Foreign -> Maybe a
maybeUnwrapForeign rt (Wrap r e)
| rt == r = Just (unsafeCoerce e)
| otherwise = Nothing
{-# NOINLINE maybeUnwrapForeign #-}
class BuiltinForeign f where
foreignRef :: Tagged f Reference

View File

@ -18,9 +18,11 @@ import Control.Exception (evaluate)
import qualified Data.Char as Char
import Data.Foldable (toList)
import Data.IORef (IORef)
import Data.Primitive.Array as PA
import Data.Primitive.ByteArray as PA
import qualified Data.Sequence as Sq
import Data.Time.Clock.POSIX (POSIXTime)
import Data.Word (Word64)
import Data.Word (Word16, Word32, Word64, Word8)
import GHC.IO.Exception (IOErrorType (..), IOException (..))
import Network.Socket (Socket)
import System.IO (BufferMode (..), Handle, IOMode, SeekMode)
@ -32,7 +34,16 @@ import Unison.Runtime.Foreign
import Unison.Runtime.MCode
import Unison.Runtime.Stack
import Unison.Symbol (Symbol)
import Unison.Type (mvarRef, refRef, tvarRef, typeLinkRef)
import Unison.Type
( iarrayRef,
ibytearrayRef,
marrayRef,
mbytearrayRef,
mvarRef,
refRef,
tvarRef,
typeLinkRef,
)
import Unison.Util.Bytes (Bytes)
import Unison.Util.Text (Text, pack, unpack)
@ -86,6 +97,18 @@ instance ForeignConvention Word64 where
ustk <- bump ustk
(ustk, bstk) <$ pokeN ustk n
instance ForeignConvention Word8 where
readForeign = readForeignAs (fromIntegral :: Word64 -> Word8)
writeForeign = writeForeignAs (fromIntegral :: Word8 -> Word64)
instance ForeignConvention Word16 where
readForeign = readForeignAs (fromIntegral :: Word64 -> Word16)
writeForeign = writeForeignAs (fromIntegral :: Word16 -> Word64)
instance ForeignConvention Word32 where
readForeign = readForeignAs (fromIntegral :: Word64 -> Word32)
writeForeign = writeForeignAs (fromIntegral :: Word32 -> Word64)
instance ForeignConvention Char where
readForeign (i : us) bs ustk _ = (us,bs,) . Char.chr <$> peekOff ustk i
readForeign [] _ _ _ = foreignCCError "Char"
@ -327,6 +350,30 @@ instance
(ustk, bstk) <- writeForeign ustk bstk b
writeForeign ustk bstk a
instance
( ForeignConvention a,
ForeignConvention b,
ForeignConvention c,
ForeignConvention d,
ForeignConvention e
) =>
ForeignConvention (a, b, c, d, e)
where
readForeign us bs ustk bstk = do
(us, bs, a) <- readForeign us bs ustk bstk
(us, bs, b) <- readForeign us bs ustk bstk
(us, bs, c) <- readForeign us bs ustk bstk
(us, bs, d) <- readForeign us bs ustk bstk
(us, bs, e) <- readForeign us bs ustk bstk
pure (us, bs, (a, b, c, d, e))
writeForeign ustk bstk (a, b, c, d, e) = do
(ustk, bstk) <- writeForeign ustk bstk e
(ustk, bstk) <- writeForeign ustk bstk d
(ustk, bstk) <- writeForeign ustk bstk c
(ustk, bstk) <- writeForeign ustk bstk b
writeForeign ustk bstk a
no'buf, line'buf, block'buf, sblock'buf :: Int
no'buf = fromIntegral Ty.bufferModeNoBufferingId
line'buf = fromIntegral Ty.bufferModeLineBufferingId
@ -395,6 +442,22 @@ instance ForeignConvention Foreign where
readForeign = readForeignAs marshalToForeign
writeForeign = writeForeignAs Foreign
instance ForeignConvention (PA.MutableArray s Closure) where
readForeign = readForeignAs (unwrapForeign . marshalToForeign)
writeForeign = writeForeignAs (Foreign . Wrap marrayRef)
instance ForeignConvention (PA.MutableByteArray s) where
readForeign = readForeignAs (unwrapForeign . marshalToForeign)
writeForeign = writeForeignAs (Foreign . Wrap mbytearrayRef)
instance ForeignConvention (PA.Array Closure) where
readForeign = readForeignAs (unwrapForeign . marshalToForeign)
writeForeign = writeForeignAs (Foreign . Wrap iarrayRef)
instance ForeignConvention PA.ByteArray where
readForeign = readForeignAs (unwrapForeign . marshalToForeign)
writeForeign = writeForeignAs (Foreign . Wrap ibytearrayRef)
instance {-# OVERLAPPABLE #-} BuiltinForeign b => ForeignConvention b where
readForeign = readForeignBuiltin
writeForeign = writeForeignBuiltin

View File

@ -13,6 +13,7 @@ import Control.Exception
import Data.Bits
import qualified Data.Map.Strict as M
import Data.Ord (comparing)
import qualified Data.Primitive.Array as PA
import qualified Data.Primitive.PrimArray as PA
import qualified Data.Sequence as Sq
import qualified Data.Set as S
@ -1915,12 +1916,24 @@ universalEq frn = eqc
&& eql (==) us1 us2
&& eql eqc bs1 bs2
eqc (Foreign fl) (Foreign fr)
| Just al <- maybeUnwrapForeign Rf.iarrayRef fl,
Just ar <- maybeUnwrapForeign Rf.iarrayRef fr =
arrayEq eqc al ar
| Just sl <- maybeUnwrapForeign Rf.listRef fl,
Just sr <- maybeUnwrapForeign Rf.listRef fr =
length sl == length sr && and (Sq.zipWith eqc sl sr)
| otherwise = frn fl fr
eqc c d = closureNum c == closureNum d
arrayEq :: (Closure -> Closure -> Bool) -> PA.Array Closure -> PA.Array Closure -> Bool
arrayEq eqc l r
| PA.sizeofArray l /= PA.sizeofArray r = False
| otherwise = go (PA.sizeofArray l - 1)
where
go i
| i < 0 = True
| otherwise = eqc (PA.indexArray l i) (PA.indexArray r i) && go (i - 1)
-- IEEE floating point layout is such that comparison as integers
-- somewhat works. Positive floating values map to positive integers
-- and negatives map to negatives. The corner cases are:
@ -2018,5 +2031,19 @@ universalCompare frn = cmpc False
| Just sl <- maybeUnwrapForeign Rf.listRef fl,
Just sr <- maybeUnwrapForeign Rf.listRef fr =
comparing Sq.length sl sr <> fold (Sq.zipWith (cmpc tyEq) sl sr)
| Just al <- maybeUnwrapForeign Rf.iarrayRef fl,
Just ar <- maybeUnwrapForeign Rf.iarrayRef fr =
arrayCmp (cmpc tyEq) al ar
| otherwise = frn fl fr
cmpc _ c d = comparing closureNum c d
arrayCmp ::
(Closure -> Closure -> Ordering) ->
PA.Array Closure ->
PA.Array Closure ->
Ordering
arrayCmp cmpc l r = comparing PA.sizeofArray l r <> go (PA.sizeofArray l)
where
go i
| i < 0 = EQ
| otherwise = cmpc (PA.indexArray l i) (PA.indexArray r i) <> go (i - 1)

View File

@ -253,6 +253,14 @@ scopeRef, refRef :: Reference
scopeRef = Reference.Builtin "Scope"
refRef = Reference.Builtin "Ref"
iarrayRef, marrayRef :: Reference
iarrayRef = Reference.Builtin "ImmutableArray"
marrayRef = Reference.Builtin "MutableArray"
ibytearrayRef, mbytearrayRef :: Reference
ibytearrayRef = Reference.Builtin "ImmutableByteArray"
mbytearrayRef = Reference.Builtin "MutableByteArray"
mvarRef, tvarRef :: Reference
mvarRef = Reference.Builtin "MVar"
tvarRef = Reference.Builtin "TVar"
@ -333,6 +341,12 @@ scopeType a = ref a scopeRef
refType :: Ord v => a -> Type v a
refType a = ref a refRef
iarrayType, marrayType, ibytearrayType, mbytearrayType :: Ord v => a -> Type v a
iarrayType a = ref a iarrayRef
marrayType a = ref a marrayRef
ibytearrayType a = ref a ibytearrayRef
mbytearrayType a = ref a mbytearrayRef
socket :: Ord v => a -> Type v a
socket a = ref a socketRef
@ -599,7 +613,7 @@ removePureEffects :: ABT.Var v => Type v a -> Type v a
removePureEffects t
| not Settings.removePureEffects = t
| otherwise =
generalize vs $ removeEffectVars fvs tu
generalize vs $ removeEffectVars fvs tu
where
(vs, tu) = unforall' t
vss = Set.fromList vs

View File

@ -141,351 +141,458 @@ Let's try it!
118. Float.toText : Float -> Text
119. Float.truncate : Float -> Int
120. Handle.toText : Handle -> Text
121. builtin type Int
122. Int.* : Int -> Int -> Int
123. Int.+ : Int -> Int -> Int
124. Int.- : Int -> Int -> Int
125. Int./ : Int -> Int -> Int
126. Int.and : Int -> Int -> Int
127. Int.complement : Int -> Int
128. Int.eq : Int -> Int -> Boolean
129. Int.fromRepresentation : Nat -> Int
130. Int.fromText : Text -> Optional Int
131. Int.gt : Int -> Int -> Boolean
132. Int.gteq : Int -> Int -> Boolean
133. Int.increment : Int -> Int
134. Int.isEven : Int -> Boolean
135. Int.isOdd : Int -> Boolean
136. Int.leadingZeros : Int -> Nat
137. Int.lt : Int -> Int -> Boolean
138. Int.lteq : Int -> Int -> Boolean
139. Int.mod : Int -> Int -> Int
140. Int.negate : Int -> Int
141. Int.or : Int -> Int -> Int
142. Int.popCount : Int -> Nat
143. Int.pow : Int -> Nat -> Int
144. Int.shiftLeft : Int -> Nat -> Int
145. Int.shiftRight : Int -> Nat -> Int
146. Int.signum : Int -> Int
147. Int.toFloat : Int -> Float
148. Int.toRepresentation : Int -> Nat
149. Int.toText : Int -> Text
150. Int.trailingZeros : Int -> Nat
151. Int.truncate0 : Int -> Nat
152. Int.xor : Int -> Int -> Int
153. unique type io2.BufferMode
154. io2.BufferMode.BlockBuffering : BufferMode
155. io2.BufferMode.LineBuffering : BufferMode
156. io2.BufferMode.NoBuffering : BufferMode
157. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode
158. io2.Clock.internals.monotonic : '{IO} Either
121. builtin type ImmutableArray
122. ImmutableArray.copyTo! : MutableArray g a
-> Nat
-> ImmutableArray a
-> Nat
-> Nat
->{g, Exception} ()
123. ImmutableArray.read : ImmutableArray a
-> Nat
->{Exception} a
124. builtin type ImmutableByteArray
125. ImmutableByteArray.copyTo! : MutableByteArray g
-> Nat
-> ImmutableByteArray
-> Nat
-> Nat
->{g, Exception} ()
126. ImmutableByteArray.read16be : ImmutableByteArray
-> Nat
->{Exception} Nat
127. ImmutableByteArray.read32be : ImmutableByteArray
-> Nat
->{Exception} Nat
128. ImmutableByteArray.read64be : ImmutableByteArray
-> Nat
->{Exception} Nat
129. ImmutableByteArray.read8 : ImmutableByteArray
-> Nat
->{Exception} Nat
130. builtin type Int
131. Int.* : Int -> Int -> Int
132. Int.+ : Int -> Int -> Int
133. Int.- : Int -> Int -> Int
134. Int./ : Int -> Int -> Int
135. Int.and : Int -> Int -> Int
136. Int.complement : Int -> Int
137. Int.eq : Int -> Int -> Boolean
138. Int.fromRepresentation : Nat -> Int
139. Int.fromText : Text -> Optional Int
140. Int.gt : Int -> Int -> Boolean
141. Int.gteq : Int -> Int -> Boolean
142. Int.increment : Int -> Int
143. Int.isEven : Int -> Boolean
144. Int.isOdd : Int -> Boolean
145. Int.leadingZeros : Int -> Nat
146. Int.lt : Int -> Int -> Boolean
147. Int.lteq : Int -> Int -> Boolean
148. Int.mod : Int -> Int -> Int
149. Int.negate : Int -> Int
150. Int.or : Int -> Int -> Int
151. Int.popCount : Int -> Nat
152. Int.pow : Int -> Nat -> Int
153. Int.shiftLeft : Int -> Nat -> Int
154. Int.shiftRight : Int -> Nat -> Int
155. Int.signum : Int -> Int
156. Int.toFloat : Int -> Float
157. Int.toRepresentation : Int -> Nat
158. Int.toText : Int -> Text
159. Int.trailingZeros : Int -> Nat
160. Int.truncate0 : Int -> Nat
161. Int.xor : Int -> Int -> Int
162. unique type io2.ArrayFailure
163. unique type io2.BufferMode
164. io2.BufferMode.BlockBuffering : BufferMode
165. io2.BufferMode.LineBuffering : BufferMode
166. io2.BufferMode.NoBuffering : BufferMode
167. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode
168. io2.Clock.internals.monotonic : '{IO} Either
Failure TimeSpec
159. io2.Clock.internals.nsec : TimeSpec -> Nat
160. io2.Clock.internals.processCPUTime : '{IO} Either
169. io2.Clock.internals.nsec : TimeSpec -> Nat
170. io2.Clock.internals.processCPUTime : '{IO} Either
Failure TimeSpec
161. io2.Clock.internals.realtime : '{IO} Either
171. io2.Clock.internals.realtime : '{IO} Either
Failure TimeSpec
162. io2.Clock.internals.sec : TimeSpec -> Int
163. io2.Clock.internals.threadCPUTime : '{IO} Either
172. io2.Clock.internals.sec : TimeSpec -> Int
173. io2.Clock.internals.threadCPUTime : '{IO} Either
Failure TimeSpec
164. builtin type io2.Clock.internals.TimeSpec
165. unique type io2.Failure
166. io2.Failure.Failure : Type -> Text -> Any -> Failure
167. unique type io2.FileMode
168. io2.FileMode.Append : FileMode
169. io2.FileMode.Read : FileMode
170. io2.FileMode.ReadWrite : FileMode
171. io2.FileMode.Write : FileMode
172. builtin type io2.Handle
173. builtin type io2.IO
174. io2.IO.clientSocket.impl : Text
174. builtin type io2.Clock.internals.TimeSpec
175. unique type io2.Failure
176. io2.Failure.Failure : Type -> Text -> Any -> Failure
177. unique type io2.FileMode
178. io2.FileMode.Append : FileMode
179. io2.FileMode.Read : FileMode
180. io2.FileMode.ReadWrite : FileMode
181. io2.FileMode.Write : FileMode
182. builtin type io2.Handle
183. builtin type io2.IO
184. io2.IO.array : Nat ->{IO} MutableArray {IO} a
185. io2.IO.arrayOf : a -> Nat ->{IO} MutableArray {IO} a
186. io2.IO.bytearray : Nat ->{IO} MutableByteArray {IO}
187. io2.IO.bytearrayOf : Nat
-> Nat
->{IO} MutableByteArray {IO}
188. io2.IO.clientSocket.impl : Text
-> Text
->{IO} Either Failure Socket
175. io2.IO.closeFile.impl : Handle ->{IO} Either Failure ()
176. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure ()
177. io2.IO.createDirectory.impl : Text
189. io2.IO.closeFile.impl : Handle ->{IO} Either Failure ()
190. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure ()
191. io2.IO.createDirectory.impl : Text
->{IO} Either Failure ()
178. io2.IO.createTempDirectory.impl : Text
192. io2.IO.createTempDirectory.impl : Text
->{IO} Either
Failure Text
179. io2.IO.delay.impl : Nat ->{IO} Either Failure ()
180. io2.IO.directoryContents.impl : Text
193. io2.IO.delay.impl : Nat ->{IO} Either Failure ()
194. io2.IO.directoryContents.impl : Text
->{IO} Either
Failure [Text]
181. io2.IO.fileExists.impl : Text
195. io2.IO.fileExists.impl : Text
->{IO} Either Failure Boolean
182. io2.IO.forkComp : '{IO} a ->{IO} ThreadId
183. io2.IO.getArgs.impl : '{IO} Either Failure [Text]
184. io2.IO.getBuffering.impl : Handle
196. io2.IO.forkComp : '{IO} a ->{IO} ThreadId
197. io2.IO.getArgs.impl : '{IO} Either Failure [Text]
198. io2.IO.getBuffering.impl : Handle
->{IO} Either
Failure BufferMode
185. io2.IO.getBytes.impl : Handle
199. io2.IO.getBytes.impl : Handle
-> Nat
->{IO} Either Failure Bytes
186. io2.IO.getCurrentDirectory.impl : '{IO} Either
200. io2.IO.getCurrentDirectory.impl : '{IO} Either
Failure Text
187. io2.IO.getEnv.impl : Text ->{IO} Either Failure Text
188. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat
189. io2.IO.getFileTimestamp.impl : Text
201. io2.IO.getEnv.impl : Text ->{IO} Either Failure Text
202. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat
203. io2.IO.getFileTimestamp.impl : Text
->{IO} Either Failure Nat
190. io2.IO.getLine.impl : Handle ->{IO} Either Failure Text
191. io2.IO.getSomeBytes.impl : Handle
204. io2.IO.getLine.impl : Handle ->{IO} Either Failure Text
205. io2.IO.getSomeBytes.impl : Handle
-> Nat
->{IO} Either Failure Bytes
192. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text
193. io2.IO.handlePosition.impl : Handle
206. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text
207. io2.IO.handlePosition.impl : Handle
->{IO} Either Failure Nat
194. io2.IO.isDirectory.impl : Text
208. io2.IO.isDirectory.impl : Text
->{IO} Either Failure Boolean
195. io2.IO.isFileEOF.impl : Handle
209. io2.IO.isFileEOF.impl : Handle
->{IO} Either Failure Boolean
196. io2.IO.isFileOpen.impl : Handle
210. io2.IO.isFileOpen.impl : Handle
->{IO} Either Failure Boolean
197. io2.IO.isSeekable.impl : Handle
211. io2.IO.isSeekable.impl : Handle
->{IO} Either Failure Boolean
198. io2.IO.kill.impl : ThreadId ->{IO} Either Failure ()
199. io2.IO.listen.impl : Socket ->{IO} Either Failure ()
200. io2.IO.openFile.impl : Text
212. io2.IO.kill.impl : ThreadId ->{IO} Either Failure ()
213. io2.IO.listen.impl : Socket ->{IO} Either Failure ()
214. io2.IO.openFile.impl : Text
-> FileMode
->{IO} Either Failure Handle
201. io2.IO.putBytes.impl : Handle
215. io2.IO.putBytes.impl : Handle
-> Bytes
->{IO} Either Failure ()
202. io2.IO.ref : a ->{IO} Ref {IO} a
203. io2.IO.removeDirectory.impl : Text
216. io2.IO.ref : a ->{IO} Ref {IO} a
217. io2.IO.removeDirectory.impl : Text
->{IO} Either Failure ()
204. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
205. io2.IO.renameDirectory.impl : Text
218. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
219. io2.IO.renameDirectory.impl : Text
-> Text
->{IO} Either Failure ()
206. io2.IO.renameFile.impl : Text
220. io2.IO.renameFile.impl : Text
-> Text
->{IO} Either Failure ()
207. io2.IO.seekHandle.impl : Handle
221. io2.IO.seekHandle.impl : Handle
-> SeekMode
-> Int
->{IO} Either Failure ()
208. io2.IO.serverSocket.impl : Optional Text
222. io2.IO.serverSocket.impl : Optional Text
-> Text
->{IO} Either Failure Socket
209. io2.IO.setBuffering.impl : Handle
223. io2.IO.setBuffering.impl : Handle
-> BufferMode
->{IO} Either Failure ()
210. io2.IO.setCurrentDirectory.impl : Text
224. io2.IO.setCurrentDirectory.impl : Text
->{IO} Either
Failure ()
211. io2.IO.socketAccept.impl : Socket
225. io2.IO.socketAccept.impl : Socket
->{IO} Either Failure Socket
212. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
213. io2.IO.socketReceive.impl : Socket
226. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
227. io2.IO.socketReceive.impl : Socket
-> Nat
->{IO} Either Failure Bytes
214. io2.IO.socketSend.impl : Socket
228. io2.IO.socketSend.impl : Socket
-> Bytes
->{IO} Either Failure ()
215. io2.IO.stdHandle : StdHandle -> Handle
216. io2.IO.systemTime.impl : '{IO} Either Failure Nat
217. io2.IO.systemTimeMicroseconds : '{IO} Int
218. unique type io2.IOError
219. io2.IOError.AlreadyExists : IOError
220. io2.IOError.EOF : IOError
221. io2.IOError.IllegalOperation : IOError
222. io2.IOError.NoSuchThing : IOError
223. io2.IOError.PermissionDenied : IOError
224. io2.IOError.ResourceBusy : IOError
225. io2.IOError.ResourceExhausted : IOError
226. io2.IOError.UserError : IOError
227. unique type io2.IOFailure
228. builtin type io2.MVar
229. io2.MVar.isEmpty : MVar a ->{IO} Boolean
230. io2.MVar.new : a ->{IO} MVar a
231. io2.MVar.newEmpty : '{IO} MVar a
232. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
233. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
234. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
235. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
236. io2.MVar.tryPut.impl : MVar a
229. io2.IO.stdHandle : StdHandle -> Handle
230. io2.IO.systemTime.impl : '{IO} Either Failure Nat
231. io2.IO.systemTimeMicroseconds : '{IO} Int
232. unique type io2.IOError
233. io2.IOError.AlreadyExists : IOError
234. io2.IOError.EOF : IOError
235. io2.IOError.IllegalOperation : IOError
236. io2.IOError.NoSuchThing : IOError
237. io2.IOError.PermissionDenied : IOError
238. io2.IOError.ResourceBusy : IOError
239. io2.IOError.ResourceExhausted : IOError
240. io2.IOError.UserError : IOError
241. unique type io2.IOFailure
242. builtin type io2.MVar
243. io2.MVar.isEmpty : MVar a ->{IO} Boolean
244. io2.MVar.new : a ->{IO} MVar a
245. io2.MVar.newEmpty : '{IO} MVar a
246. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
247. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
248. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
249. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
250. io2.MVar.tryPut.impl : MVar a
-> a
->{IO} Either Failure Boolean
237. io2.MVar.tryRead.impl : MVar a
251. io2.MVar.tryRead.impl : MVar a
->{IO} Either
Failure (Optional a)
238. io2.MVar.tryTake : MVar a ->{IO} Optional a
239. unique type io2.SeekMode
240. io2.SeekMode.AbsoluteSeek : SeekMode
241. io2.SeekMode.RelativeSeek : SeekMode
242. io2.SeekMode.SeekFromEnd : SeekMode
243. builtin type io2.Socket
244. unique type io2.StdHandle
245. io2.StdHandle.StdErr : StdHandle
246. io2.StdHandle.StdIn : StdHandle
247. io2.StdHandle.StdOut : StdHandle
248. builtin type io2.STM
249. io2.STM.atomically : '{STM} a ->{IO} a
250. io2.STM.retry : '{STM} a
251. builtin type io2.ThreadId
252. builtin type io2.Tls
253. builtin type io2.Tls.Cipher
254. builtin type io2.Tls.ClientConfig
255. io2.Tls.ClientConfig.certificates.set : [SignedCert]
252. io2.MVar.tryTake : MVar a ->{IO} Optional a
253. unique type io2.SeekMode
254. io2.SeekMode.AbsoluteSeek : SeekMode
255. io2.SeekMode.RelativeSeek : SeekMode
256. io2.SeekMode.SeekFromEnd : SeekMode
257. builtin type io2.Socket
258. unique type io2.StdHandle
259. io2.StdHandle.StdErr : StdHandle
260. io2.StdHandle.StdIn : StdHandle
261. io2.StdHandle.StdOut : StdHandle
262. builtin type io2.STM
263. io2.STM.atomically : '{STM} a ->{IO} a
264. io2.STM.retry : '{STM} a
265. builtin type io2.ThreadId
266. builtin type io2.Tls
267. builtin type io2.Tls.Cipher
268. builtin type io2.Tls.ClientConfig
269. io2.Tls.ClientConfig.certificates.set : [SignedCert]
-> ClientConfig
-> ClientConfig
256. io2.TLS.ClientConfig.ciphers.set : [Cipher]
270. io2.TLS.ClientConfig.ciphers.set : [Cipher]
-> ClientConfig
-> ClientConfig
257. io2.Tls.ClientConfig.default : Text
271. io2.Tls.ClientConfig.default : Text
-> Bytes
-> ClientConfig
258. io2.Tls.ClientConfig.versions.set : [Version]
272. io2.Tls.ClientConfig.versions.set : [Version]
-> ClientConfig
-> ClientConfig
259. io2.Tls.decodeCert.impl : Bytes
273. io2.Tls.decodeCert.impl : Bytes
-> Either Failure SignedCert
260. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
261. io2.Tls.encodeCert : SignedCert -> Bytes
262. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
263. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
264. io2.Tls.newClient.impl : ClientConfig
274. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
275. io2.Tls.encodeCert : SignedCert -> Bytes
276. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
277. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
278. io2.Tls.newClient.impl : ClientConfig
-> Socket
->{IO} Either Failure Tls
265. io2.Tls.newServer.impl : ServerConfig
279. io2.Tls.newServer.impl : ServerConfig
-> Socket
->{IO} Either Failure Tls
266. builtin type io2.Tls.PrivateKey
267. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
268. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
269. builtin type io2.Tls.ServerConfig
270. io2.Tls.ServerConfig.certificates.set : [SignedCert]
280. builtin type io2.Tls.PrivateKey
281. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
282. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
283. builtin type io2.Tls.ServerConfig
284. io2.Tls.ServerConfig.certificates.set : [SignedCert]
-> ServerConfig
-> ServerConfig
271. io2.Tls.ServerConfig.ciphers.set : [Cipher]
285. io2.Tls.ServerConfig.ciphers.set : [Cipher]
-> ServerConfig
-> ServerConfig
272. io2.Tls.ServerConfig.default : [SignedCert]
286. io2.Tls.ServerConfig.default : [SignedCert]
-> PrivateKey
-> ServerConfig
273. io2.Tls.ServerConfig.versions.set : [Version]
287. io2.Tls.ServerConfig.versions.set : [Version]
-> ServerConfig
-> ServerConfig
274. builtin type io2.Tls.SignedCert
275. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
276. builtin type io2.Tls.Version
277. unique type io2.TlsFailure
278. builtin type io2.TVar
279. io2.TVar.new : a ->{STM} TVar a
280. io2.TVar.newIO : a ->{IO} TVar a
281. io2.TVar.read : TVar a ->{STM} a
282. io2.TVar.readIO : TVar a ->{IO} a
283. io2.TVar.swap : TVar a -> a ->{STM} a
284. io2.TVar.write : TVar a -> a ->{STM} ()
285. io2.validateSandboxed : [Term] -> a -> Boolean
286. unique type IsPropagated
287. IsPropagated.IsPropagated : IsPropagated
288. unique type IsTest
289. IsTest.IsTest : IsTest
290. unique type Link
291. builtin type Link.Term
292. Link.Term : Term -> Link
293. Link.Term.toText : Term -> Text
294. builtin type Link.Type
295. Link.Type : Type -> Link
296. builtin type List
297. List.++ : [a] -> [a] -> [a]
298. List.+: : a -> [a] -> [a]
299. List.:+ : [a] -> a -> [a]
300. List.at : Nat -> [a] -> Optional a
301. List.cons : a -> [a] -> [a]
302. List.drop : Nat -> [a] -> [a]
303. List.empty : [a]
304. List.size : [a] -> Nat
305. List.snoc : [a] -> a -> [a]
306. List.take : Nat -> [a] -> [a]
307. metadata.isPropagated : IsPropagated
308. metadata.isTest : IsTest
309. builtin type Nat
310. Nat.* : Nat -> Nat -> Nat
311. Nat.+ : Nat -> Nat -> Nat
312. Nat./ : Nat -> Nat -> Nat
313. Nat.and : Nat -> Nat -> Nat
314. Nat.complement : Nat -> Nat
315. Nat.drop : Nat -> Nat -> Nat
316. Nat.eq : Nat -> Nat -> Boolean
317. Nat.fromText : Text -> Optional Nat
318. Nat.gt : Nat -> Nat -> Boolean
319. Nat.gteq : Nat -> Nat -> Boolean
320. Nat.increment : Nat -> Nat
321. Nat.isEven : Nat -> Boolean
322. Nat.isOdd : Nat -> Boolean
323. Nat.leadingZeros : Nat -> Nat
324. Nat.lt : Nat -> Nat -> Boolean
325. Nat.lteq : Nat -> Nat -> Boolean
326. Nat.mod : Nat -> Nat -> Nat
327. Nat.or : Nat -> Nat -> Nat
328. Nat.popCount : Nat -> Nat
329. Nat.pow : Nat -> Nat -> Nat
330. Nat.shiftLeft : Nat -> Nat -> Nat
331. Nat.shiftRight : Nat -> Nat -> Nat
332. Nat.sub : Nat -> Nat -> Int
333. Nat.toFloat : Nat -> Float
334. Nat.toInt : Nat -> Int
335. Nat.toText : Nat -> Text
336. Nat.trailingZeros : Nat -> Nat
337. Nat.xor : Nat -> Nat -> Nat
338. structural type Optional a
339. Optional.None : Optional a
340. Optional.Some : a -> Optional a
341. builtin type Ref
342. Ref.read : Ref g a ->{g} a
343. Ref.write : Ref g a -> a ->{g} ()
344. builtin type Request
345. builtin type Scope
346. Scope.ref : a ->{Scope s} Ref {Scope s} a
347. Scope.run : (∀ s. '{g, Scope s} r) ->{g} r
348. structural type SeqView a b
349. SeqView.VElem : a -> b -> SeqView a b
350. SeqView.VEmpty : SeqView a b
351. Socket.toText : Socket -> Text
352. unique type Test.Result
353. Test.Result.Fail : Text -> Result
354. Test.Result.Ok : Text -> Result
355. builtin type Text
356. Text.!= : Text -> Text -> Boolean
357. Text.++ : Text -> Text -> Text
358. Text.drop : Nat -> Text -> Text
359. Text.empty : Text
360. Text.eq : Text -> Text -> Boolean
361. Text.fromCharList : [Char] -> Text
362. Text.fromUtf8.impl : Bytes -> Either Failure Text
363. Text.gt : Text -> Text -> Boolean
364. Text.gteq : Text -> Text -> Boolean
365. Text.lt : Text -> Text -> Boolean
366. Text.lteq : Text -> Text -> Boolean
367. Text.repeat : Nat -> Text -> Text
368. Text.size : Text -> Nat
369. Text.take : Nat -> Text -> Text
370. Text.toCharList : Text -> [Char]
371. Text.toUtf8 : Text -> Bytes
372. Text.uncons : Text -> Optional (Char, Text)
373. Text.unsnoc : Text -> Optional (Text, Char)
374. ThreadId.toText : ThreadId -> Text
375. todo : a -> b
376. structural type Tuple a b
377. Tuple.Cons : a -> b -> Tuple a b
378. structural type Unit
379. Unit.Unit : ()
380. Universal.< : a -> a -> Boolean
381. Universal.<= : a -> a -> Boolean
382. Universal.== : a -> a -> Boolean
383. Universal.> : a -> a -> Boolean
384. Universal.>= : a -> a -> Boolean
385. Universal.compare : a -> a -> Int
386. unsafe.coerceAbilities : (a ->{e1} b) -> a ->{e2} b
387. builtin type Value
388. Value.dependencies : Value -> [Term]
389. Value.deserialize : Bytes -> Either Text Value
390. Value.load : Value ->{IO} Either [Term] a
391. Value.serialize : Value -> Bytes
392. Value.value : a -> Value
288. builtin type io2.Tls.SignedCert
289. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
290. builtin type io2.Tls.Version
291. unique type io2.TlsFailure
292. builtin type io2.TVar
293. io2.TVar.new : a ->{STM} TVar a
294. io2.TVar.newIO : a ->{IO} TVar a
295. io2.TVar.read : TVar a ->{STM} a
296. io2.TVar.readIO : TVar a ->{IO} a
297. io2.TVar.swap : TVar a -> a ->{STM} a
298. io2.TVar.write : TVar a -> a ->{STM} ()
299. io2.validateSandboxed : [Term] -> a -> Boolean
300. unique type IsPropagated
301. IsPropagated.IsPropagated : IsPropagated
302. unique type IsTest
303. IsTest.IsTest : IsTest
304. unique type Link
305. builtin type Link.Term
306. Link.Term : Term -> Link
307. Link.Term.toText : Term -> Text
308. builtin type Link.Type
309. Link.Type : Type -> Link
310. builtin type List
311. List.++ : [a] -> [a] -> [a]
312. List.+: : a -> [a] -> [a]
313. List.:+ : [a] -> a -> [a]
314. List.at : Nat -> [a] -> Optional a
315. List.cons : a -> [a] -> [a]
316. List.drop : Nat -> [a] -> [a]
317. List.empty : [a]
318. List.size : [a] -> Nat
319. List.snoc : [a] -> a -> [a]
320. List.take : Nat -> [a] -> [a]
321. metadata.isPropagated : IsPropagated
322. metadata.isTest : IsTest
323. builtin type MutableArray
324. MutableArray.copyTo! : MutableArray g a
-> Nat
-> MutableArray g a
-> Nat
-> Nat
->{g, Exception} ()
325. MutableArray.freeze : MutableArray g a
-> Nat
-> Nat
->{g} ImmutableArray a
326. MutableArray.freeze! : MutableArray g a
->{g} ImmutableArray a
327. MutableArray.read : MutableArray g a
-> Nat
->{g, Exception} a
328. MutableArray.write : MutableArray g a
-> Nat
-> a
->{g, Exception} ()
329. builtin type MutableByteArray
330. MutableByteArray.copyTo! : MutableByteArray g
-> Nat
-> MutableByteArray g
-> Nat
-> Nat
->{g, Exception} ()
331. MutableByteArray.freeze : MutableByteArray g
-> Nat
-> Nat
->{g} ImmutableByteArray
332. MutableByteArray.freeze! : MutableByteArray g
->{g} ImmutableByteArray
333. MutableByteArray.read16be : MutableByteArray g
-> Nat
->{g, Exception} Nat
334. MutableByteArray.read32be : MutableByteArray g
-> Nat
->{g, Exception} Nat
335. MutableByteArray.read64be : MutableByteArray g
-> Nat
->{g, Exception} Nat
336. MutableByteArray.read8 : MutableByteArray g
-> Nat
->{g, Exception} Nat
337. MutableByteArray.write16be : MutableByteArray g
-> Nat
-> Nat
->{g, Exception} ()
338. MutableByteArray.write32be : MutableByteArray g
-> Nat
-> Nat
->{g, Exception} ()
339. MutableByteArray.write64be : MutableByteArray g
-> Nat
-> Nat
->{g, Exception} ()
340. MutableByteArray.write8 : MutableByteArray g
-> Nat
-> Nat
->{g, Exception} ()
341. builtin type Nat
342. Nat.* : Nat -> Nat -> Nat
343. Nat.+ : Nat -> Nat -> Nat
344. Nat./ : Nat -> Nat -> Nat
345. Nat.and : Nat -> Nat -> Nat
346. Nat.complement : Nat -> Nat
347. Nat.drop : Nat -> Nat -> Nat
348. Nat.eq : Nat -> Nat -> Boolean
349. Nat.fromText : Text -> Optional Nat
350. Nat.gt : Nat -> Nat -> Boolean
351. Nat.gteq : Nat -> Nat -> Boolean
352. Nat.increment : Nat -> Nat
353. Nat.isEven : Nat -> Boolean
354. Nat.isOdd : Nat -> Boolean
355. Nat.leadingZeros : Nat -> Nat
356. Nat.lt : Nat -> Nat -> Boolean
357. Nat.lteq : Nat -> Nat -> Boolean
358. Nat.mod : Nat -> Nat -> Nat
359. Nat.or : Nat -> Nat -> Nat
360. Nat.popCount : Nat -> Nat
361. Nat.pow : Nat -> Nat -> Nat
362. Nat.shiftLeft : Nat -> Nat -> Nat
363. Nat.shiftRight : Nat -> Nat -> Nat
364. Nat.sub : Nat -> Nat -> Int
365. Nat.toFloat : Nat -> Float
366. Nat.toInt : Nat -> Int
367. Nat.toText : Nat -> Text
368. Nat.trailingZeros : Nat -> Nat
369. Nat.xor : Nat -> Nat -> Nat
370. structural type Optional a
371. Optional.None : Optional a
372. Optional.Some : a -> Optional a
373. builtin type Ref
374. Ref.read : Ref g a ->{g} a
375. Ref.write : Ref g a -> a ->{g} ()
376. builtin type Request
377. builtin type Scope
378. Scope.array : Nat ->{Scope s} MutableArray (Scope s) a
379. Scope.arrayOf : a
-> Nat
->{Scope s} MutableArray (Scope s) a
380. Scope.bytearray : Nat
->{Scope s} MutableByteArray (Scope s)
381. Scope.bytearrayOf : Nat
-> Nat
->{Scope s} MutableByteArray
(Scope s)
382. Scope.ref : a ->{Scope s} Ref {Scope s} a
383. Scope.run : (∀ s. '{g, Scope s} r) ->{g} r
384. structural type SeqView a b
385. SeqView.VElem : a -> b -> SeqView a b
386. SeqView.VEmpty : SeqView a b
387. Socket.toText : Socket -> Text
388. unique type Test.Result
389. Test.Result.Fail : Text -> Result
390. Test.Result.Ok : Text -> Result
391. builtin type Text
392. Text.!= : Text -> Text -> Boolean
393. Text.++ : Text -> Text -> Text
394. Text.drop : Nat -> Text -> Text
395. Text.empty : Text
396. Text.eq : Text -> Text -> Boolean
397. Text.fromCharList : [Char] -> Text
398. Text.fromUtf8.impl : Bytes -> Either Failure Text
399. Text.gt : Text -> Text -> Boolean
400. Text.gteq : Text -> Text -> Boolean
401. Text.lt : Text -> Text -> Boolean
402. Text.lteq : Text -> Text -> Boolean
403. Text.repeat : Nat -> Text -> Text
404. Text.size : Text -> Nat
405. Text.take : Nat -> Text -> Text
406. Text.toCharList : Text -> [Char]
407. Text.toUtf8 : Text -> Bytes
408. Text.uncons : Text -> Optional (Char, Text)
409. Text.unsnoc : Text -> Optional (Text, Char)
410. ThreadId.toText : ThreadId -> Text
411. todo : a -> b
412. structural type Tuple a b
413. Tuple.Cons : a -> b -> Tuple a b
414. structural type Unit
415. Unit.Unit : ()
416. Universal.< : a -> a -> Boolean
417. Universal.<= : a -> a -> Boolean
418. Universal.== : a -> a -> Boolean
419. Universal.> : a -> a -> Boolean
420. Universal.>= : a -> a -> Boolean
421. Universal.compare : a -> a -> Int
422. unsafe.coerceAbilities : (a ->{e1} b) -> a ->{e2} b
423. builtin type Value
424. Value.dependencies : Value -> [Term]
425. Value.deserialize : Bytes -> Either Text Value
426. Value.load : Value ->{IO} Either [Term] a
427. Value.serialize : Value -> Bytes
428. Value.value : a -> Value
.builtin> alias.many 94-104 .mylib

View File

@ -9,64 +9,72 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
.tmp> ls builtin
1. Any (builtin type)
2. Any/ (2 definitions)
3. Boolean (builtin type)
4. Boolean/ (1 definition)
5. Bytes (builtin type)
6. Bytes/ (33 definitions)
7. Char (builtin type)
8. Char/ (3 definitions)
9. Code (builtin type)
10. Code/ (8 definitions)
11. Debug/ (2 definitions)
12. Doc (type)
13. Doc/ (6 definitions)
14. Either (type)
15. Either/ (2 definitions)
16. Exception (type)
17. Exception/ (1 definition)
18. Float (builtin type)
19. Float/ (38 definitions)
20. Handle/ (1 definition)
21. Int (builtin type)
22. Int/ (31 definitions)
23. IsPropagated (type)
24. IsPropagated/ (1 definition)
25. IsTest (type)
26. IsTest/ (1 definition)
27. Link (type)
28. Link/ (5 definitions)
29. List (builtin type)
30. List/ (10 definitions)
31. Nat (builtin type)
32. Nat/ (28 definitions)
33. Optional (type)
34. Optional/ (2 definitions)
35. Ref (builtin type)
36. Ref/ (2 definitions)
37. Request (builtin type)
38. Scope (builtin type)
39. Scope/ (2 definitions)
40. SeqView (type)
41. SeqView/ (2 definitions)
42. Socket/ (1 definition)
43. Test/ (3 definitions)
44. Text (builtin type)
45. Text/ (18 definitions)
46. ThreadId/ (1 definition)
47. Tuple (type)
48. Tuple/ (1 definition)
49. Unit (type)
50. Unit/ (1 definition)
51. Universal/ (6 definitions)
52. Value (builtin type)
53. Value/ (5 definitions)
54. bug (a -> b)
55. crypto/ (13 definitions)
56. io2/ (133 definitions)
57. metadata/ (2 definitions)
58. todo (a -> b)
59. unsafe/ (1 definition)
1. Any (builtin type)
2. Any/ (2 definitions)
3. Boolean (builtin type)
4. Boolean/ (1 definition)
5. Bytes (builtin type)
6. Bytes/ (33 definitions)
7. Char (builtin type)
8. Char/ (3 definitions)
9. Code (builtin type)
10. Code/ (8 definitions)
11. Debug/ (2 definitions)
12. Doc (type)
13. Doc/ (6 definitions)
14. Either (type)
15. Either/ (2 definitions)
16. Exception (type)
17. Exception/ (1 definition)
18. Float (builtin type)
19. Float/ (38 definitions)
20. Handle/ (1 definition)
21. ImmutableArray (builtin type)
22. ImmutableArray/ (2 definitions)
23. ImmutableByteArray (builtin type)
24. ImmutableByteArray/ (5 definitions)
25. Int (builtin type)
26. Int/ (31 definitions)
27. IsPropagated (type)
28. IsPropagated/ (1 definition)
29. IsTest (type)
30. IsTest/ (1 definition)
31. Link (type)
32. Link/ (5 definitions)
33. List (builtin type)
34. List/ (10 definitions)
35. MutableArray (builtin type)
36. MutableArray/ (5 definitions)
37. MutableByteArray (builtin type)
38. MutableByteArray/ (11 definitions)
39. Nat (builtin type)
40. Nat/ (28 definitions)
41. Optional (type)
42. Optional/ (2 definitions)
43. Ref (builtin type)
44. Ref/ (2 definitions)
45. Request (builtin type)
46. Scope (builtin type)
47. Scope/ (6 definitions)
48. SeqView (type)
49. SeqView/ (2 definitions)
50. Socket/ (1 definition)
51. Test/ (3 definitions)
52. Text (builtin type)
53. Text/ (18 definitions)
54. ThreadId/ (1 definition)
55. Tuple (type)
56. Tuple/ (1 definition)
57. Unit (type)
58. Unit/ (1 definition)
59. Universal/ (6 definitions)
60. Value (builtin type)
61. Value/ (5 definitions)
62. bug (a -> b)
63. crypto/ (13 definitions)
64. io2/ (138 definitions)
65. metadata/ (2 definitions)
66. todo (a -> b)
67. unsafe/ (1 definition)
```

View File

@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge`
.foo> ls
1. builtin/ (392 definitions)
1. builtin/ (428 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/ (578 definitions)
1. builtin/ (614 definitions)
```
More typically, you'd start out by pulling `base.

View File

@ -121,13 +121,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.
⊙ 1. #0mhdtddb80
⊙ 1. #202434u8i8
- Deletes:
feature1.y
⊙ 2. #leu63g3bpn
⊙ 2. #320m7eprtp
+ Adds / updates:
@ -138,26 +138,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
⊙ 3. #qsefehkn4s
⊙ 3. #aqe5ukkpho
+ Adds / updates:
feature1.y
⊙ 4. #5vssi6fg86
⊙ 4. #jrmqnmjaof
> Moves:
Original name New name
x master.x
⊙ 5. #g3lmsiv8ui
⊙ 5. #c1if8chh6q
+ Adds / updates:
x
□ 6. #jnr0fqsfop (start of history)
□ 6. #jbpdv7v5t3 (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`.

File diff suppressed because it is too large Load Diff

View File

@ -59,16 +59,16 @@ y = 2
most recent, along with the command that got us there. Try:
`fork 2 .old`
`fork #6rnlsqcthn .old` to make an old namespace
`fork #iqpoatoq9n .old` to make an old namespace
accessible again,
`reset-root #6rnlsqcthn` to reset the root namespace and
`reset-root #iqpoatoq9n` to reset the root namespace and
its history to that of the
specified namespace.
1. #8kr5i8gver : add
2. #6rnlsqcthn : add
3. #odl13ktegj : builtins.merge
1. #n6l0a3mq9e : add
2. #iqpoatoq9n : add
3. #rhmjfkq4o8 : builtins.merge
4. #sg60bvjo91 : (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
□ 1. #ia768a41ec (start of history)
□ 1. #m7huejvgd3 (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.
⊙ 1. #7su28m7gvs
⊙ 1. #6f0a8lccsd
> Moves:
Original name New name
Nat.frobnicate Nat.+
⊙ 2. #00duj13j0k
⊙ 2. #rp32arn4ko
> Moves:
Original name New name
Nat.+ Nat.frobnicate
□ 3. #ia768a41ec (start of history)
□ 3. #m7huejvgd3 (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.
⊙ 1. #7su28m7gvs
⊙ 1. #6f0a8lccsd
> Moves:
Original name New name
Nat.frobnicate Nat.+
⊙ 2. #00duj13j0k
⊙ 2. #rp32arn4ko
> Moves:
Original name New name
Nat.+ Nat.frobnicate
□ 3. #ia768a41ec (start of history)
□ 3. #m7huejvgd3 (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
□ 1. #ia768a41ec (start of history)
□ 1. #m7huejvgd3 (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.
⊙ 1. #3g9mjnkcpa
⊙ 1. #1rs3r831e3
- Deletes:
Nat.* Nat.+
□ 2. #ia768a41ec (start of history)
□ 2. #m7huejvgd3 (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.