Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
ok, so what about this?
type A <: Int
object A {
def apply(i: Int): A = i.asInstanceOf[A]
}
val isIntA = 3.isInstanceOf[A]
First, the compiler warns me that the type test for A cannot be checked at runtime
so I'm curious about that. Second, it tells me that 3 is an A, which surprised me.
def fmap[B](f : A => B) :M[B] = ma.flatMap(a => pure(f(a)))
I guess the time to revive my old ("gamer") discord profile has come.
@BalmungSan
If you have gmail or protonmail, you can use a alias when you signup for an account ${user}@gmail.com => ${user}+${alias}@gmail.com
The aliases still get sent to you, but they have alias in the TO field so you can properly filter via domain
Some thing I wish I knew about 20 years ago for setting up spam filters.
ap
using fmap
it causes the loop. I guess that is because Monad trait is reference to the fmap
within Applicative
. However, why does @main def main = println(List(1).fmap(_ * 2))
refer to the Monad
version of instead of directly using the Functor
implementation?
Monad
)
@BalmungSan Hmm... So, the instance that will always be pass will be the monad instance? What if I have a generalized function that just needs a Functor
constraint, how will the compiler find that instance?
For example:
def someGeneralizedFunc [F[_]: Functor](fa: F[String]): F[Int] = fa.fmap(x => 3)
someGeneralizedFunc(List("yo")) // I don't think this will work with just a Monad instance for List
Monad
can form a Functor
map
in terms of flatMap
and pure
Monad[F] extends Functor[F]
, as such, it is a subtype.
Applicative
already extends Functor
?
map
on a tuple?[error] | Found: Object with PolyFunction {...}
[error] | Required: PolyFunction{apply: [t](x$1: t): Any}