How to pass a function with implicit argument to a high-order function with full type signature (A => I => B)?

74 views
Skip to first unread message

Jianshi Huang

unread,
Nov 17, 2014, 2:35:13 AM11/17/14
to scala...@googlegroups.com
I need to write a function that converts a function that takes an implicit argument of I to a function that takes an implicit argument of K (where I can be implicitly converted from K).

So the function type signature looks like:

  lift[A, B, I, K <% I](f: A => I => B): A => K => B

However, when I write

  lift(fn)

Scala reports "Could not find implicit value for fn ..."

Will Scala automatically curry fn to A => B by applying the implicit argument? How can I achieve my goal then?

Thanks
--
Jianshi Huang

LinkedIn: jianshi
Twitter: @jshuang
Github & Blog: http://huangjs.github.com/

Naftoli Gugenheim

unread,
Nov 17, 2014, 5:10:22 PM11/17/14
to Jianshi Huang, scala...@googlegroups.com
Can you show fn?

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jianshi Huang

unread,
Nov 17, 2014, 5:46:13 PM11/17/14
to Naftoli Gugenheim, scala...@googlegroups.com
Sure.

  def fn(id: String)(implicit qe: GraphQueryExecutor): Int = {
    ...
  }


Jianshi

Stephen Compall

unread,
Mar 2, 2015, 7:21:35 AM3/2/15
to Jianshi Huang, scala...@googlegroups.com
On Mon, 2014-11-17 at 15:34 +0800, Jianshi Huang wrote:
> lift[A, B, I, K <% I](f: A => I => B): A => K => B
>
> However, when I write
>
> lift(fn)
>
> Scala reports "Could not find implicit value for fn ..."
>
> Will Scala automatically curry fn to A => B by applying the implicit
> argument? How can I achieve my goal then?

No, I don't think this will infer.


--
Stephen Compall
"^aCollection allSatisfy: [:each|aCondition]": less is better
signature.asc
Reply all
Reply to author
Forward
0 new messages