Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
F[A]
(kind * -> *
) - matter. This is the most neglected part, everyone's talking about "monads", in ways that generate lots of confusion. A good treatment of this helps you tremendously understanding the restMonoid
being an example
F[A]
as a standalone entities, as well as their relationship with typeclasses/algebras, especially the fact that algebras describe part of their behaviour, but some things are specific to each concrete datatype <-- failure to understand this leads to the "how do I get this value out of IO" fallacy
Exists
:trait Exists[A] { def apply(): Boolean }
object Exists extends Nope {
implicit def sure[A](implicit a: A): Exists[A] = new Exists[A] {
def apply() = true
}
}
trait Nope {
implicit def nope[A]: Exists[A] = new Exists[A] {
def apply() = false
}
}
def isEffect[T](implicit isIt: Exists[Effect[T]]) = isIt()
rho
issue
rho
only had Task
TypeTag
, which would need to also capture typeclass instances
trait TagHandler {
def success(x: Any): Unit
def failure(reason: Throwable): Unit
}
abstract class StandardTagHandler(val pfAllowedStates : PartialFunction[State, Unit]) extends TagHandler {
def sth_success(x : Any) : Unit
def success(x : Any) : Unit =
if (pfAllowedStates.isDefinedAt(state)) sth_success(x)
else resetToInit(s"$this called in unallowed state $state")
def failure(reason : Throwable) : Unit = {
resetToInit(s"$this failed with reason : $reason")
}
}
state : State
. i want to make this intermediate StandardTagHandler
class so I don't keep rewriting the state check boiler plate
State => Boolean
check or something like that
State1 <: State
etc, you could have a class StateTransition[A, B]
, have the method that does a state transition from From
to To
take an implicit StateTransition[From, To]
, and have a bunch of implicit object transitionFromTo extends StateTransition[From, To]
for the allowed transitions