Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't understand exactly why this isn't working (and I've just asked <a href="https://stackoverflow.com/q/13515169/334519">a follow-up question</a> about the part I don't understand), but I can offer three workarounds.</p> <p>The <a href="https://gist.github.com/4131492" rel="nofollow noreferrer">first</a> makes no sense to me and requires some deeper changes to your code and clunky syntax, so I'll only mention it in passing.</p> <p>The second is to import the appropriate <code>FunctorSyntax</code> implicits (as opposed to the <code>ToFunctorOps</code> ones that aren't working properly):</p> <pre><code>scala&gt; val of = implicitly[scalaz.Functor[Option]] of: scalaz.Functor[Option] = scalaz.std.OptionInstances$$anon$1@377d4c39 scala&gt; import of.functorSyntax._ import of.functorSyntax._ scala&gt; 1.some |&gt; (inc _).lift res0: Option[Int] = Some(2) </code></pre> <p>But this requires you to import these implicits for every individual <code>Functor</code> you want to use them with, and isn't much better than just writing <code>of lift inc</code>.</p> <p>The last requires a little more code but is more satisfying. You need the following new syntax trait, with a <code>myLift</code> method modeled of the <code>lift</code> in <code>Function2Ops</code>:</p> <pre><code>trait MyFunction1Syntax[A, R] extends scalaz.syntax.Ops[A =&gt; R] { def myLift[F[_]](implicit F: scalaz.Functor[F]) = F lift self } implicit def toMyFunction1Syntax[A, R](f: A =&gt; R) = new MyFunction1Syntax[A, R] { def self = f } </code></pre> <p>And now you can write the following:</p> <pre><code>scala&gt; 1.some |&gt; (inc _).myLift res3: Option[Int] = Some(2) </code></pre> <p>It might be worth bringing this issue up on the Scalaz mailing list.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload