Implicit for Function not being foundPimp my function in scala - applying implicit conversions on functionsWhere does Scala look for implicits?How can a time function exist in functional programming?selecting a subset of a list of functions based off of the type of their arguments in scalaCovariance of a passed function argumentScala: Is it possible to override val's in the sub-class's constructor?Scala ambiguity with paren-less function callsImporting implicits from a subclassUnable to find implicit macroWhere to put implicits and helper functions, traits vs companion objects

Why is long-term living in Almost-Earth causing severe health problems?

How can one's career as a reviewer be ended?

Do you have to have figures when playing D&D?

How can powerful telekinesis avoid violating Newton's 3rd Law?

What is Gilligan's full Name?

Why is the length of the Kelvin unit of temperature equal to that of the Celsius unit?

Why did the World Bank set the global poverty line at $1.90?

Who is "He that flies" in Lord of the Rings?

Confused with atmospheric pressure equals plastic balloon’s inner pressure

How can I remove material from this wood beam?

Breaking changes to eieio in Emacs 27?

Remove border lines of SRTM tiles rendered as hillshade

If someone intimidates another person, does the person affected gain the Frightened condition?

How (un)safe is it to ride barefoot?

Proving that a Russian cryptographic standard is too structured

C++ logging library

How to avoid typing 'git' at the begining of every Git command

Was Self-modifying-code possible just using BASIC?

Why would a home insurer offer a discount based on credit score?

How far would a landing Airbus A380 go until it stops with no brakes?

Augment Export function to support custom number formatting

Should I refuse to be named as co-author of a low quality paper?

Suppose leased car is totalled: what are financial implications?

The origin of the Russian proverb about two hares



Implicit for Function not being found


Pimp my function in scala - applying implicit conversions on functionsWhere does Scala look for implicits?How can a time function exist in functional programming?selecting a subset of a list of functions based off of the type of their arguments in scalaCovariance of a passed function argumentScala: Is it possible to override val's in the sub-class's constructor?Scala ambiguity with paren-less function callsImporting implicits from a subclassUnable to find implicit macroWhere to put implicits and helper functions, traits vs companion objects






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I have this typeclass



import simulacrum._
@typeclass trait Functor[F[_]]
def map[A, B](fa: F[A])(f: A => B) : F[B]
def lift[A, B](fa: F[A])(f: A => B) : F[A] => F[B] = fa => map(fa)(f)
def as[A, B](fa: F[A], b: => B) : F[B] = map(fa)(_ => b)
def void[A](fa: F[A]) : F[Unit] = as(fa, ())



and this is the implementation



object Functor 
implicit val listFunctor: Functor[List] = new Functor[List]
def map[A, B](fa: List[A])(f: A => B) = fa.map(f)

implicit def functionFunctor[X]: Functor[X => ?] = new Functor[X => ?]
def map[A, B](fa : X => A)(f : A => B) = fa andThen f




I can easily discover the List implicit implementation as



object Chapter1 extends App 
import Functor.ops._
List(1, 2, 3).as("foo").foreach(println)



The above works perfectly fine. I can also do



object Chapter1 extends App 
import Functor._
val func : Int => String = implicitly[Functor[Int => ?]].map(_ + 2)(_.toString)
println(func(5))



But when I try



object Chapter1 extends App 
import Functor.ops._
val x : Int => Int = _ + 2
val y : Int => String = x.map(_.toString)



It doesn't find my implicit implementation and says that the value map is not a member of Int => Int










share|improve this question




























    2















    I have this typeclass



    import simulacrum._
    @typeclass trait Functor[F[_]]
    def map[A, B](fa: F[A])(f: A => B) : F[B]
    def lift[A, B](fa: F[A])(f: A => B) : F[A] => F[B] = fa => map(fa)(f)
    def as[A, B](fa: F[A], b: => B) : F[B] = map(fa)(_ => b)
    def void[A](fa: F[A]) : F[Unit] = as(fa, ())



    and this is the implementation



    object Functor 
    implicit val listFunctor: Functor[List] = new Functor[List]
    def map[A, B](fa: List[A])(f: A => B) = fa.map(f)

    implicit def functionFunctor[X]: Functor[X => ?] = new Functor[X => ?]
    def map[A, B](fa : X => A)(f : A => B) = fa andThen f




    I can easily discover the List implicit implementation as



    object Chapter1 extends App 
    import Functor.ops._
    List(1, 2, 3).as("foo").foreach(println)



    The above works perfectly fine. I can also do



    object Chapter1 extends App 
    import Functor._
    val func : Int => String = implicitly[Functor[Int => ?]].map(_ + 2)(_.toString)
    println(func(5))



    But when I try



    object Chapter1 extends App 
    import Functor.ops._
    val x : Int => Int = _ + 2
    val y : Int => String = x.map(_.toString)



    It doesn't find my implicit implementation and says that the value map is not a member of Int => Int










    share|improve this question
























      2












      2








      2








      I have this typeclass



      import simulacrum._
      @typeclass trait Functor[F[_]]
      def map[A, B](fa: F[A])(f: A => B) : F[B]
      def lift[A, B](fa: F[A])(f: A => B) : F[A] => F[B] = fa => map(fa)(f)
      def as[A, B](fa: F[A], b: => B) : F[B] = map(fa)(_ => b)
      def void[A](fa: F[A]) : F[Unit] = as(fa, ())



      and this is the implementation



      object Functor 
      implicit val listFunctor: Functor[List] = new Functor[List]
      def map[A, B](fa: List[A])(f: A => B) = fa.map(f)

      implicit def functionFunctor[X]: Functor[X => ?] = new Functor[X => ?]
      def map[A, B](fa : X => A)(f : A => B) = fa andThen f




      I can easily discover the List implicit implementation as



      object Chapter1 extends App 
      import Functor.ops._
      List(1, 2, 3).as("foo").foreach(println)



      The above works perfectly fine. I can also do



      object Chapter1 extends App 
      import Functor._
      val func : Int => String = implicitly[Functor[Int => ?]].map(_ + 2)(_.toString)
      println(func(5))



      But when I try



      object Chapter1 extends App 
      import Functor.ops._
      val x : Int => Int = _ + 2
      val y : Int => String = x.map(_.toString)



      It doesn't find my implicit implementation and says that the value map is not a member of Int => Int










      share|improve this question














      I have this typeclass



      import simulacrum._
      @typeclass trait Functor[F[_]]
      def map[A, B](fa: F[A])(f: A => B) : F[B]
      def lift[A, B](fa: F[A])(f: A => B) : F[A] => F[B] = fa => map(fa)(f)
      def as[A, B](fa: F[A], b: => B) : F[B] = map(fa)(_ => b)
      def void[A](fa: F[A]) : F[Unit] = as(fa, ())



      and this is the implementation



      object Functor 
      implicit val listFunctor: Functor[List] = new Functor[List]
      def map[A, B](fa: List[A])(f: A => B) = fa.map(f)

      implicit def functionFunctor[X]: Functor[X => ?] = new Functor[X => ?]
      def map[A, B](fa : X => A)(f : A => B) = fa andThen f




      I can easily discover the List implicit implementation as



      object Chapter1 extends App 
      import Functor.ops._
      List(1, 2, 3).as("foo").foreach(println)



      The above works perfectly fine. I can also do



      object Chapter1 extends App 
      import Functor._
      val func : Int => String = implicitly[Functor[Int => ?]].map(_ + 2)(_.toString)
      println(func(5))



      But when I try



      object Chapter1 extends App 
      import Functor.ops._
      val x : Int => Int = _ + 2
      val y : Int => String = x.map(_.toString)



      It doesn't find my implicit implementation and says that the value map is not a member of Int => Int







      scala simulacrum






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 21:36









      Knows Not MuchKnows Not Much

      11.4k29112227




      11.4k29112227






















          1 Answer
          1






          active

          oldest

          votes


















          3














          Compiler can't see that Int => Int is Int => ? applied to Int.



          Add



          scalacOptions += "-Ypartial-unification"


          to build.sbt.



          It's necessary for normal work with higher-kinded types with Cats, Scalaz or manually.



          By the way, there's no sense to import Functor._






          share|improve this answer




















          • 1





            Ahhh.... This is the 100th time partial unification has bit me

            – Knows Not Much
            Mar 24 at 22:11











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328810%2fimplicit-for-function-not-being-found%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Compiler can't see that Int => Int is Int => ? applied to Int.



          Add



          scalacOptions += "-Ypartial-unification"


          to build.sbt.



          It's necessary for normal work with higher-kinded types with Cats, Scalaz or manually.



          By the way, there's no sense to import Functor._






          share|improve this answer




















          • 1





            Ahhh.... This is the 100th time partial unification has bit me

            – Knows Not Much
            Mar 24 at 22:11















          3














          Compiler can't see that Int => Int is Int => ? applied to Int.



          Add



          scalacOptions += "-Ypartial-unification"


          to build.sbt.



          It's necessary for normal work with higher-kinded types with Cats, Scalaz or manually.



          By the way, there's no sense to import Functor._






          share|improve this answer




















          • 1





            Ahhh.... This is the 100th time partial unification has bit me

            – Knows Not Much
            Mar 24 at 22:11













          3












          3








          3







          Compiler can't see that Int => Int is Int => ? applied to Int.



          Add



          scalacOptions += "-Ypartial-unification"


          to build.sbt.



          It's necessary for normal work with higher-kinded types with Cats, Scalaz or manually.



          By the way, there's no sense to import Functor._






          share|improve this answer















          Compiler can't see that Int => Int is Int => ? applied to Int.



          Add



          scalacOptions += "-Ypartial-unification"


          to build.sbt.



          It's necessary for normal work with higher-kinded types with Cats, Scalaz or manually.



          By the way, there's no sense to import Functor._







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 24 at 22:05

























          answered Mar 24 at 22:00









          Dmytro MitinDmytro Mitin

          12.1k1622




          12.1k1622







          • 1





            Ahhh.... This is the 100th time partial unification has bit me

            – Knows Not Much
            Mar 24 at 22:11












          • 1





            Ahhh.... This is the 100th time partial unification has bit me

            – Knows Not Much
            Mar 24 at 22:11







          1




          1





          Ahhh.... This is the 100th time partial unification has bit me

          – Knows Not Much
          Mar 24 at 22:11





          Ahhh.... This is the 100th time partial unification has bit me

          – Knows Not Much
          Mar 24 at 22:11



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328810%2fimplicit-for-function-not-being-found%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript