A PoC of non-deterministic effects (assumes effect is referentially transparent is sth).
// these are deterministic effectsdefcreateUser(newUser:CreateUser):F[User]deflogout(user:User):F[Unit]defcheckSomePage(user:User):F[Page]// this makes effects non-deterministic// we can combine 2 branches and only one of them will be followeddefndLogout(user:User):NonDeterministicT[F,Unit]=NonDeterministicT.liftF(logout(user))defndCheckPage(user:User):NonDeterministicT[F,Unit]=>NonDeterministicT.liftF(checkSomePage(user))defndUserBehavior(user:User):NonDeterministicT[F,Unit]=// The first path will have its likelihood increased 9 times,// the second path will have its original weight (1),// which should result in branch picking the first branch 9 times out of 9+1=10,// and the second branch 1 time out of 10. ndCheckPage(user).flatMap(_=> ndUserBehavior(user)).scale(9)<+> ndLogout(user)// this should create user and then randomly decide between// checking page and logging out - once logged out, it should finishNonDeterministicT.liftF(createUser(newUser))// NonDeterministicT[F, User] .flatMap(ndUserBehavior)// NonDeterministicT[F, Unit] .execute(Decider.random())// F[Unit]