add Bytes.indexOf and Text.indexOf builtins

fixes #4060
This commit is contained in:
Stew O'Connor 2023-06-01 19:24:07 -07:00
parent 4f38a89c95
commit 054cdd87de
23 changed files with 1709 additions and 1491 deletions

View File

@ -12,6 +12,7 @@ dependencies:
- deepseq
- memory
- primitive
- stringsearch
- text
- vector
- unison-prelude

View File

@ -29,6 +29,7 @@ module Unison.Util.Bytes
at,
take,
drop,
indexOf,
size,
empty,
encodeNat16be,
@ -80,6 +81,8 @@ import Unison.Prelude hiding (ByteString, empty)
import Unison.Util.Rope qualified as R
import Unsafe.Coerce (unsafeCoerce)
import Prelude hiding (drop, take)
import qualified Data.ByteString.Lazy.Search as SS
type Chunk = V.Vector Word8
@ -193,6 +196,15 @@ take n (Bytes bs) = Bytes (R.take n bs)
drop :: Int -> Bytes -> Bytes
drop n (Bytes bs) = Bytes (R.drop n bs)
indexOf :: Bytes -> Bytes -> Maybe Word64
indexOf needle haystack =
case SS.indices needle' haystack' of
[] -> Nothing
(i:_) -> Just (fromIntegral i)
where
needle' = toByteString needle
haystack' = toLazyByteString haystack
at, index :: Int -> Bytes -> Maybe Word8
at n (Bytes bs) = R.index n bs
index = at

View File

@ -59,6 +59,7 @@ library
, deepseq
, memory
, primitive
, stringsearch
, text
, unison-prelude
, unison-util-rope
@ -112,6 +113,7 @@ test-suite util-bytes-tests
, easytest
, memory
, primitive
, stringsearch
, text
, unison-prelude
, unison-util-bytes

View File

@ -480,6 +480,7 @@ builtinsSrc =
B "Text.++" $ text --> text --> text,
B "Text.take" $ nat --> text --> text,
B "Text.drop" $ nat --> text --> text,
B "Text.indexOf" $ text --> text --> optionalt nat,
B "Text.size" $ text --> nat,
B "Text.repeat" $ nat --> text --> text,
B "Text.==" $ text --> text --> boolean,
@ -529,6 +530,7 @@ builtinsSrc =
B "Bytes.take" $ nat --> bytes --> bytes,
B "Bytes.drop" $ nat --> bytes --> bytes,
B "Bytes.at" $ nat --> bytes --> optionalt nat,
B "Bytes.indexOf" $ bytes --> bytes --> optionalt nat,
B "Bytes.toList" $ bytes --> list nat,
B "Bytes.size" $ bytes --> nat,
B "Bytes.flatten" $ bytes --> bytes,

View File

@ -1256,6 +1256,7 @@ data POp
| TAKT
| DRPT
| SIZT -- ++,take,drop,size
| IXOT -- indexOf
| UCNS
| USNC
| EQLT
@ -1280,6 +1281,7 @@ data POp
| UPKB
| TAKB
| DRPB -- pack,unpack,take,drop
| IXOB -- indexOf
| IDXB
| SIZB
| FLTB

View File

@ -559,6 +559,8 @@ pOpCode op = case op of
ATOM -> 117
TFRC -> 118
DBTX -> 119
IXOT -> 120
IXOB -> 121
pOpAssoc :: [(POp, Word16)]
pOpAssoc = map (\op -> (op, pOpCode op)) [minBound .. maxBound]

View File

@ -533,7 +533,7 @@ dropn = binop0 4 $ \[x0, y0, x, y, b, r] ->
)
$ TCon Ty.natRef 0 [r]
appendt, taket, dropt, sizet, unconst, unsnoct :: (Var v) => SuperNormal v
appendt, taket, dropt, indext, indexb, sizet, unconst, unsnoct :: (Var v) => SuperNormal v
appendt = binop0 0 $ \[x, y] -> TPrm CATT [x, y]
taket = binop0 1 $ \[x0, y, x] ->
unbox x0 Ty.natRef x $
@ -541,6 +541,52 @@ taket = binop0 1 $ \[x0, y, x] ->
dropt = binop0 1 $ \[x0, y, x] ->
unbox x0 Ty.natRef x $
TPrm DRPT [x, y]
atb = binop0 4 $ \[n0, b, n, t, r0, r] ->
unbox n0 Ty.natRef n
. TLetD t UN (TPrm IDXB [n, b])
. TMatch t
. MatchSum
$ mapFromList
[ (0, ([], none)),
( 1,
( [UN],
TAbs r0
. TLetD r BX (TCon Ty.natRef 0 [r0])
$ some r
)
)
]
indext = binop0 3 $ \[x, y, t, r0, r] ->
TLetD t UN (TPrm IXOT [x, y])
. TMatch t
. MatchSum
$ mapFromList
[ (0, ([], none )),
(1,
( [UN],
TAbs r0
. TLetD r BX (TCon Ty.natRef 0 [r0])
$ some r
)
)
]
indexb = binop0 3 $ \[x, y, t, i, r] ->
TLetD t UN (TPrm IXOB [x, y])
. TMatch t
. MatchSum
$ mapFromList
[ (0, ([], none)),
(1,
( [UN],
TAbs i
. TLetD r BX (TCon Ty.natRef 0 [i])
$ some r
)
)
]
sizet = unop0 1 $ \[x, r] ->
TLetD r UN (TPrm SIZT [x]) $
TCon Ty.natRef 0 [r]
@ -670,21 +716,6 @@ takeb = binop0 1 $ \[n0, b, n] ->
dropb = binop0 1 $ \[n0, b, n] ->
unbox n0 Ty.natRef n $
TPrm DRPB [n, b]
atb = binop0 4 $ \[n0, b, n, t, r0, r] ->
unbox n0 Ty.natRef n
. TLetD t UN (TPrm IDXB [n, b])
. TMatch t
. MatchSum
$ mapFromList
[ (0, ([], none)),
( 1,
( [UN],
TAbs r0
. TLetD r BX (TCon Ty.natRef 0 [r0])
$ some r
)
)
]
sizeb = unop0 1 $ \[b, n] ->
TLetD n UN (TPrm SIZB [b]) $
TCon Ty.natRef 0 [n]
@ -1998,6 +2029,7 @@ builtinLookup =
("Text.++", (Untracked, appendt)),
("Text.take", (Untracked, taket)),
("Text.drop", (Untracked, dropt)),
("Text.indexOf", (Untracked, indext)),
("Text.size", (Untracked, sizet)),
("Text.==", (Untracked, eqt)),
("Text.!=", (Untracked, neqt)),
@ -2027,6 +2059,7 @@ builtinLookup =
("Bytes.take", (Untracked, takeb)),
("Bytes.drop", (Untracked, dropb)),
("Bytes.at", (Untracked, atb)),
("Bytes.indexOf", (Untracked, indexb)),
("Bytes.size", (Untracked, sizeb)),
("Bytes.flatten", (Untracked, flattenb)),
("List.take", (Untracked, takes)),

View File

@ -399,6 +399,7 @@ data BPrim2
| DRPT
| CATT
| TAKT -- drop,append,take
| IXOT -- indexof
| EQLT
| LEQT
| LEST -- ==,<=,<
@ -416,6 +417,7 @@ data BPrim2
| DRPB
| IDXB
| CATB -- take,drop,index,append
| IXOB -- indexof
-- general
| THRO -- throw
| TRCE -- trace
@ -1138,6 +1140,7 @@ emitPOp ANF.TTOF = emitBP1 TTOF
emitPOp ANF.CATT = emitBP2 CATT
emitPOp ANF.TAKT = emitBP2 TAKT
emitPOp ANF.DRPT = emitBP2 DRPT
emitPOp ANF.IXOT = emitBP2 IXOT
emitPOp ANF.SIZT = emitBP1 SIZT
emitPOp ANF.UCNS = emitBP1 UCNS
emitPOp ANF.USNC = emitBP1 USNC
@ -1162,6 +1165,7 @@ emitPOp ANF.PAKB = emitBP1 PAKB
emitPOp ANF.UPKB = emitBP1 UPKB
emitPOp ANF.TAKB = emitBP2 TAKB
emitPOp ANF.DRPB = emitBP2 DRPB
emitPOp ANF.IXOB = emitBP2 IXOB
emitPOp ANF.IDXB = emitBP2 IDXB
emitPOp ANF.SIZB = emitBP1 SIZB
emitPOp ANF.FLTB = emitBP1 FLTB

View File

@ -1503,6 +1503,35 @@ bprim2 !ustk !bstk EQLU i j = do
ustk <- bump ustk
poke ustk $ if universalEq (==) x y then 1 else 0
pure (ustk, bstk)
bprim2 !ustk !bstk IXOT i j = do
x <- peekOffBi bstk i
y <- peekOffBi bstk j
case Util.Text.indexOf x y of
Nothing -> do
ustk <- bump ustk
poke ustk 0
pure (ustk, bstk)
Just i -> do
ustk <- bumpn ustk 2
poke ustk 1
pokeOffN ustk 1 i
pure (ustk, bstk)
bprim2 !ustk !bstk IXOB i j = do
x <- peekOffBi bstk i
y <- peekOffBi bstk j
case By.indexOf x y of
Nothing -> do
ustk <- bump ustk
poke ustk 0
pure (ustk, bstk)
Just i -> do
ustk <- bumpn ustk 2
poke ustk 1
pokeOffN ustk 1 i
pure (ustk, bstk)
bprim2 !ustk !bstk DRPT i j = do
n <- peekOff ustk i
t <- peekOffBi bstk j

View File

@ -458,6 +458,8 @@ instance Tag BPrim2 where
tag2word THRO = 20
tag2word TRCE = 21
tag2word SDBX = 22
tag2word IXOT = 23
tag2word IXOB = 24
word2tag 0 = pure EQLU
word2tag 1 = pure CMPU
@ -482,4 +484,6 @@ instance Tag BPrim2 where
word2tag 20 = pure THRO
word2tag 21 = pure TRCE
word2tag 22 = pure SDBX
word2tag 23 = pure IXOT
word2tag 24 = pure IXOB
word2tag n = unknownTag "BPrim2" n

View File

@ -10,7 +10,10 @@ import Data.String (IsString (..))
import Data.Text qualified as T
import Data.Text.Encoding qualified as T
import Data.Text.Internal qualified as T
import Data.Text.Lazy qualified as TL
import Data.Text.Internal.Lazy.Search qualified as TL
import Data.Text.Unsafe qualified as T (Iter (..), iter)
import Data.Word (Word64)
import Unison.Util.Bytes qualified as B
import Unison.Util.Rope qualified as R
import Prelude hiding (drop, replicate, take)
@ -42,6 +45,9 @@ replicate 1 t = t
replicate n t =
replicate (n `div` 2) t <> replicate (n - (n `div` 2)) t
toLazyText :: Text -> TL.Text
toLazyText (Text t) = TL.fromChunks (chunkToText <$> toList t)
chunkToText :: Chunk -> T.Text
chunkToText (Chunk _ t) = t
@ -116,6 +122,16 @@ toText :: Text -> T.Text
toText (Text t) = T.concat (chunkToText <$> unfoldr R.uncons t)
{-# INLINE toText #-}
indexOf :: Text -> Text -> Maybe Word64
indexOf needle haystack = unsafePerformIO $ do
pure $ case TL.indices needle' haystack' of
[] -> Nothing
(i:_) -> unsafePerformIO $ do
pure $ Just (fromIntegral i)
where
needle' = toLazyText needle
haystack' = toLazyText haystack
-- Drop with both a maximum size and a predicate. Yields actual number of
-- dropped characters.
--

File diff suppressed because it is too large Load Diff

View File

@ -28,14 +28,15 @@ Unison has cryptographic builtins for hashing and computing [HMACs](https://en.w
21. fromBase64UrlUnpadded (Bytes -> Either Text Bytes)
22. fromList ([Nat] -> Bytes)
23. gzip/ (2 terms)
24. size (Bytes -> Nat)
25. take (Nat -> Bytes -> Bytes)
26. toBase16 (Bytes -> Bytes)
27. toBase32 (Bytes -> Bytes)
28. toBase64 (Bytes -> Bytes)
29. toBase64UrlUnpadded (Bytes -> Bytes)
30. toList (Bytes -> [Nat])
31. zlib/ (2 terms)
24. indexOf (Bytes -> Bytes -> Optional Nat)
25. size (Bytes -> Nat)
26. take (Nat -> Bytes -> Bytes)
27. toBase16 (Bytes -> Bytes)
28. toBase32 (Bytes -> Bytes)
29. toBase64 (Bytes -> Bytes)
30. toBase64UrlUnpadded (Bytes -> Bytes)
31. toList (Bytes -> [Nat])
32. zlib/ (2 terms)
```
Notice the `fromBase16` and `toBase16` functions. Here's some convenience functions for converting `Bytes` to and from base-16 `Text`.

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
3. Boolean (builtin type)
4. Boolean/ (1 term)
5. Bytes (builtin type)
6. Bytes/ (33 terms)
6. Bytes/ (34 terms)
7. Char (builtin type)
8. Char/ (22 terms, 1 type)
9. Code (builtin type)
@ -63,7 +63,7 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
52. Socket/ (1 term)
53. Test/ (2 terms, 1 type)
54. Text (builtin type)
55. Text/ (33 terms)
55. Text/ (34 terms)
56. ThreadId/ (1 term)
57. Tuple (type)
58. Tuple/ (1 term)

View File

@ -250,6 +250,30 @@ test> Text.tests.patterns =
isMatch (join [l "abra", many (l "cadabra")]) "abracadabracadabra" == true,
]
test> Text.tests.indexOf =
haystack = "01020304" ++ "05060708" ++ "090a0b0c01"
needle1 = "01"
needle2 = "02"
needle3 = "0304"
needle4 = "05"
needle5 = "0405"
needle6 = "0c"
needle7 = haystack
needle8 = "lopez"
checks [
Text.indexOf needle1 haystack == Some 0,
Text.indexOf needle2 haystack == Some 2,
Text.indexOf needle3 haystack == Some 4,
Text.indexOf needle4 haystack == Some 8,
Text.indexOf needle5 haystack == Some 6,
Text.indexOf needle6 haystack == Some 22,
Text.indexOf needle7 haystack == Some 0,
Text.indexOf needle8 haystack == None,
]
```
```ucm:hide
@ -292,6 +316,28 @@ test> Bytes.tests.fromBase64UrlUnpadded =
(raiseMessage () (Bytes.fromBase64UrlUnpadded (toUtf8 "aGVsbG8gd29ybGQ")))) == Right "hello world"
, isLeft (Bytes.fromBase64UrlUnpadded (toUtf8 "aGVsbG8gd29ybGQ="))]
test> Bytes.tests.indexOf =
haystack = 0xs01020304 ++ 0xs05060708 ++ 0xs090a0b0c01
needle1 = 0xs01
needle2 = 0xs02
needle3 = 0xs0304
needle4 = 0xs05
needle5 = 0xs0405
needle6 = 0xs0c
needle7 = haystack
needle8 = 0xsffffff
checks [
Bytes.indexOf needle1 haystack == Some 0,
Bytes.indexOf needle2 haystack == Some 1,
Bytes.indexOf needle3 haystack == Some 2,
Bytes.indexOf needle4 haystack == Some 4,
Bytes.indexOf needle5 haystack == Some 3,
Bytes.indexOf needle6 haystack == Some 11,
Bytes.indexOf needle7 haystack == Some 0,
Bytes.indexOf needle8 haystack == None,
]
```
```ucm:hide

View File

@ -231,6 +231,30 @@ test> Text.tests.patterns =
isMatch (join [l "abra", many (l "cadabra")]) "abracadabracadabra" == true,
]
test> Text.tests.indexOf =
haystack = "01020304" ++ "05060708" ++ "090a0b0c01"
needle1 = "01"
needle2 = "02"
needle3 = "0304"
needle4 = "05"
needle5 = "0405"
needle6 = "0c"
needle7 = haystack
needle8 = "lopez"
checks [
Text.indexOf needle1 haystack == Some 0,
Text.indexOf needle2 haystack == Some 2,
Text.indexOf needle3 haystack == Some 4,
Text.indexOf needle4 haystack == Some 8,
Text.indexOf needle5 haystack == Some 6,
Text.indexOf needle6 haystack == Some 22,
Text.indexOf needle7 haystack == Some 0,
Text.indexOf needle8 haystack == None,
]
```
## `Bytes` functions
@ -269,6 +293,28 @@ test> Bytes.tests.fromBase64UrlUnpadded =
(raiseMessage () (Bytes.fromBase64UrlUnpadded (toUtf8 "aGVsbG8gd29ybGQ")))) == Right "hello world"
, isLeft (Bytes.fromBase64UrlUnpadded (toUtf8 "aGVsbG8gd29ybGQ="))]
test> Bytes.tests.indexOf =
haystack = 0xs01020304 ++ 0xs05060708 ++ 0xs090a0b0c01
needle1 = 0xs01
needle2 = 0xs02
needle3 = 0xs0304
needle4 = 0xs05
needle5 = 0xs0405
needle6 = 0xs0c
needle7 = haystack
needle8 = 0xsffffff
checks [
Bytes.indexOf needle1 haystack == Some 0,
Bytes.indexOf needle2 haystack == Some 1,
Bytes.indexOf needle3 haystack == Some 2,
Bytes.indexOf needle4 haystack == Some 4,
Bytes.indexOf needle5 haystack == Some 3,
Bytes.indexOf needle6 haystack == Some 11,
Bytes.indexOf needle7 haystack == Some 0,
Bytes.indexOf needle8 haystack == None,
]
```
## `List` comparison
@ -427,6 +473,7 @@ Now that all the tests have been added to the codebase, let's view the test repo
◉ Bytes.tests.at Passed
◉ Bytes.tests.compression Passed
◉ Bytes.tests.fromBase64UrlUnpadded Passed
◉ Bytes.tests.indexOf Passed
◉ Int.tests.arithmetic Passed
◉ Int.tests.bitTwiddling Passed
◉ Int.tests.conversions Passed
@ -438,13 +485,14 @@ Now that all the tests have been added to the codebase, let's view the test repo
◉ Sandbox.test3 Passed
◉ test.rtjqan7bcs Passed
◉ Text.tests.alignment Passed
◉ Text.tests.indexOf Passed
◉ Text.tests.literalsEq Passed
◉ Text.tests.patterns Passed
◉ Text.tests.repeat Passed
◉ Text.tests.takeDropAppend Passed
◉ Universal.murmurHash.tests Passed
✅ 24 test(s) passing
✅ 26 test(s) passing
Tip: Use view Any.test1 to view the source of a test.

View File

@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge`
.foo> ls
1. builtin/ (441 terms, 66 types)
1. builtin/ (443 terms, 66 types)
```
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/ (613 terms, 84 types)
1. builtin/ (615 terms, 84 types)
```
More typically, you'd start out by pulling `base.

View File

@ -115,13 +115,13 @@ it's still in the `history` of the parent namespace and can be resurrected at an
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #nkba2hklaj
⊙ 1. #s596kildj7
- Deletes:
feature1.y
⊙ 2. #5rvucutrqs
⊙ 2. #vp9vp5rlh7
+ Adds / updates:
@ -132,26 +132,26 @@ it's still in the `history` of the parent namespace and can be resurrected at an
Original name New name(s)
feature1.y master.y
⊙ 3. #s37mv81ocj
⊙ 3. #era6pviase
+ Adds / updates:
feature1.y
⊙ 4. #9lpfbm6ug1
⊙ 4. #0n9ahjfc05
> Moves:
Original name New name
x master.x
⊙ 5. #i9jun1cl1a
⊙ 5. #jflvvdjuda
+ Adds / updates:
x
□ 6. #rcu3lukmgn (start of history)
□ 6. #2aphb8rpb3 (start of history)
```
To resurrect an old version of a namespace, you can learn its hash via the `history` command, then use `fork #namespacehash .newname`.

View File

@ -269,7 +269,7 @@ I should be able to move the root into a sub-namespace
.> ls
1. root/ (618 terms, 85 types)
1. root/ (620 terms, 85 types)
.> history
@ -278,13 +278,13 @@ I should be able to move the root into a sub-namespace
□ 1. #59k30lbgtv (start of history)
□ 1. #sdud3m6saf (start of history)
```
```ucm
.> ls .root.at.path
1. builtin/ (613 terms, 84 types)
1. builtin/ (615 terms, 84 types)
2. existing/ (1 term)
3. happy/ (3 terms, 1 type)
4. history/ (1 term)
@ -294,7 +294,7 @@ I should be able to move the root into a sub-namespace
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #3fqubj2dfq
⊙ 1. #1sabm1cldu
- Deletes:
@ -305,7 +305,7 @@ I should be able to move the root into a sub-namespace
Original name New name
existing.a.termInA existing.b.termInA
⊙ 2. #4oifqrjksd
⊙ 2. #mf665m2cgs
+ Adds / updates:
@ -317,26 +317,26 @@ I should be able to move the root into a sub-namespace
happy.b.termInA existing.a.termInA
history.b.termInA existing.a.termInA
⊙ 3. #vmtrlijaub
⊙ 3. #6jq6gq543e
+ Adds / updates:
existing.a.termInA existing.b.termInB
⊙ 4. #qp72kiv6qv
⊙ 4. #0l5029ks65
> Moves:
Original name New name
history.a.termInA history.b.termInA
⊙ 5. #rgcqdg78el
⊙ 5. #oldref9jou
- Deletes:
history.b.termInB
⊙ 6. #3ep162o7o5
⊙ 6. #6u1u2qlr2j
+ Adds / updates:
@ -347,13 +347,13 @@ I should be able to move the root into a sub-namespace
Original name New name(s)
happy.b.termInA history.a.termInA
⊙ 7. #icou0jar0d
⊙ 7. #8ifova0k1j
+ Adds / updates:
history.a.termInA history.b.termInB
⊙ 8. #utbaohifbg
⊙ 8. #hfnilnerra
> Moves:
@ -363,7 +363,7 @@ I should be able to move the root into a sub-namespace
happy.a.T.T2 happy.b.T.T2
happy.a.termInA happy.b.termInA
⊙ 9. #3tgqm3g16k
⊙ 9. #nbhrhmn6og
+ Adds / updates:
@ -373,7 +373,7 @@ I should be able to move the root into a sub-namespace
happy.a.T.T
⊙ 10. #5f0h338k67
⊙ 10. #ib2kl0u3te
+ Adds / updates:
@ -385,7 +385,7 @@ I should be able to move the root into a sub-namespace
⊙ 11. #u0kujjj8n2
⊙ 11. #d15lsl7ioi
```

View File

@ -938,517 +938,525 @@ d = c + 10
-> Int
330. builtin.Nat.increment : Nat
-> Nat
331. builtin.Char.Class.is : Class
331. builtin.Bytes.indexOf : Bytes
-> Bytes
-> Optional
Nat
332. builtin.Text.indexOf : Text
-> Text
-> Optional
Nat
333. builtin.Char.Class.is : Class
-> Char
-> Boolean
332. builtin.io2.MVar.isEmpty : MVar a
334. builtin.io2.MVar.isEmpty : MVar a
->{IO} Boolean
333. builtin.Int.isEven : Int
335. builtin.Int.isEven : Int
-> Boolean
334. builtin.Nat.isEven : Nat
336. builtin.Nat.isEven : Nat
-> Boolean
335. builtin.Pattern.isMatch : Pattern
337. builtin.Pattern.isMatch : Pattern
a
-> a
-> Boolean
336. builtin.Code.isMissing : Term
338. builtin.Code.isMissing : Term
->{IO} Boolean
337. builtin.Int.isOdd : Int
339. builtin.Int.isOdd : Int
-> Boolean
338. builtin.Nat.isOdd : Nat
340. builtin.Nat.isOdd : Nat
-> Boolean
339. builtin.metadata.isPropagated : IsPropagated
340. builtin.metadata.isTest : IsTest
341. builtin.Pattern.join : [Pattern
341. builtin.metadata.isPropagated : IsPropagated
342. builtin.metadata.isTest : IsTest
343. builtin.Pattern.join : [Pattern
a]
-> Pattern
a
342. builtin.io2.IO.process.kill : ProcessHandle
344. builtin.io2.IO.process.kill : ProcessHandle
->{IO} ()
343. builtin.Int.leadingZeros : Int
345. builtin.Int.leadingZeros : Int
-> Nat
344. builtin.Nat.leadingZeros : Nat
346. builtin.Nat.leadingZeros : Nat
-> Nat
345. builtin.Char.Class.letter : Class
346. builtin.Text.patterns.letter : Pattern
347. builtin.Char.Class.letter : Class
348. builtin.Text.patterns.letter : Pattern
Text
347. builtin.Text.patterns.literal : Text
349. builtin.Text.patterns.literal : Text
-> Pattern
Text
348. builtin.Value.load : Value
350. builtin.Value.load : Value
->{IO} Either
[Term]
a
349. builtin.Float.log : Float
351. builtin.Float.log : Float
-> Float
350. builtin.Float.logBase : Float
352. builtin.Float.logBase : Float
-> Float
-> Float
351. builtin.Code.lookup : Term
353. builtin.Code.lookup : Term
->{IO} Optional
Code
352. builtin.Char.Class.lower : Class
353. builtin.Float.lt : Float
354. builtin.Char.Class.lower : Class
355. builtin.Float.lt : Float
-> Float
-> Boolean
354. builtin.Int.lt : Int
356. builtin.Int.lt : Int
-> Int
-> Boolean
355. builtin.Nat.lt : Nat
357. builtin.Nat.lt : Nat
-> Nat
-> Boolean
356. builtin.Text.lt : Text
358. builtin.Text.lt : Text
-> Text
-> Boolean
357. builtin.Float.lteq : Float
359. builtin.Float.lteq : Float
-> Float
-> Boolean
358. builtin.Int.lteq : Int
360. builtin.Int.lteq : Int
-> Int
-> Boolean
359. builtin.Nat.lteq : Nat
361. builtin.Nat.lteq : Nat
-> Nat
-> Boolean
360. builtin.Text.lteq : Text
362. builtin.Text.lteq : Text
-> Text
-> Boolean
361. builtin.Pattern.many : Pattern
363. builtin.Pattern.many : Pattern
a
-> Pattern
a
362. builtin.Char.Class.mark : Class
363. builtin.Float.max : Float
364. builtin.Char.Class.mark : Class
365. builtin.Float.max : Float
-> Float
-> Float
364. builtin.Float.min : Float
366. builtin.Float.min : Float
-> Float
-> Float
365. builtin.Int.mod : Int
367. builtin.Int.mod : Int
-> Int
-> Int
366. builtin.Nat.mod : Nat
368. builtin.Nat.mod : Nat
-> Nat
-> Nat
367. builtin.io2.Clock.internals.monotonic : '{IO} Either
369. builtin.io2.Clock.internals.monotonic : '{IO} Either
Failure
TimeSpec
368. builtin.Universal.murmurHash : a
370. builtin.Universal.murmurHash : a
-> Nat
369. builtin.Int.negate : Int
371. builtin.Int.negate : Int
-> Int
370. builtin.io2.MVar.new : a
372. builtin.io2.MVar.new : a
->{IO} MVar
a
371. builtin.io2.Promise.new : '{IO} Promise
373. builtin.io2.Promise.new : '{IO} Promise
a
372. builtin.io2.TVar.new : a
374. builtin.io2.TVar.new : a
->{STM} TVar
a
373. builtin.io2.MVar.newEmpty : '{IO} MVar
375. builtin.io2.MVar.newEmpty : '{IO} MVar
a
374. builtin.io2.TVar.newIO : a
376. builtin.io2.TVar.newIO : a
->{IO} TVar
a
375. builtin.Boolean.not : Boolean
377. builtin.Boolean.not : Boolean
-> Boolean
376. builtin.Char.Class.not : Class
378. builtin.Char.Class.not : Class
-> Class
377. builtin.Text.patterns.notCharIn : [Char]
379. builtin.Text.patterns.notCharIn : [Char]
-> Pattern
Text
378. builtin.Text.patterns.notCharRange : Char
380. builtin.Text.patterns.notCharRange : Char
-> Char
-> Pattern
Text
379. builtin.io2.Clock.internals.nsec : TimeSpec
381. builtin.io2.Clock.internals.nsec : TimeSpec
-> Nat
380. builtin.Char.Class.number : Class
381. builtin.Char.Class.or : Class
382. builtin.Char.Class.number : Class
383. builtin.Char.Class.or : Class
-> Class
-> Class
382. builtin.Int.or : Int
384. builtin.Int.or : Int
-> Int
-> Int
383. builtin.Nat.or : Nat
385. builtin.Nat.or : Nat
-> Nat
-> Nat
384. builtin.Pattern.or : Pattern
386. builtin.Pattern.or : Pattern
a
-> Pattern
a
-> Pattern
a
385. builtin.Int.popCount : Int
387. builtin.Int.popCount : Int
-> Nat
386. builtin.Nat.popCount : Nat
388. builtin.Nat.popCount : Nat
-> Nat
387. builtin.Float.pow : Float
389. builtin.Float.pow : Float
-> Float
-> Float
388. builtin.Int.pow : Int
390. builtin.Int.pow : Int
-> Nat
-> Int
389. builtin.Nat.pow : Nat
391. builtin.Nat.pow : Nat
-> Nat
-> Nat
390. builtin.Char.Class.printable : Class
391. builtin.io2.Clock.internals.processCPUTime : '{IO} Either
392. builtin.Char.Class.printable : Class
393. builtin.io2.Clock.internals.processCPUTime : '{IO} Either
Failure
TimeSpec
392. builtin.Char.Class.punctuation : Class
393. builtin.Text.patterns.punctuation : Pattern
394. builtin.Char.Class.punctuation : Class
395. builtin.Text.patterns.punctuation : Pattern
Text
394. builtin.Char.Class.range : Char
396. builtin.Char.Class.range : Char
-> Char
-> Class
395. builtin.ImmutableArray.read : ImmutableArray
397. builtin.ImmutableArray.read : ImmutableArray
a
-> Nat
->{Exception} a
396. builtin.MutableArray.read : MutableArray
398. builtin.MutableArray.read : MutableArray
g a
-> Nat
->{g,
Exception} a
397. builtin.io2.Promise.read : Promise
399. builtin.io2.Promise.read : Promise
a
->{IO} a
398. builtin.Ref.read : Ref g a
400. builtin.Ref.read : Ref g a
->{g} a
399. builtin.io2.TVar.read : TVar a
401. builtin.io2.TVar.read : TVar a
->{STM} a
400. builtin.io2.Ref.Ticket.read : Ticket
402. builtin.io2.Ref.Ticket.read : Ticket
a
-> a
401. builtin.ImmutableByteArray.read16be : ImmutableByteArray
403. builtin.ImmutableByteArray.read16be : ImmutableByteArray
-> Nat
->{Exception} Nat
402. builtin.MutableByteArray.read16be : MutableByteArray
404. builtin.MutableByteArray.read16be : MutableByteArray
g
-> Nat
->{g,
Exception} Nat
403. builtin.ImmutableByteArray.read24be : ImmutableByteArray
405. builtin.ImmutableByteArray.read24be : ImmutableByteArray
-> Nat
->{Exception} Nat
404. builtin.MutableByteArray.read24be : MutableByteArray
406. builtin.MutableByteArray.read24be : MutableByteArray
g
-> Nat
->{g,
Exception} Nat
405. builtin.ImmutableByteArray.read32be : ImmutableByteArray
407. builtin.ImmutableByteArray.read32be : ImmutableByteArray
-> Nat
->{Exception} Nat
406. builtin.MutableByteArray.read32be : MutableByteArray
408. builtin.MutableByteArray.read32be : MutableByteArray
g
-> Nat
->{g,
Exception} Nat
407. builtin.ImmutableByteArray.read40be : ImmutableByteArray
409. builtin.ImmutableByteArray.read40be : ImmutableByteArray
-> Nat
->{Exception} Nat
408. builtin.MutableByteArray.read40be : MutableByteArray
410. builtin.MutableByteArray.read40be : MutableByteArray
g
-> Nat
->{g,
Exception} Nat
409. builtin.ImmutableByteArray.read64be : ImmutableByteArray
411. builtin.ImmutableByteArray.read64be : ImmutableByteArray
-> Nat
->{Exception} Nat
410. builtin.MutableByteArray.read64be : MutableByteArray
412. builtin.MutableByteArray.read64be : MutableByteArray
g
-> Nat
->{g,
Exception} Nat
411. builtin.ImmutableByteArray.read8 : ImmutableByteArray
413. builtin.ImmutableByteArray.read8 : ImmutableByteArray
-> Nat
->{Exception} Nat
412. builtin.MutableByteArray.read8 : MutableByteArray
414. builtin.MutableByteArray.read8 : MutableByteArray
g
-> Nat
->{g,
Exception} Nat
413. builtin.io2.Ref.readForCas : Ref
415. builtin.io2.Ref.readForCas : Ref
{IO} a
->{IO} Ticket
a
414. builtin.io2.TVar.readIO : TVar a
416. builtin.io2.TVar.readIO : TVar a
->{IO} a
415. builtin.io2.Clock.internals.realtime : '{IO} Either
417. builtin.io2.Clock.internals.realtime : '{IO} Either
Failure
TimeSpec
416. builtin.io2.IO.ref : a
418. builtin.io2.IO.ref : a
->{IO} Ref
{IO} a
417. builtin.Scope.ref : a
419. builtin.Scope.ref : a
->{Scope
s} Ref
{Scope
s}
a
418. builtin.Text.repeat : Nat
420. builtin.Text.repeat : Nat
-> Text
-> Text
419. builtin.Pattern.replicate : Nat
421. builtin.Pattern.replicate : Nat
-> Nat
-> Pattern
a
-> Pattern
a
420. builtin.io2.STM.retry : '{STM} a
421. builtin.Text.reverse : Text
422. builtin.io2.STM.retry : '{STM} a
423. builtin.Text.reverse : Text
-> Text
422. builtin.Float.round : Float
424. builtin.Float.round : Float
-> Int
423. builtin.Pattern.run : Pattern
425. builtin.Pattern.run : Pattern
a
-> a
-> Optional
( [a],
a)
424. builtin.Scope.run : (∀ s.
426. builtin.Scope.run : (∀ s.
'{g,
Scope s} r)
->{g} r
425. builtin.io2.Clock.internals.sec : TimeSpec
427. builtin.io2.Clock.internals.sec : TimeSpec
-> Int
426. builtin.Char.Class.separator : Class
427. builtin.Code.serialize : Code
428. builtin.Char.Class.separator : Class
429. builtin.Code.serialize : Code
-> Bytes
428. builtin.Value.serialize : Value
430. builtin.Value.serialize : Value
-> Bytes
429. builtin.io2.Tls.ClientConfig.certificates.set : [SignedCert]
431. builtin.io2.Tls.ClientConfig.certificates.set : [SignedCert]
-> ClientConfig
-> ClientConfig
430. builtin.io2.Tls.ServerConfig.certificates.set : [SignedCert]
432. builtin.io2.Tls.ServerConfig.certificates.set : [SignedCert]
-> ServerConfig
-> ServerConfig
431. builtin.io2.TLS.ClientConfig.ciphers.set : [Cipher]
433. builtin.io2.TLS.ClientConfig.ciphers.set : [Cipher]
-> ClientConfig
-> ClientConfig
432. builtin.io2.Tls.ServerConfig.ciphers.set : [Cipher]
434. builtin.io2.Tls.ServerConfig.ciphers.set : [Cipher]
-> ServerConfig
-> ServerConfig
433. builtin.io2.Tls.ClientConfig.versions.set : [Version]
435. builtin.io2.Tls.ClientConfig.versions.set : [Version]
-> ClientConfig
-> ClientConfig
434. builtin.io2.Tls.ServerConfig.versions.set : [Version]
436. builtin.io2.Tls.ServerConfig.versions.set : [Version]
-> ServerConfig
-> ServerConfig
435. builtin.Int.shiftLeft : Int
437. builtin.Int.shiftLeft : Int
-> Nat
-> Int
436. builtin.Nat.shiftLeft : Nat
438. builtin.Nat.shiftLeft : Nat
-> Nat
-> Nat
437. builtin.Int.shiftRight : Int
439. builtin.Int.shiftRight : Int
-> Nat
-> Int
438. builtin.Nat.shiftRight : Nat
440. builtin.Nat.shiftRight : Nat
-> Nat
-> Nat
439. builtin.Int.signum : Int
441. builtin.Int.signum : Int
-> Int
440. builtin.Float.sin : Float
442. builtin.Float.sin : Float
-> Float
441. builtin.Float.sinh : Float
443. builtin.Float.sinh : Float
-> Float
442. builtin.Bytes.size : Bytes
444. builtin.Bytes.size : Bytes
-> Nat
443. builtin.ImmutableArray.size : ImmutableArray
445. builtin.ImmutableArray.size : ImmutableArray
a
-> Nat
444. builtin.ImmutableByteArray.size : ImmutableByteArray
446. builtin.ImmutableByteArray.size : ImmutableByteArray
-> Nat
445. builtin.List.size : [a]
447. builtin.List.size : [a]
-> Nat
446. builtin.MutableArray.size : MutableArray
448. builtin.MutableArray.size : MutableArray
g a
-> Nat
447. builtin.MutableByteArray.size : MutableByteArray
449. builtin.MutableByteArray.size : MutableByteArray
g
-> Nat
448. builtin.Text.size : Text
450. builtin.Text.size : Text
-> Nat
449. builtin.Text.patterns.space : Pattern
451. builtin.Text.patterns.space : Pattern
Text
450. builtin.Float.sqrt : Float
452. builtin.Float.sqrt : Float
-> Float
451. builtin.io2.IO.process.start : Text
453. builtin.io2.IO.process.start : Text
-> [Text]
->{IO} ( Handle,
Handle,
Handle,
ProcessHandle)
452. builtin.io2.IO.stdHandle : StdHandle
454. builtin.io2.IO.stdHandle : StdHandle
-> Handle
453. builtin.Nat.sub : Nat
455. builtin.Nat.sub : Nat
-> Nat
-> Int
454. builtin.io2.TVar.swap : TVar a
456. builtin.io2.TVar.swap : TVar a
-> a
->{STM} a
455. builtin.Char.Class.symbol : Class
456. builtin.io2.IO.systemTimeMicroseconds : '{IO} Int
457. builtin.Bytes.take : Nat
457. builtin.Char.Class.symbol : Class
458. builtin.io2.IO.systemTimeMicroseconds : '{IO} Int
459. builtin.Bytes.take : Nat
-> Bytes
-> Bytes
458. builtin.List.take : Nat
460. builtin.List.take : Nat
-> [a]
-> [a]
459. builtin.Text.take : Nat
461. builtin.Text.take : Nat
-> Text
-> Text
460. builtin.Float.tan : Float
462. builtin.Float.tan : Float
-> Float
461. builtin.Float.tanh : Float
463. builtin.Float.tanh : Float
-> Float
462. builtin.io2.Clock.internals.threadCPUTime : '{IO} Either
464. builtin.io2.Clock.internals.threadCPUTime : '{IO} Either
Failure
TimeSpec
463. builtin.Bytes.toBase16 : Bytes
465. builtin.Bytes.toBase16 : Bytes
-> Bytes
464. builtin.Bytes.toBase32 : Bytes
466. builtin.Bytes.toBase32 : Bytes
-> Bytes
465. builtin.Bytes.toBase64 : Bytes
467. builtin.Bytes.toBase64 : Bytes
-> Bytes
466. builtin.Bytes.toBase64UrlUnpadded : Bytes
468. builtin.Bytes.toBase64UrlUnpadded : Bytes
-> Bytes
467. builtin.Text.toCharList : Text
469. builtin.Text.toCharList : Text
-> [Char]
468. builtin.Int.toFloat : Int
470. builtin.Int.toFloat : Int
-> Float
469. builtin.Nat.toFloat : Nat
471. builtin.Nat.toFloat : Nat
-> Float
470. builtin.Nat.toInt : Nat
472. builtin.Nat.toInt : Nat
-> Int
471. builtin.Bytes.toList : Bytes
473. builtin.Bytes.toList : Bytes
-> [Nat]
472. builtin.Text.toLowercase : Text
474. builtin.Text.toLowercase : Text
-> Text
473. builtin.Char.toNat : Char
475. builtin.Char.toNat : Char
-> Nat
474. builtin.Float.toRepresentation : Float
476. builtin.Float.toRepresentation : Float
-> Nat
475. builtin.Int.toRepresentation : Int
477. builtin.Int.toRepresentation : Int
-> Nat
476. builtin.Char.toText : Char
478. builtin.Char.toText : Char
-> Text
477. builtin.Debug.toText : a
479. builtin.Debug.toText : a
-> Optional
(Either
Text
Text)
478. builtin.Float.toText : Float
480. builtin.Float.toText : Float
-> Text
479. builtin.Handle.toText : Handle
481. builtin.Handle.toText : Handle
-> Text
480. builtin.Int.toText : Int
482. builtin.Int.toText : Int
-> Text
481. builtin.Nat.toText : Nat
483. builtin.Nat.toText : Nat
-> Text
482. builtin.Socket.toText : Socket
484. builtin.Socket.toText : Socket
-> Text
483. builtin.Link.Term.toText : Term
485. builtin.Link.Term.toText : Term
-> Text
484. builtin.ThreadId.toText : ThreadId
486. builtin.ThreadId.toText : ThreadId
-> Text
485. builtin.Text.toUppercase : Text
487. builtin.Text.toUppercase : Text
-> Text
486. builtin.Text.toUtf8 : Text
488. builtin.Text.toUtf8 : Text
-> Bytes
487. builtin.todo : a -> b
488. builtin.Debug.trace : Text
489. builtin.todo : a -> b
490. builtin.Debug.trace : Text
-> a
-> ()
489. builtin.Int.trailingZeros : Int
491. builtin.Int.trailingZeros : Int
-> Nat
490. builtin.Nat.trailingZeros : Nat
492. builtin.Nat.trailingZeros : Nat
-> Nat
491. builtin.Float.truncate : Float
493. builtin.Float.truncate : Float
-> Int
492. builtin.Int.truncate0 : Int
494. builtin.Int.truncate0 : Int
-> Nat
493. builtin.io2.IO.tryEval : '{IO} a
495. builtin.io2.IO.tryEval : '{IO} a
->{IO,
Exception} a
494. builtin.io2.Promise.tryRead : Promise
496. builtin.io2.Promise.tryRead : Promise
a
->{IO} Optional
a
495. builtin.io2.MVar.tryTake : MVar a
497. builtin.io2.MVar.tryTake : MVar a
->{IO} Optional
a
496. builtin.Text.uncons : Text
498. builtin.Text.uncons : Text
-> Optional
( Char,
Text)
497. builtin.Any.unsafeExtract : Any
499. builtin.Any.unsafeExtract : Any
-> a
498. builtin.Text.unsnoc : Text
500. builtin.Text.unsnoc : Text
-> Optional
( Text,
Char)
499. builtin.Char.Class.upper : Class
500. builtin.Code.validate : [( Term,
501. builtin.Char.Class.upper : Class
502. builtin.Code.validate : [( Term,
Code)]
->{IO} Optional
Failure
501. builtin.io2.validateSandboxed : [Term]
503. builtin.io2.validateSandboxed : [Term]
-> a
-> Boolean
502. builtin.Value.value : a
504. builtin.Value.value : a
-> Value
503. builtin.io2.IO.process.wait : ProcessHandle
505. builtin.io2.IO.process.wait : ProcessHandle
->{IO} Nat
504. builtin.Debug.watch : Text
506. builtin.Debug.watch : Text
-> a
-> a
505. builtin.Char.Class.whitespace : Class
506. builtin.MutableArray.write : MutableArray
507. builtin.Char.Class.whitespace : Class
508. builtin.MutableArray.write : MutableArray
g a
-> Nat
-> a
->{g,
Exception} ()
507. builtin.io2.Promise.write : Promise
509. builtin.io2.Promise.write : Promise
a
-> a
->{IO} Boolean
508. builtin.Ref.write : Ref g a
510. builtin.Ref.write : Ref g a
-> a
->{g} ()
509. builtin.io2.TVar.write : TVar a
511. builtin.io2.TVar.write : TVar a
-> a
->{STM} ()
510. builtin.MutableByteArray.write16be : MutableByteArray
512. builtin.MutableByteArray.write16be : MutableByteArray
g
-> Nat
-> Nat
->{g,
Exception} ()
511. builtin.MutableByteArray.write32be : MutableByteArray
513. builtin.MutableByteArray.write32be : MutableByteArray
g
-> Nat
-> Nat
->{g,
Exception} ()
512. builtin.MutableByteArray.write64be : MutableByteArray
514. builtin.MutableByteArray.write64be : MutableByteArray
g
-> Nat
-> Nat
->{g,
Exception} ()
513. builtin.MutableByteArray.write8 : MutableByteArray
515. builtin.MutableByteArray.write8 : MutableByteArray
g
-> Nat
-> Nat
->{g,
Exception} ()
514. builtin.Int.xor : Int
516. builtin.Int.xor : Int
-> Int
-> Int
515. builtin.Nat.xor : Nat
517. builtin.Nat.xor : Nat
-> Nat
-> Nat

View File

@ -59,17 +59,17 @@ y = 2
most recent, along with the command that got us there. Try:
`fork 2 .old`
`fork #upgj8h6ju3 .old` to make an old namespace
`fork #1os27e1d65 .old` to make an old namespace
accessible again,
`reset-root #upgj8h6ju3` to reset the root namespace and
`reset-root #1os27e1d65` to reset the root namespace and
its history to that of the
specified namespace.
When Root Hash Action
1. now #58jmfch7o7 add
2. now #upgj8h6ju3 add
3. now #acegso70di builtins.merge
1. now #la0gb79l5t add
2. now #1os27e1d65 add
3. now #qc3b485dku builtins.merge
4. #sg60bvjo91 history starts here
Tip: Use `diff.namespace 1 7` to compare namespaces between

View File

@ -13,7 +13,7 @@ Let's look at some examples. We'll start with a namespace with just the builtins
□ 1. #l6nvab7prj (start of history)
□ 1. #dpen6o8u9a (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. #la42o8m5tq
⊙ 1. #4fri0ae2n9
> Moves:
Original name New name
Nat.frobnicate Nat.+
⊙ 2. #fqkpt5ogt2
⊙ 2. #bdu9sp9eov
> Moves:
Original name New name
Nat.+ Nat.frobnicate
□ 3. #l6nvab7prj (start of history)
□ 3. #dpen6o8u9a (start of history)
```
If we merge that back into `builtin`, we get that same chain of history:
@ -73,21 +73,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. #la42o8m5tq
⊙ 1. #4fri0ae2n9
> Moves:
Original name New name
Nat.frobnicate Nat.+
⊙ 2. #fqkpt5ogt2
⊙ 2. #bdu9sp9eov
> Moves:
Original name New name
Nat.+ Nat.frobnicate
□ 3. #l6nvab7prj (start of history)
□ 3. #dpen6o8u9a (start of history)
```
Let's try again, but using a `merge.squash` (or just `squash`) instead. The history will be unchanged:
@ -108,7 +108,7 @@ Let's try again, but using a `merge.squash` (or just `squash`) instead. The hist
□ 1. #l6nvab7prj (start of history)
□ 1. #dpen6o8u9a (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.
@ -499,13 +499,13 @@ This checks to see that squashing correctly preserves deletions:
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #ae3oc8cikb
⊙ 1. #b7cgpsmc1j
- Deletes:
Nat.* Nat.+
□ 2. #l6nvab7prj (start of history)
□ 2. #dpen6o8u9a (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.