[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.zio._ | |
import scalaz.zio.syntax._ | |
import utest._ | |
class TestService(data: Ref[Map[Int, String]]) extends Database.Service { | |
def lookup(id: Int) = for { | |
map <- data.get | |
// I assume the semantic is to fail if key is not defined | |
v <- map.get(id) match { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.nio._ | |
import scalaz.nio.channels.{AsynchronousServerSocketChannel, AsynchronousSocketChannel} | |
import scalaz.zio.console._ | |
import scalaz.zio._ | |
object TestSocket extends App { | |
override def run(args: List[String]): ZIO[Environment, Nothing, Int] = { | |
theSocket.foldM( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fiber failed. | |
A checked error was not handled. | |
Chained(Error when calculating configuration for node 'relay2.rudder.local' (66fbf984-e1a9-4fea-83fe-ee14b15355b5),Chained(Error for node '66fbf984-e1a9-4fea-83fe-ee14b15355b5' bundle creation,Unexpected(We could not generate policies for server '66fbf984-e1a9-4fea-83fe-ee14b15355b5', therefore making updates for nodes behind it unavailable. Maybe you are missing 'scale out' plugin?))) | |
Fiber:189998 was supposed to continue to: | |
a future continuation at scalaz.zio.ZIO.run(ZIO.scala:1026) | |
a future continuation at scalaz.zio.Semaphore.withPermit(Semaphore.scala:60) | |
Fiber:189998 execution trace: | |
at com.normation.errors$IOChainError.chainError(ZioCommons.scala:119) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This test shows that without a fork, execution is purely mono-fiber and sequential. | |
*/ | |
object TestZioExecSemantic { | |
val rt = new DefaultRuntime {} | |
trait LOG { | |
def apply(s: String): UIO[Unit] | |
} | |
def makeLog = UIO(new LOG { | |
val zero = System.currentTimeMillis() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* My application is splitted in several modules, possibly independently built and | |
* distributed. | |
* I have a Base error trait for the whole application. | |
* | |
* Each module has its own business error defined by a module base error trait which | |
* extends BaseError. | |
* | |
* I want to have a common framework to manage bridging errors between modules so | |
* that a module can use the other ones and subsume error type to its own, especially |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package challenge | |
// libraryDependencies += "org.scalaz" %% "scalaz-zio" % "0.11" | |
import com.softwaremill.quicklens._ | |
// libraryDependencies += "com.softwaremill.quicklens" %% "quicklens" % "1.4.11" | |
import scalaz.zio._ | |
import scalaz.zio.syntax._ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************** | |
* UPDATED VERSION HERE: | |
* https://gist.github.com/fanf/5b6edced8422e127ea0bf4ad2ed1b7a2 | |
* | |
******************************************************************/ | |
/* | |
* The below version is kept to show how clumsy and non optimal things can be | |
* when you use the incorrect abstraction. Please go see the link above to | |
* see a much better, cleaner, shorter version of the solution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This piece of commented code aims to clarify some | |
misconceptions between several advanced concepts | |
in pure functional programming/category theory: | |
free monads, finally tagless approach, algebraic | |
effects. | |
These concepts are actually very close. They rely | |
on similar concepts and even represent the "same" | |
object (up to isomorphism!) from the theoretical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.normation.rudder | |
import com.normation.ldap.sdk.LDAPEntry | |
import com.normation.ldap.sdk.RWPooledSimpleAuthConnectionProvider | |
import com.unboundid.ldap.sdk.Attribute | |
import com.unboundid.ldap.sdk.DN | |
/* | |
* See: | |
* https://www.rudder-project.org/redmine/issues/13256 |