diff --git a/parser-typechecker/package.yaml b/parser-typechecker/package.yaml index 1df6fe124..f6b3a34bf 100644 --- a/parser-typechecker/package.yaml +++ b/parser-typechecker/package.yaml @@ -44,6 +44,7 @@ library: - configurator - cryptonite - data-default + - deepseq - directory - either - fuzzyfind @@ -108,6 +109,7 @@ library: - x509 - x509-store - x509-system + - zlib - unison-codebase - unison-codebase-sqlite - unison-codebase-sync diff --git a/parser-typechecker/src/Unison/Builtin.hs b/parser-typechecker/src/Unison/Builtin.hs index 28b69aa3b..de51a29d5 100644 --- a/parser-typechecker/src/Unison/Builtin.hs +++ b/parser-typechecker/src/Unison/Builtin.hs @@ -428,6 +428,11 @@ builtinsSrc = , B "Bytes.size" $ bytes --> nat , B "Bytes.flatten" $ bytes --> bytes + , B "Bytes.zlib.compress" $ bytes --> bytes + , B "Bytes.zlib.decompress" $ bytes --> eithert text bytes + , B "Bytes.gzip.compress" $ bytes --> bytes + , B "Bytes.gzip.decompress" $ bytes --> eithert text bytes + {- These are all `Bytes -> Bytes`, rather than `Bytes -> Text`. This is intentional: it avoids a round trip to `Text` if all you are doing with the bytes is dumping them to a file or a diff --git a/parser-typechecker/src/Unison/Runtime/Builtin.hs b/parser-typechecker/src/Unison/Runtime/Builtin.hs index d3756f1a4..1c9df33ba 100644 --- a/parser-typechecker/src/Unison/Runtime/Builtin.hs +++ b/parser-typechecker/src/Unison/Runtime/Builtin.hs @@ -18,6 +18,9 @@ module Unison.Runtime.Builtin ) where import Control.Monad.State.Strict (State, modify, execState) +import qualified Control.Exception.Safe as Exception +import Control.Monad.Catch (MonadCatch) +import Control.DeepSeq (NFData) import Unison.ABT.Normalized hiding (TTm) import Unison.Reference @@ -1786,6 +1789,21 @@ declareForeigns = do in pure . Bytes.fromArray . hmac alg $ serializeValueLazy x + let + catchAll :: (MonadCatch m, MonadIO m, NFData a) => m a -> m (Either Text a) + catchAll e = do + e <- Exception.tryAnyDeep e + pure $ case e of + Left se -> Left (Text.pack (show se)) + Right a -> Right a + + declareForeign "Bytes.zlib.compress" boxDirect . mkForeign $ pure . Bytes.zlibCompress + declareForeign "Bytes.gzip.compress" boxDirect . mkForeign $ pure . Bytes.gzipCompress + declareForeign "Bytes.zlib.decompress" boxToEBoxBox . mkForeign $ \bs -> + catchAll (pure (Bytes.zlibDecompress bs)) + declareForeign "Bytes.gzip.decompress" boxToEBoxBox . mkForeign $ \bs -> + catchAll (pure (Bytes.gzipDecompress bs)) + declareForeign "Bytes.toBase16" boxDirect . mkForeign $ pure . Bytes.toBase16 declareForeign "Bytes.toBase32" boxDirect . mkForeign $ pure . Bytes.toBase32 declareForeign "Bytes.toBase64" boxDirect . mkForeign $ pure . Bytes.toBase64 diff --git a/parser-typechecker/src/Unison/Util/Bytes.hs b/parser-typechecker/src/Unison/Util/Bytes.hs index 580c5586e..c4c5a2a21 100644 --- a/parser-typechecker/src/Unison/Util/Bytes.hs +++ b/parser-typechecker/src/Unison/Util/Bytes.hs @@ -3,6 +3,7 @@ module Unison.Util.Bytes where +import Control.DeepSeq (NFData(..)) import Data.Bits (shiftR, shiftL, (.|.)) import Data.Char import Data.Memory.PtrMethods (memCompare, memEqual) @@ -17,6 +18,8 @@ import qualified Data.ByteArray as B import qualified Data.ByteArray.Encoding as BE import qualified Data.FingerTree as T import qualified Data.Text as Text +import qualified Codec.Compression.Zlib as Zlib +import qualified Codec.Compression.GZip as GZip -- Block is just `newtype Block a = Block ByteArray#` type ByteString = Block Word8 @@ -35,12 +38,27 @@ empty = Bytes mempty fromArray :: B.ByteArrayAccess ba => ba -> Bytes fromArray = snoc empty +zlibCompress :: Bytes -> Bytes +zlibCompress = fromLazyByteString . Zlib.compress . toLazyByteString + +gzipCompress :: Bytes -> Bytes +gzipCompress = fromLazyByteString . GZip.compress . toLazyByteString + +gzipDecompress :: Bytes -> Bytes +gzipDecompress = fromLazyByteString . GZip.decompress . toLazyByteString + +zlibDecompress :: Bytes -> Bytes +zlibDecompress = fromLazyByteString . Zlib.decompress . toLazyByteString + toArray :: forall bo . B.ByteArray bo => Bytes -> bo toArray b = B.concat (map B.convert (chunks b) :: [bo]) toLazyByteString :: Bytes -> LB.ByteString toLazyByteString b = LB.fromChunks $ map B.convert $ chunks b +fromLazyByteString :: LB.ByteString -> Bytes +fromLazyByteString b = fromChunks (map (view . B.convert) $ LB.toChunks b) + size :: Bytes -> Int size (Bytes bs) = getSum (T.measure bs) @@ -212,7 +230,7 @@ fillBE :: Word64 -> Int -> Ptr Word8 -> IO () fillBE n 0 p = poke p (fromIntegral n) >> return () fillBE n i p = poke p (fromIntegral (shiftR n (i * 8))) >> fillBE n (i - 1) (p `plusPtr` 1) - + encodeNat64be :: Word64 -> Bytes encodeNat64be n = Bytes (T.singleton (view (B.unsafeCreate 8 (fillBE n 7)))) @@ -361,3 +379,9 @@ instance B.ByteArrayAccess bytes => B.ByteArrayAccess (View bytes) where length = viewSize withByteArray v f = B.withByteArray (unView v) $ \ptr -> f (ptr `plusPtr` (viewOffset v)) + +instance NFData (View bs) where + rnf bs = seq bs () + +instance NFData Bytes where + rnf bs = rnf (chunks bs) diff --git a/parser-typechecker/unison-parser-typechecker.cabal b/parser-typechecker/unison-parser-typechecker.cabal index 2b14bbb8e..3beb2ace6 100644 --- a/parser-typechecker/unison-parser-typechecker.cabal +++ b/parser-typechecker/unison-parser-typechecker.cabal @@ -193,6 +193,7 @@ library , cryptonite , data-default , data-memocombinators + , deepseq , directory , either , errors @@ -260,6 +261,7 @@ library , x509 , x509-store , x509-system + , zlib if flag(optimized) ghc-options: -funbox-strict-fields -O2 default-language: Haskell2010 diff --git a/unison-src/transcripts-using-base/hashing.output.md b/unison-src/transcripts-using-base/hashing.output.md index 2f8c32247..a79fe660c 100644 --- a/unison-src/transcripts-using-base/hashing.output.md +++ b/unison-src/transcripts-using-base/hashing.output.md @@ -27,13 +27,15 @@ Unison has cryptographic builtins for hashing and computing [HMACs](https://en.w 20. fromBase64 (Bytes -> Either Text Bytes) 21. fromBase64UrlUnpadded (Bytes -> Either Text Bytes) 22. fromList ([Nat] -> Bytes) - 23. size (Bytes -> Nat) - 24. take (Nat -> Bytes -> Bytes) - 25. toBase16 (Bytes -> Bytes) - 26. toBase32 (Bytes -> Bytes) - 27. toBase64 (Bytes -> Bytes) - 28. toBase64UrlUnpadded (Bytes -> Bytes) - 29. toList (Bytes -> [Nat]) + 23. gzip/ (2 definitions) + 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 definitions) ``` Notice the `fromBase16` and `toBase16` functions. Here's some convenience functions for converting `Bytes` to and from base-16 `Text`. diff --git a/unison-src/transcripts/alias-many.output.md b/unison-src/transcripts/alias-many.output.md index bac466280..c4c76a977 100644 --- a/unison-src/transcripts/alias-many.output.md +++ b/unison-src/transcripts/alias-many.output.md @@ -46,404 +46,408 @@ Let's try it! 26. Bytes.fromBase64 : Bytes -> Either Text Bytes 27. Bytes.fromBase64UrlUnpadded : Bytes -> Either Text Bytes 28. Bytes.fromList : [Nat] -> Bytes - 29. Bytes.size : Bytes -> Nat - 30. Bytes.take : Nat -> Bytes -> Bytes - 31. Bytes.toBase16 : Bytes -> Bytes - 32. Bytes.toBase32 : Bytes -> Bytes - 33. Bytes.toBase64 : Bytes -> Bytes - 34. Bytes.toBase64UrlUnpadded : Bytes -> Bytes - 35. Bytes.toList : Bytes -> [Nat] - 36. builtin type Char - 37. Char.fromNat : Nat -> Char - 38. Char.toNat : Char -> Nat - 39. Char.toText : Char -> Text - 40. builtin type Code - 41. Code.cache_ : [(Term, Code)] ->{IO} [Term] - 42. Code.dependencies : Code -> [Term] - 43. Code.deserialize : Bytes -> Either Text Code - 44. Code.isMissing : Term ->{IO} Boolean - 45. Code.lookup : Term ->{IO} Optional Code - 46. Code.serialize : Code -> Bytes - 47. crypto.hash : HashAlgorithm -> a -> Bytes - 48. builtin type crypto.HashAlgorithm - 49. crypto.HashAlgorithm.Blake2b_256 : HashAlgorithm - 50. crypto.HashAlgorithm.Blake2b_512 : HashAlgorithm - 51. crypto.HashAlgorithm.Blake2s_256 : HashAlgorithm - 52. crypto.HashAlgorithm.Sha2_256 : HashAlgorithm - 53. crypto.HashAlgorithm.Sha2_512 : HashAlgorithm - 54. crypto.HashAlgorithm.Sha3_256 : HashAlgorithm - 55. crypto.HashAlgorithm.Sha3_512 : HashAlgorithm - 56. crypto.hashBytes : HashAlgorithm -> Bytes -> Bytes - 57. crypto.hmac : HashAlgorithm -> Bytes -> a -> Bytes - 58. crypto.hmacBytes : HashAlgorithm + 29. Bytes.gzip.compress : Bytes -> Bytes + 30. Bytes.gzip.decompress : Bytes -> Either Text Bytes + 31. Bytes.size : Bytes -> Nat + 32. Bytes.take : Nat -> Bytes -> Bytes + 33. Bytes.toBase16 : Bytes -> Bytes + 34. Bytes.toBase32 : Bytes -> Bytes + 35. Bytes.toBase64 : Bytes -> Bytes + 36. Bytes.toBase64UrlUnpadded : Bytes -> Bytes + 37. Bytes.toList : Bytes -> [Nat] + 38. Bytes.zlib.compress : Bytes -> Bytes + 39. Bytes.zlib.decompress : Bytes -> Either Text Bytes + 40. builtin type Char + 41. Char.fromNat : Nat -> Char + 42. Char.toNat : Char -> Nat + 43. Char.toText : Char -> Text + 44. builtin type Code + 45. Code.cache_ : [(Term, Code)] ->{IO} [Term] + 46. Code.dependencies : Code -> [Term] + 47. Code.deserialize : Bytes -> Either Text Code + 48. Code.isMissing : Term ->{IO} Boolean + 49. Code.lookup : Term ->{IO} Optional Code + 50. Code.serialize : Code -> Bytes + 51. crypto.hash : HashAlgorithm -> a -> Bytes + 52. builtin type crypto.HashAlgorithm + 53. crypto.HashAlgorithm.Blake2b_256 : HashAlgorithm + 54. crypto.HashAlgorithm.Blake2b_512 : HashAlgorithm + 55. crypto.HashAlgorithm.Blake2s_256 : HashAlgorithm + 56. crypto.HashAlgorithm.Sha2_256 : HashAlgorithm + 57. crypto.HashAlgorithm.Sha2_512 : HashAlgorithm + 58. crypto.HashAlgorithm.Sha3_256 : HashAlgorithm + 59. crypto.HashAlgorithm.Sha3_512 : HashAlgorithm + 60. crypto.hashBytes : HashAlgorithm -> Bytes -> Bytes + 61. crypto.hmac : HashAlgorithm -> Bytes -> a -> Bytes + 62. crypto.hmacBytes : HashAlgorithm -> Bytes -> Bytes -> Bytes - 59. Debug.watch : Text -> a -> a - 60. unique type Doc - 61. Doc.Blob : Text -> Doc - 62. Doc.Evaluate : Term -> Doc - 63. Doc.Join : [Doc] -> Doc - 64. Doc.Link : Link -> Doc - 65. Doc.Signature : Term -> Doc - 66. Doc.Source : Link -> Doc - 67. type Either a b - 68. Either.Left : a -> Either a b - 69. Either.Right : b -> Either a b - 70. ability Exception - 71. Exception.raise : Failure ->{Exception} x - 72. builtin type Float - 73. Float.* : Float -> Float -> Float - 74. Float.+ : Float -> Float -> Float - 75. Float.- : Float -> Float -> Float - 76. Float./ : Float -> Float -> Float - 77. Float.abs : Float -> Float - 78. Float.acos : Float -> Float - 79. Float.acosh : Float -> Float - 80. Float.asin : Float -> Float - 81. Float.asinh : Float -> Float - 82. Float.atan : Float -> Float - 83. Float.atan2 : Float -> Float -> Float - 84. Float.atanh : Float -> Float - 85. Float.ceiling : Float -> Int - 86. Float.cos : Float -> Float - 87. Float.cosh : Float -> Float - 88. Float.eq : Float -> Float -> Boolean - 89. Float.exp : Float -> Float - 90. Float.floor : Float -> Int - 91. Float.fromText : Text -> Optional Float - 92. Float.gt : Float -> Float -> Boolean - 93. Float.gteq : Float -> Float -> Boolean - 94. Float.log : Float -> Float - 95. Float.logBase : Float -> Float -> Float - 96. Float.lt : Float -> Float -> Boolean - 97. Float.lteq : Float -> Float -> Boolean - 98. Float.max : Float -> Float -> Float - 99. Float.min : Float -> Float -> Float - 100. Float.pow : Float -> Float -> Float - 101. Float.round : Float -> Int - 102. Float.sin : Float -> Float - 103. Float.sinh : Float -> Float - 104. Float.sqrt : Float -> Float - 105. Float.tan : Float -> Float - 106. Float.tanh : Float -> Float - 107. Float.toText : Float -> Text - 108. Float.truncate : Float -> Int - 109. builtin type Int - 110. Int.* : Int -> Int -> Int - 111. Int.+ : Int -> Int -> Int - 112. Int.- : Int -> Int -> Int - 113. Int./ : Int -> Int -> Int - 114. Int.and : Int -> Int -> Int - 115. Int.complement : Int -> Int - 116. Int.eq : Int -> Int -> Boolean - 117. Int.fromText : Text -> Optional Int - 118. Int.gt : Int -> Int -> Boolean - 119. Int.gteq : Int -> Int -> Boolean - 120. Int.increment : Int -> Int - 121. Int.isEven : Int -> Boolean - 122. Int.isOdd : Int -> Boolean - 123. Int.leadingZeros : Int -> Nat - 124. Int.lt : Int -> Int -> Boolean - 125. Int.lteq : Int -> Int -> Boolean - 126. Int.mod : Int -> Int -> Int - 127. Int.negate : Int -> Int - 128. Int.or : Int -> Int -> Int - 129. Int.popCount : Int -> Nat - 130. Int.pow : Int -> Nat -> Int - 131. Int.shiftLeft : Int -> Nat -> Int - 132. Int.shiftRight : Int -> Nat -> Int - 133. Int.signum : Int -> Int - 134. Int.toFloat : Int -> Float - 135. Int.toText : Int -> Text - 136. Int.trailingZeros : Int -> Nat - 137. Int.truncate0 : Int -> Nat - 138. Int.xor : Int -> Int -> Int - 139. unique type io2.BufferMode - 140. io2.BufferMode.BlockBuffering : BufferMode - 141. io2.BufferMode.LineBuffering : BufferMode - 142. io2.BufferMode.NoBuffering : BufferMode - 143. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode - 144. unique type io2.Failure - 145. io2.Failure.Failure : Type -> Text -> Any -> Failure - 146. unique type io2.FileMode - 147. io2.FileMode.Append : FileMode - 148. io2.FileMode.Read : FileMode - 149. io2.FileMode.ReadWrite : FileMode - 150. io2.FileMode.Write : FileMode - 151. builtin type io2.Handle - 152. builtin type io2.IO - 153. io2.IO.clientSocket.impl : Text + 63. Debug.watch : Text -> a -> a + 64. unique type Doc + 65. Doc.Blob : Text -> Doc + 66. Doc.Evaluate : Term -> Doc + 67. Doc.Join : [Doc] -> Doc + 68. Doc.Link : Link -> Doc + 69. Doc.Signature : Term -> Doc + 70. Doc.Source : Link -> Doc + 71. type Either a b + 72. Either.Left : a -> Either a b + 73. Either.Right : b -> Either a b + 74. ability Exception + 75. Exception.raise : Failure ->{Exception} x + 76. builtin type Float + 77. Float.* : Float -> Float -> Float + 78. Float.+ : Float -> Float -> Float + 79. Float.- : Float -> Float -> Float + 80. Float./ : Float -> Float -> Float + 81. Float.abs : Float -> Float + 82. Float.acos : Float -> Float + 83. Float.acosh : Float -> Float + 84. Float.asin : Float -> Float + 85. Float.asinh : Float -> Float + 86. Float.atan : Float -> Float + 87. Float.atan2 : Float -> Float -> Float + 88. Float.atanh : Float -> Float + 89. Float.ceiling : Float -> Int + 90. Float.cos : Float -> Float + 91. Float.cosh : Float -> Float + 92. Float.eq : Float -> Float -> Boolean + 93. Float.exp : Float -> Float + 94. Float.floor : Float -> Int + 95. Float.fromText : Text -> Optional Float + 96. Float.gt : Float -> Float -> Boolean + 97. Float.gteq : Float -> Float -> Boolean + 98. Float.log : Float -> Float + 99. Float.logBase : Float -> Float -> Float + 100. Float.lt : Float -> Float -> Boolean + 101. Float.lteq : Float -> Float -> Boolean + 102. Float.max : Float -> Float -> Float + 103. Float.min : Float -> Float -> Float + 104. Float.pow : Float -> Float -> Float + 105. Float.round : Float -> Int + 106. Float.sin : Float -> Float + 107. Float.sinh : Float -> Float + 108. Float.sqrt : Float -> Float + 109. Float.tan : Float -> Float + 110. Float.tanh : Float -> Float + 111. Float.toText : Float -> Text + 112. Float.truncate : Float -> Int + 113. builtin type Int + 114. Int.* : Int -> Int -> Int + 115. Int.+ : Int -> Int -> Int + 116. Int.- : Int -> Int -> Int + 117. Int./ : Int -> Int -> Int + 118. Int.and : Int -> Int -> Int + 119. Int.complement : Int -> Int + 120. Int.eq : Int -> Int -> Boolean + 121. Int.fromText : Text -> Optional Int + 122. Int.gt : Int -> Int -> Boolean + 123. Int.gteq : Int -> Int -> Boolean + 124. Int.increment : Int -> Int + 125. Int.isEven : Int -> Boolean + 126. Int.isOdd : Int -> Boolean + 127. Int.leadingZeros : Int -> Nat + 128. Int.lt : Int -> Int -> Boolean + 129. Int.lteq : Int -> Int -> Boolean + 130. Int.mod : Int -> Int -> Int + 131. Int.negate : Int -> Int + 132. Int.or : Int -> Int -> Int + 133. Int.popCount : Int -> Nat + 134. Int.pow : Int -> Nat -> Int + 135. Int.shiftLeft : Int -> Nat -> Int + 136. Int.shiftRight : Int -> Nat -> Int + 137. Int.signum : Int -> Int + 138. Int.toFloat : Int -> Float + 139. Int.toText : Int -> Text + 140. Int.trailingZeros : Int -> Nat + 141. Int.truncate0 : Int -> Nat + 142. Int.xor : Int -> Int -> Int + 143. unique type io2.BufferMode + 144. io2.BufferMode.BlockBuffering : BufferMode + 145. io2.BufferMode.LineBuffering : BufferMode + 146. io2.BufferMode.NoBuffering : BufferMode + 147. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode + 148. unique type io2.Failure + 149. io2.Failure.Failure : Type -> Text -> Any -> Failure + 150. unique type io2.FileMode + 151. io2.FileMode.Append : FileMode + 152. io2.FileMode.Read : FileMode + 153. io2.FileMode.ReadWrite : FileMode + 154. io2.FileMode.Write : FileMode + 155. builtin type io2.Handle + 156. builtin type io2.IO + 157. io2.IO.clientSocket.impl : Text -> Text ->{IO} Either Failure Socket - 154. io2.IO.closeFile.impl : Handle ->{IO} Either Failure () - 155. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure () - 156. io2.IO.createDirectory.impl : Text + 158. io2.IO.closeFile.impl : Handle ->{IO} Either Failure () + 159. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure () + 160. io2.IO.createDirectory.impl : Text ->{IO} Either Failure () - 157. io2.IO.createTempDirectory.impl : Text + 161. io2.IO.createTempDirectory.impl : Text ->{IO} Either Failure Text - 158. io2.IO.delay.impl : Nat ->{IO} Either Failure () - 159. io2.IO.directoryContents.impl : Text + 162. io2.IO.delay.impl : Nat ->{IO} Either Failure () + 163. io2.IO.directoryContents.impl : Text ->{IO} Either Failure [Text] - 160. io2.IO.fileExists.impl : Text + 164. io2.IO.fileExists.impl : Text ->{IO} Either Failure Boolean - 161. io2.IO.forkComp : '{IO} a ->{IO} ThreadId - 162. io2.IO.getBuffering.impl : Handle + 165. io2.IO.forkComp : '{IO} a ->{IO} ThreadId + 166. io2.IO.getBuffering.impl : Handle ->{IO} Either Failure BufferMode - 163. io2.IO.getBytes.impl : Handle + 167. io2.IO.getBytes.impl : Handle -> Nat ->{IO} Either Failure Bytes - 164. io2.IO.getCurrentDirectory.impl : '{IO} Either + 168. io2.IO.getCurrentDirectory.impl : '{IO} Either Failure Text - 165. io2.IO.getEnv.impl : Text ->{IO} Either Failure Text - 166. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat - 167. io2.IO.getFileTimestamp.impl : Text + 169. io2.IO.getEnv.impl : Text ->{IO} Either Failure Text + 170. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat + 171. io2.IO.getFileTimestamp.impl : Text ->{IO} Either Failure Nat - 168. io2.IO.getLine.impl : Handle ->{IO} Either Failure Text - 169. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text - 170. io2.IO.handlePosition.impl : Handle + 172. io2.IO.getLine.impl : Handle ->{IO} Either Failure Text + 173. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text + 174. io2.IO.handlePosition.impl : Handle ->{IO} Either Failure Nat - 171. io2.IO.isDirectory.impl : Text + 175. io2.IO.isDirectory.impl : Text ->{IO} Either Failure Boolean - 172. io2.IO.isFileEOF.impl : Handle + 176. io2.IO.isFileEOF.impl : Handle ->{IO} Either Failure Boolean - 173. io2.IO.isFileOpen.impl : Handle + 177. io2.IO.isFileOpen.impl : Handle ->{IO} Either Failure Boolean - 174. io2.IO.isSeekable.impl : Handle + 178. io2.IO.isSeekable.impl : Handle ->{IO} Either Failure Boolean - 175. io2.IO.kill.impl : ThreadId ->{IO} Either Failure () - 176. io2.IO.listen.impl : Socket ->{IO} Either Failure () - 177. io2.IO.openFile.impl : Text + 179. io2.IO.kill.impl : ThreadId ->{IO} Either Failure () + 180. io2.IO.listen.impl : Socket ->{IO} Either Failure () + 181. io2.IO.openFile.impl : Text -> FileMode ->{IO} Either Failure Handle - 178. io2.IO.putBytes.impl : Handle + 182. io2.IO.putBytes.impl : Handle -> Bytes ->{IO} Either Failure () - 179. io2.IO.removeDirectory.impl : Text + 183. io2.IO.removeDirectory.impl : Text ->{IO} Either Failure () - 180. io2.IO.removeFile.impl : Text ->{IO} Either Failure () - 181. io2.IO.renameDirectory.impl : Text + 184. io2.IO.removeFile.impl : Text ->{IO} Either Failure () + 185. io2.IO.renameDirectory.impl : Text -> Text ->{IO} Either Failure () - 182. io2.IO.renameFile.impl : Text + 186. io2.IO.renameFile.impl : Text -> Text ->{IO} Either Failure () - 183. io2.IO.seekHandle.impl : Handle + 187. io2.IO.seekHandle.impl : Handle -> SeekMode -> Int ->{IO} Either Failure () - 184. io2.IO.serverSocket.impl : Optional Text + 188. io2.IO.serverSocket.impl : Optional Text -> Text ->{IO} Either Failure Socket - 185. io2.IO.setBuffering.impl : Handle + 189. io2.IO.setBuffering.impl : Handle -> BufferMode ->{IO} Either Failure () - 186. io2.IO.setCurrentDirectory.impl : Text + 190. io2.IO.setCurrentDirectory.impl : Text ->{IO} Either Failure () - 187. io2.IO.socketAccept.impl : Socket + 191. io2.IO.socketAccept.impl : Socket ->{IO} Either Failure Socket - 188. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat - 189. io2.IO.socketReceive.impl : Socket + 192. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat + 193. io2.IO.socketReceive.impl : Socket -> Nat ->{IO} Either Failure Bytes - 190. io2.IO.socketSend.impl : Socket + 194. io2.IO.socketSend.impl : Socket -> Bytes ->{IO} Either Failure () - 191. io2.IO.stdHandle : StdHandle -> Handle - 192. io2.IO.systemTime.impl : '{IO} Either Failure Nat - 193. unique type io2.IOError - 194. io2.IOError.AlreadyExists : IOError - 195. io2.IOError.EOF : IOError - 196. io2.IOError.IllegalOperation : IOError - 197. io2.IOError.NoSuchThing : IOError - 198. io2.IOError.PermissionDenied : IOError - 199. io2.IOError.ResourceBusy : IOError - 200. io2.IOError.ResourceExhausted : IOError - 201. io2.IOError.UserError : IOError - 202. unique type io2.IOFailure - 203. builtin type io2.MVar - 204. io2.MVar.isEmpty : MVar a ->{IO} Boolean - 205. io2.MVar.new : a ->{IO} MVar a - 206. io2.MVar.newEmpty : '{IO} MVar a - 207. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure () - 208. io2.MVar.read.impl : MVar a ->{IO} Either Failure a - 209. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a - 210. io2.MVar.take.impl : MVar a ->{IO} Either Failure a - 211. io2.MVar.tryPut.impl : MVar a + 195. io2.IO.stdHandle : StdHandle -> Handle + 196. io2.IO.systemTime.impl : '{IO} Either Failure Nat + 197. unique type io2.IOError + 198. io2.IOError.AlreadyExists : IOError + 199. io2.IOError.EOF : IOError + 200. io2.IOError.IllegalOperation : IOError + 201. io2.IOError.NoSuchThing : IOError + 202. io2.IOError.PermissionDenied : IOError + 203. io2.IOError.ResourceBusy : IOError + 204. io2.IOError.ResourceExhausted : IOError + 205. io2.IOError.UserError : IOError + 206. unique type io2.IOFailure + 207. builtin type io2.MVar + 208. io2.MVar.isEmpty : MVar a ->{IO} Boolean + 209. io2.MVar.new : a ->{IO} MVar a + 210. io2.MVar.newEmpty : '{IO} MVar a + 211. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure () + 212. io2.MVar.read.impl : MVar a ->{IO} Either Failure a + 213. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a + 214. io2.MVar.take.impl : MVar a ->{IO} Either Failure a + 215. io2.MVar.tryPut.impl : MVar a -> a ->{IO} Either Failure Boolean - 212. io2.MVar.tryRead.impl : MVar a + 216. io2.MVar.tryRead.impl : MVar a ->{IO} Either Failure (Optional a) - 213. io2.MVar.tryTake : MVar a ->{IO} Optional a - 214. unique type io2.SeekMode - 215. io2.SeekMode.AbsoluteSeek : SeekMode - 216. io2.SeekMode.RelativeSeek : SeekMode - 217. io2.SeekMode.SeekFromEnd : SeekMode - 218. builtin type io2.Socket - 219. unique type io2.StdHandle - 220. io2.StdHandle.StdErr : StdHandle - 221. io2.StdHandle.StdIn : StdHandle - 222. io2.StdHandle.StdOut : StdHandle - 223. builtin type io2.STM - 224. io2.STM.atomically : '{STM} a ->{IO} a - 225. io2.STM.retry : '{STM} a - 226. builtin type io2.ThreadId - 227. builtin type io2.Tls - 228. builtin type io2.Tls.Cipher - 229. builtin type io2.Tls.ClientConfig - 230. io2.Tls.ClientConfig.certificates.set : [SignedCert] + 217. io2.MVar.tryTake : MVar a ->{IO} Optional a + 218. unique type io2.SeekMode + 219. io2.SeekMode.AbsoluteSeek : SeekMode + 220. io2.SeekMode.RelativeSeek : SeekMode + 221. io2.SeekMode.SeekFromEnd : SeekMode + 222. builtin type io2.Socket + 223. unique type io2.StdHandle + 224. io2.StdHandle.StdErr : StdHandle + 225. io2.StdHandle.StdIn : StdHandle + 226. io2.StdHandle.StdOut : StdHandle + 227. builtin type io2.STM + 228. io2.STM.atomically : '{STM} a ->{IO} a + 229. io2.STM.retry : '{STM} a + 230. builtin type io2.ThreadId + 231. builtin type io2.Tls + 232. builtin type io2.Tls.Cipher + 233. builtin type io2.Tls.ClientConfig + 234. io2.Tls.ClientConfig.certificates.set : [SignedCert] -> ClientConfig -> ClientConfig - 231. io2.TLS.ClientConfig.ciphers.set : [Cipher] + 235. io2.TLS.ClientConfig.ciphers.set : [Cipher] -> ClientConfig -> ClientConfig - 232. io2.Tls.ClientConfig.default : Text + 236. io2.Tls.ClientConfig.default : Text -> Bytes -> ClientConfig - 233. io2.Tls.ClientConfig.versions.set : [Version] + 237. io2.Tls.ClientConfig.versions.set : [Version] -> ClientConfig -> ClientConfig - 234. io2.Tls.decodeCert.impl : Bytes + 238. io2.Tls.decodeCert.impl : Bytes -> Either Failure SignedCert - 235. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey] - 236. io2.Tls.encodeCert : SignedCert -> Bytes - 237. io2.Tls.encodePrivateKey : PrivateKey -> Bytes - 238. io2.Tls.handshake.impl : Tls ->{IO} Either Failure () - 239. io2.Tls.newClient.impl : ClientConfig + 239. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey] + 240. io2.Tls.encodeCert : SignedCert -> Bytes + 241. io2.Tls.encodePrivateKey : PrivateKey -> Bytes + 242. io2.Tls.handshake.impl : Tls ->{IO} Either Failure () + 243. io2.Tls.newClient.impl : ClientConfig -> Socket ->{IO} Either Failure Tls - 240. io2.Tls.newServer.impl : ServerConfig + 244. io2.Tls.newServer.impl : ServerConfig -> Socket ->{IO} Either Failure Tls - 241. builtin type io2.Tls.PrivateKey - 242. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes - 243. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure () - 244. builtin type io2.Tls.ServerConfig - 245. io2.Tls.ServerConfig.certificates.set : [SignedCert] + 245. builtin type io2.Tls.PrivateKey + 246. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes + 247. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure () + 248. builtin type io2.Tls.ServerConfig + 249. io2.Tls.ServerConfig.certificates.set : [SignedCert] -> ServerConfig -> ServerConfig - 246. io2.Tls.ServerConfig.ciphers.set : [Cipher] + 250. io2.Tls.ServerConfig.ciphers.set : [Cipher] -> ServerConfig -> ServerConfig - 247. io2.Tls.ServerConfig.default : [SignedCert] + 251. io2.Tls.ServerConfig.default : [SignedCert] -> PrivateKey -> ServerConfig - 248. io2.Tls.ServerConfig.versions.set : [Version] + 252. io2.Tls.ServerConfig.versions.set : [Version] -> ServerConfig -> ServerConfig - 249. builtin type io2.Tls.SignedCert - 250. io2.Tls.terminate.impl : Tls ->{IO} Either Failure () - 251. builtin type io2.Tls.Version - 252. unique type io2.TlsFailure - 253. builtin type io2.TVar - 254. io2.TVar.new : a ->{STM} TVar a - 255. io2.TVar.newIO : a ->{IO} TVar a - 256. io2.TVar.read : TVar a ->{STM} a - 257. io2.TVar.readIO : TVar a ->{IO} a - 258. io2.TVar.swap : TVar a -> a ->{STM} a - 259. io2.TVar.write : TVar a -> a ->{STM} () - 260. unique type IsPropagated - 261. IsPropagated.IsPropagated : IsPropagated - 262. unique type IsTest - 263. IsTest.IsTest : IsTest - 264. unique type Link - 265. builtin type Link.Term - 266. Link.Term : Term -> Link - 267. builtin type Link.Type - 268. Link.Type : Type -> Link - 269. builtin type List - 270. List.++ : [a] -> [a] -> [a] - 271. List.+: : a -> [a] -> [a] - 272. List.:+ : [a] -> a -> [a] - 273. List.at : Nat -> [a] -> Optional a - 274. List.cons : a -> [a] -> [a] - 275. List.drop : Nat -> [a] -> [a] - 276. List.empty : [a] - 277. List.size : [a] -> Nat - 278. List.snoc : [a] -> a -> [a] - 279. List.take : Nat -> [a] -> [a] - 280. metadata.isPropagated : IsPropagated - 281. metadata.isTest : IsTest - 282. builtin type Nat - 283. Nat.* : Nat -> Nat -> Nat - 284. Nat.+ : Nat -> Nat -> Nat - 285. Nat./ : Nat -> Nat -> Nat - 286. Nat.and : Nat -> Nat -> Nat - 287. Nat.complement : Nat -> Nat - 288. Nat.drop : Nat -> Nat -> Nat - 289. Nat.eq : Nat -> Nat -> Boolean - 290. Nat.fromText : Text -> Optional Nat - 291. Nat.gt : Nat -> Nat -> Boolean - 292. Nat.gteq : Nat -> Nat -> Boolean - 293. Nat.increment : Nat -> Nat - 294. Nat.isEven : Nat -> Boolean - 295. Nat.isOdd : Nat -> Boolean - 296. Nat.leadingZeros : Nat -> Nat - 297. Nat.lt : Nat -> Nat -> Boolean - 298. Nat.lteq : Nat -> Nat -> Boolean - 299. Nat.mod : Nat -> Nat -> Nat - 300. Nat.or : Nat -> Nat -> Nat - 301. Nat.popCount : Nat -> Nat - 302. Nat.pow : Nat -> Nat -> Nat - 303. Nat.shiftLeft : Nat -> Nat -> Nat - 304. Nat.shiftRight : Nat -> Nat -> Nat - 305. Nat.sub : Nat -> Nat -> Int - 306. Nat.toFloat : Nat -> Float - 307. Nat.toInt : Nat -> Int - 308. Nat.toText : Nat -> Text - 309. Nat.trailingZeros : Nat -> Nat - 310. Nat.xor : Nat -> Nat -> Nat - 311. type Optional a - 312. Optional.None : Optional a - 313. Optional.Some : a -> Optional a - 314. builtin type Request - 315. type SeqView a b - 316. SeqView.VElem : a -> b -> SeqView a b - 317. SeqView.VEmpty : SeqView a b - 318. unique type Test.Result - 319. Test.Result.Fail : Text -> Result - 320. Test.Result.Ok : Text -> Result - 321. builtin type Text - 322. Text.!= : Text -> Text -> Boolean - 323. Text.++ : Text -> Text -> Text - 324. Text.drop : Nat -> Text -> Text - 325. Text.empty : Text - 326. Text.eq : Text -> Text -> Boolean - 327. Text.fromCharList : [Char] -> Text - 328. Text.fromUtf8.impl : Bytes -> Either Failure Text - 329. Text.gt : Text -> Text -> Boolean - 330. Text.gteq : Text -> Text -> Boolean - 331. Text.lt : Text -> Text -> Boolean - 332. Text.lteq : Text -> Text -> Boolean - 333. Text.repeat : Nat -> Text -> Text - 334. Text.size : Text -> Nat - 335. Text.take : Nat -> Text -> Text - 336. Text.toCharList : Text -> [Char] - 337. Text.toUtf8 : Text -> Bytes - 338. Text.uncons : Text -> Optional (Char, Text) - 339. Text.unsnoc : Text -> Optional (Text, Char) - 340. todo : a -> b - 341. type Tuple a b - 342. Tuple.Cons : a -> b -> Tuple a b - 343. type Unit - 344. Unit.Unit : () - 345. Universal.< : a -> a -> Boolean - 346. Universal.<= : a -> a -> Boolean - 347. Universal.== : a -> a -> Boolean - 348. Universal.> : a -> a -> Boolean - 349. Universal.>= : a -> a -> Boolean - 350. Universal.compare : a -> a -> Int - 351. builtin type Value - 352. Value.dependencies : Value -> [Term] - 353. Value.deserialize : Bytes -> Either Text Value - 354. Value.load : Value ->{IO} Either [Term] a - 355. Value.serialize : Value -> Bytes - 356. Value.value : a -> Value + 253. builtin type io2.Tls.SignedCert + 254. io2.Tls.terminate.impl : Tls ->{IO} Either Failure () + 255. builtin type io2.Tls.Version + 256. unique type io2.TlsFailure + 257. builtin type io2.TVar + 258. io2.TVar.new : a ->{STM} TVar a + 259. io2.TVar.newIO : a ->{IO} TVar a + 260. io2.TVar.read : TVar a ->{STM} a + 261. io2.TVar.readIO : TVar a ->{IO} a + 262. io2.TVar.swap : TVar a -> a ->{STM} a + 263. io2.TVar.write : TVar a -> a ->{STM} () + 264. unique type IsPropagated + 265. IsPropagated.IsPropagated : IsPropagated + 266. unique type IsTest + 267. IsTest.IsTest : IsTest + 268. unique type Link + 269. builtin type Link.Term + 270. Link.Term : Term -> Link + 271. builtin type Link.Type + 272. Link.Type : Type -> Link + 273. builtin type List + 274. List.++ : [a] -> [a] -> [a] + 275. List.+: : a -> [a] -> [a] + 276. List.:+ : [a] -> a -> [a] + 277. List.at : Nat -> [a] -> Optional a + 278. List.cons : a -> [a] -> [a] + 279. List.drop : Nat -> [a] -> [a] + 280. List.empty : [a] + 281. List.size : [a] -> Nat + 282. List.snoc : [a] -> a -> [a] + 283. List.take : Nat -> [a] -> [a] + 284. metadata.isPropagated : IsPropagated + 285. metadata.isTest : IsTest + 286. builtin type Nat + 287. Nat.* : Nat -> Nat -> Nat + 288. Nat.+ : Nat -> Nat -> Nat + 289. Nat./ : Nat -> Nat -> Nat + 290. Nat.and : Nat -> Nat -> Nat + 291. Nat.complement : Nat -> Nat + 292. Nat.drop : Nat -> Nat -> Nat + 293. Nat.eq : Nat -> Nat -> Boolean + 294. Nat.fromText : Text -> Optional Nat + 295. Nat.gt : Nat -> Nat -> Boolean + 296. Nat.gteq : Nat -> Nat -> Boolean + 297. Nat.increment : Nat -> Nat + 298. Nat.isEven : Nat -> Boolean + 299. Nat.isOdd : Nat -> Boolean + 300. Nat.leadingZeros : Nat -> Nat + 301. Nat.lt : Nat -> Nat -> Boolean + 302. Nat.lteq : Nat -> Nat -> Boolean + 303. Nat.mod : Nat -> Nat -> Nat + 304. Nat.or : Nat -> Nat -> Nat + 305. Nat.popCount : Nat -> Nat + 306. Nat.pow : Nat -> Nat -> Nat + 307. Nat.shiftLeft : Nat -> Nat -> Nat + 308. Nat.shiftRight : Nat -> Nat -> Nat + 309. Nat.sub : Nat -> Nat -> Int + 310. Nat.toFloat : Nat -> Float + 311. Nat.toInt : Nat -> Int + 312. Nat.toText : Nat -> Text + 313. Nat.trailingZeros : Nat -> Nat + 314. Nat.xor : Nat -> Nat -> Nat + 315. type Optional a + 316. Optional.None : Optional a + 317. Optional.Some : a -> Optional a + 318. builtin type Request + 319. type SeqView a b + 320. SeqView.VElem : a -> b -> SeqView a b + 321. SeqView.VEmpty : SeqView a b + 322. unique type Test.Result + 323. Test.Result.Fail : Text -> Result + 324. Test.Result.Ok : Text -> Result + 325. builtin type Text + 326. Text.!= : Text -> Text -> Boolean + 327. Text.++ : Text -> Text -> Text + 328. Text.drop : Nat -> Text -> Text + 329. Text.empty : Text + 330. Text.eq : Text -> Text -> Boolean + 331. Text.fromCharList : [Char] -> Text + 332. Text.fromUtf8.impl : Bytes -> Either Failure Text + 333. Text.gt : Text -> Text -> Boolean + 334. Text.gteq : Text -> Text -> Boolean + 335. Text.lt : Text -> Text -> Boolean + 336. Text.lteq : Text -> Text -> Boolean + 337. Text.repeat : Nat -> Text -> Text + 338. Text.size : Text -> Nat + 339. Text.take : Nat -> Text -> Text + 340. Text.toCharList : Text -> [Char] + 341. Text.toUtf8 : Text -> Bytes + 342. Text.uncons : Text -> Optional (Char, Text) + 343. Text.unsnoc : Text -> Optional (Text, Char) + 344. todo : a -> b + 345. type Tuple a b + 346. Tuple.Cons : a -> b -> Tuple a b + 347. type Unit + 348. Unit.Unit : () + 349. Universal.< : a -> a -> Boolean + 350. Universal.<= : a -> a -> Boolean + 351. Universal.== : a -> a -> Boolean + 352. Universal.> : a -> a -> Boolean + 353. Universal.>= : a -> a -> Boolean + 354. Universal.compare : a -> a -> Int + 355. builtin type Value + 356. Value.dependencies : Value -> [Term] + 357. Value.deserialize : Bytes -> Either Text Value + 358. Value.load : Value ->{IO} Either [Term] a + 359. Value.serialize : Value -> Bytes + 360. Value.value : a -> Value .builtin> alias.many 94-104 .mylib @@ -452,17 +456,17 @@ Let's try it! Added definitions: - 1. Float.log : Float -> Float - 2. Float.logBase : Float -> Float -> Float - 3. Float.lt : Float -> Float -> Boolean - 4. Float.lteq : Float -> Float -> Boolean - 5. Float.max : Float -> Float -> Float - 6. Float.min : Float -> Float -> Float - 7. Float.pow : Float -> Float -> Float - 8. Float.round : Float -> Int - 9. Float.sin : Float -> Float - 10. Float.sinh : Float -> Float - 11. Float.sqrt : Float -> Float + 1. Float.floor : Float -> Int + 2. Float.fromText : Text -> Optional Float + 3. Float.gt : Float -> Float -> Boolean + 4. Float.gteq : Float -> Float -> Boolean + 5. Float.log : Float -> Float + 6. Float.logBase : Float -> Float -> Float + 7. Float.lt : Float -> Float -> Boolean + 8. Float.lteq : Float -> Float -> Boolean + 9. Float.max : Float -> Float -> Float + 10. Float.min : Float -> Float -> Float + 11. Float.pow : Float -> Float -> Float Tip: You can use `undo` or `reflog` to undo this change. @@ -522,17 +526,17 @@ I want to incorporate a few more from another namespace: .mylib> find - 1. Float.log : Float -> Float - 2. Float.logBase : Float -> Float -> Float - 3. Float.lt : Float -> Float -> Boolean - 4. Float.lteq : Float -> Float -> Boolean - 5. Float.max : Float -> Float -> Float - 6. Float.min : Float -> Float -> Float - 7. Float.pow : Float -> Float -> Float - 8. Float.round : Float -> Int - 9. Float.sin : Float -> Float - 10. Float.sinh : Float -> Float - 11. Float.sqrt : Float -> Float + 1. Float.floor : Float -> Int + 2. Float.fromText : Text -> Optional Float + 3. Float.gt : Float -> Float -> Boolean + 4. Float.gteq : Float -> Float -> Boolean + 5. Float.log : Float -> Float + 6. Float.logBase : Float -> Float -> Float + 7. Float.lt : Float -> Float -> Boolean + 8. Float.lteq : Float -> Float -> Boolean + 9. Float.max : Float -> Float -> Float + 10. Float.min : Float -> Float -> Float + 11. Float.pow : Float -> Float -> Float 12. List.adjacentPairs : [a] -> [(a, a)] 13. List.all : (a ->{g} Boolean) -> [a] ->{g} Boolean 14. List.any : (a ->{g} Boolean) -> [a] ->{g} Boolean diff --git a/unison-src/transcripts/builtins-merge.output.md b/unison-src/transcripts/builtins-merge.output.md index a699b8533..46c87f7e1 100644 --- a/unison-src/transcripts/builtins-merge.output.md +++ b/unison-src/transcripts/builtins-merge.output.md @@ -14,7 +14,7 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace 3. Boolean (builtin type) 4. Boolean/ (1 definition) 5. Bytes (builtin type) - 6. Bytes/ (29 definitions) + 6. Bytes/ (33 definitions) 7. Char (builtin type) 8. Char/ (3 definitions) 9. Code (builtin type) diff --git a/unison-src/transcripts/builtins.md b/unison-src/transcripts/builtins.md index 8352af158..d1bebbb37 100644 --- a/unison-src/transcripts/builtins.md +++ b/unison-src/transcripts/builtins.md @@ -227,6 +227,27 @@ test> Bytes.tests.at = Bytes.at 0 bs == Some 77, Bytes.at 99 bs == None ] + +test> Bytes.tests.compression = + roundTrip b = + (Bytes.zlib.decompress (Bytes.zlib.compress b) == Right b) + && (Bytes.gzip.decompress (Bytes.gzip.compress b) == Right b) + + isLeft = cases + Left _ -> true + Right _ -> false + + checks [ + roundTrip 0xs2093487509823745709827345789023457892345, + roundTrip 0xs00000000000000000000000000000000000000000000, + roundTrip 0xs, + roundTrip 0xs11111111111111111111111111, + roundTrip 0xsffffffffffffffffffffffffffffff, + roundTrip 0xs222222222fffffffffffffffffffffffffffffff, + -- these fail due to bad checksums and/or headers + isLeft (zlib.decompress 0xs2093487509823745709827345789023457892345), + isLeft (gzip.decompress 0xs201209348750982374593939393939709827345789023457892345) + ] ``` ```ucm:hide diff --git a/unison-src/transcripts/builtins.output.md b/unison-src/transcripts/builtins.output.md index b83798518..416b1f1cc 100644 --- a/unison-src/transcripts/builtins.output.md +++ b/unison-src/transcripts/builtins.output.md @@ -204,6 +204,27 @@ test> Bytes.tests.at = Bytes.at 0 bs == Some 77, Bytes.at 99 bs == None ] + +test> Bytes.tests.compression = + roundTrip b = + (Bytes.zlib.decompress (Bytes.zlib.compress b) == Right b) + && (Bytes.gzip.decompress (Bytes.gzip.compress b) == Right b) + + isLeft = cases + Left _ -> true + Right _ -> false + + checks [ + roundTrip 0xs2093487509823745709827345789023457892345, + roundTrip 0xs00000000000000000000000000000000000000000000, + roundTrip 0xs, + roundTrip 0xs11111111111111111111111111, + roundTrip 0xsffffffffffffffffffffffffffffff, + roundTrip 0xs222222222fffffffffffffffffffffffffffffff, + -- these fail due to bad checksums and/or headers + isLeft (zlib.decompress 0xs2093487509823745709827345789023457892345), + isLeft (gzip.decompress 0xs201209348750982374593939393939709827345789023457892345) + ] ``` ## `Any` functions @@ -257,6 +278,7 @@ Now that all the tests have been added to the codebase, let's view the test repo ◉ Boolean.tests.notTable Passed ◉ Boolean.tests.orTable Passed ◉ Bytes.tests.at Passed + ◉ Bytes.tests.compression Passed ◉ Int.tests.arithmetic Passed ◉ Int.tests.bitTwiddling Passed ◉ Int.tests.conversions Passed @@ -267,7 +289,7 @@ Now that all the tests have been added to the codebase, let's view the test repo ◉ Text.tests.repeat Passed ◉ Text.tests.takeDropAppend Passed - ✅ 15 test(s) passing + ✅ 16 test(s) passing Tip: Use view Any.test1 to view the source of a test. diff --git a/unison-src/transcripts/emptyCodebase.output.md b/unison-src/transcripts/emptyCodebase.output.md index d648c3dcd..27574aefb 100644 --- a/unison-src/transcripts/emptyCodebase.output.md +++ b/unison-src/transcripts/emptyCodebase.output.md @@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge` .foo> ls - 1. builtin/ (356 definitions) + 1. builtin/ (360 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/ (524 definitions) + 1. builtin/ (528 definitions) ``` More typically, you'd start out by pulling `base. diff --git a/unison-src/transcripts/merges.output.md b/unison-src/transcripts/merges.output.md index 8a23e3268..3a5cfaf00 100644 --- a/unison-src/transcripts/merges.output.md +++ b/unison-src/transcripts/merges.output.md @@ -112,13 +112,13 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t Note: The most recent namespace hash is immediately below this message. - ⊙ #phqs777jj7 + ⊙ #a811qrcopu - Deletes: feature1.y - ⊙ #n77vujo4il + ⊙ #a1p0e4titu + Adds / updates: @@ -129,26 +129,26 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t Original name New name(s) feature1.y master.y - ⊙ #msplsg3ueo + ⊙ #ni8uvphkh4 + Adds / updates: feature1.y - ⊙ #9spac4uc55 + ⊙ #tc32iv6qjd > Moves: Original name New name x master.x - ⊙ #grjpiitanv + ⊙ #ek3ga6djgv + Adds / updates: x - □ #l9u7s7kl6v (start of history) + □ #tjol927qko (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`. diff --git a/unison-src/transcripts/reflog.output.md b/unison-src/transcripts/reflog.output.md index e7c8fcdcd..95547e772 100644 --- a/unison-src/transcripts/reflog.output.md +++ b/unison-src/transcripts/reflog.output.md @@ -59,16 +59,16 @@ y = 2 most recent, along with the command that got us there. Try: `fork 2 .old` - `fork #o8pmeorctm .old` to make an old namespace + `fork #gplos7eiv5 .old` to make an old namespace accessible again, - `reset-root #o8pmeorctm` to reset the root namespace and + `reset-root #gplos7eiv5` to reset the root namespace and its history to that of the specified namespace. - 1. #tolltjdebp : add - 2. #o8pmeorctm : add - 3. #l9u7s7kl6v : builtins.merge + 1. #gk0gksqj3i : add + 2. #gplos7eiv5 : add + 3. #tjol927qko : builtins.merge 4. #sjg2v58vn2 : (initial reflogged namespace) ``` diff --git a/unison-src/transcripts/squash.output.md b/unison-src/transcripts/squash.output.md index cfbec6c2b..9b1a1be21 100644 --- a/unison-src/transcripts/squash.output.md +++ b/unison-src/transcripts/squash.output.md @@ -13,7 +13,7 @@ Let's look at some examples. We'll start with a namespace with just the builtins - □ #od1fl5q84m (start of history) + □ #1i8c436t0p (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. - ⊙ #q60575r9ju + ⊙ #3bmnt6nsqc > Moves: Original name New name Nat.frobnicate Nat.+ - ⊙ #308j638l8k + ⊙ #npl4p8nqhk > Moves: Original name New name Nat.+ Nat.frobnicate - □ #od1fl5q84m (start of history) + □ #1i8c436t0p (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. - ⊙ #q60575r9ju + ⊙ #3bmnt6nsqc > Moves: Original name New name Nat.frobnicate Nat.+ - ⊙ #308j638l8k + ⊙ #npl4p8nqhk > Moves: Original name New name Nat.+ Nat.frobnicate - □ #od1fl5q84m (start of history) + □ #1i8c436t0p (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 - □ #od1fl5q84m (start of history) + □ #1i8c436t0p (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. - ⊙ #cvsvuk3b0j + ⊙ #pecjlutsl0 - Deletes: Nat.* Nat.+ - □ #od1fl5q84m (start of history) + □ #1i8c436t0p (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.