@@ -30,14 +30,14 @@ import cats.effect._
3030import cats .implicits ._
3131import org .typelevel .vault ._
3232
33- // Importing global cats-effect runtime to allow .unsafeRunSync;
33+ // Importing global cats-effect runtime to allow .unsafeRunSync();
3434// In real code you should follow cats-effect advice on obtaining a runtime
3535import cats .effect .unsafe .implicits .global
3636```
3737
3838Then some basic operations
3939
40- ``` scala mdoc
40+ ``` scala mdoc:silent
4141case class Bar (a : String , b : Int , c : Long )
4242
4343// Creating keys are effects, but interacting with the vault
@@ -50,9 +50,13 @@ val basicLookup = for {
5050 .insert(key, Bar (" " , 1 , 2L ))
5151 .lookup(key)
5252}
53+ ```
5354
54- basicLookup.unsafeRunSync
55+ ``` scala mdoc
56+ basicLookup.unsafeRunSync()
57+ ```
5558
59+ ``` scala mdoc:silent
5660val lookupValuesOfDifferentTypes = for {
5761 key1 <- Key .newKey[IO , Bar ]
5862 key2 <- Key .newKey[IO , String ]
@@ -66,18 +70,26 @@ val lookupValuesOfDifferentTypes = for {
6670 (myvault.lookup(key1), myvault.lookup(key2), myvault.lookup(key3))
6771 .mapN((_,_,_))
6872}
73+ ```
6974
70- lookupValuesOfDifferentTypes.unsafeRunSync
75+ ``` scala mdoc
76+ lookupValuesOfDifferentTypes.unsafeRunSync()
77+ ```
7178
79+ ``` scala mdoc:silent
7280val emptyLookup = for {
7381 key <- Key .newKey[IO , Bar ]
7482} yield {
7583 Vault .empty
7684 .lookup(key)
7785}
86+ ```
7887
79- emptyLookup.unsafeRunSync
88+ ``` scala mdoc
89+ emptyLookup.unsafeRunSync()
90+ ```
8091
92+ ``` scala mdoc:silent
8193val doubleInsertTakesMostRecent = for {
8294 key <- Key .newKey[IO , Bar ]
8395} yield {
@@ -86,9 +98,13 @@ val doubleInsertTakesMostRecent = for {
8698 .insert(key, Bar (" Monkey" , 7 , 5L ))
8799 .lookup(key)
88100}
101+ ```
89102
90- doubleInsertTakesMostRecent.unsafeRunSync
103+ ``` scala mdoc
104+ doubleInsertTakesMostRecent.unsafeRunSync()
105+ ```
91106
107+ ``` scala mdoc:silent
92108val mergedVaultsTakesLatter = for {
93109 key <- Key .newKey[IO , Bar ]
94110} yield {
@@ -97,9 +113,13 @@ val mergedVaultsTakesLatter = for {
97113 Vault .empty.insert(key, Bar (" Monkey" , 7 , 5L ))
98114 ).lookup(key)
99115}
116+ ```
100117
101- mergedVaultsTakesLatter.unsafeRunSync
118+ ``` scala mdoc
119+ mergedVaultsTakesLatter.unsafeRunSync()
120+ ```
102121
122+ ``` scala mdoc:silent
103123val deletedKeyIsMissing = for {
104124 key <- Key .newKey[IO , Bar ]
105125} yield {
@@ -108,30 +128,38 @@ val deletedKeyIsMissing = for {
108128 .delete(key)
109129 .lookup(key)
110130}
131+ ```
111132
112- deletedKeyIsMissing.unsafeRunSync
133+ ``` scala mdoc
134+ deletedKeyIsMissing.unsafeRunSync()
113135```
114136
115137We can also interact with a single value ` locker ` instead of the
116138larger datastructure that a ` vault ` enables.
117139
118- ``` scala mdoc
140+ ``` scala mdoc:silent
119141val lockerExample = for {
120142 key <- Key .newKey[IO , Bar ]
121143} yield {
122144 Locker (key, Bar (" " , 1 , 2L ))
123145 .unlock(key)
124146}
147+ ```
125148
126- lockerExample.unsafeRunSync
149+ ``` scala mdoc
150+ lockerExample.unsafeRunSync()
151+ ```
127152
153+ ``` scala mdoc:silent
128154val wrongLockerExample = for {
129155 key <- Key .newKey[IO , Bar ]
130156 key2 <- Key .newKey[IO , Bar ]
131157} yield {
132158 Locker (key, Bar (" " , 1 , 2L ))
133159 .unlock(key2)
134160}
161+ ```
135162
136- wrongLockerExample.unsafeRunSync
163+ ``` scala mdoc
164+ wrongLockerExample.unsafeRunSync()
137165```
0 commit comments