Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
foo[T: ClassTag]
and want to specialize it dynamically to call bar[T <: Bar]
if it knows it can; the proper way would be to introduce a typeclass I know, but it's so much boilerplate
@tirumalesh123 lift
is just another name for map
, with a slightly rearranged signature.map
normally looks like def map(fa: F[A])(f: A => B): F[B]
. If you rearrange the arguments you get def lift(f: A => B): F[A] => F[B]
, so you can look at Functor
as the api for lifting functions of one argument in F
. This extends to Applicative, which lets you lift functions of multiple arguments into F
, and ultimately into Monad
, which gives you the ability to change the structure of one computation based on the result of another.
et's say I have a method which returns optional if I want to get the value inside optional should I use lifting functions
yeah, pretty much. You should just map
(or flatMap
) and transform the Option
that way. I don't particularly like saying "the value inside the F
" because it's misleading in the long run, but it's a decent approximation at first
Deserializer[A](run: Array[Byte] => A)
A => B
giving us a Deserializer[B]
Serializer[A]