Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8967691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:18:06+00:00 2026-06-15T17:18:06+00:00

Forgive me if this question is a duplicate; I’m having trouble finding anything because

  • 0

Forgive me if this question is a duplicate; I’m having trouble finding anything because I don’t know the right words to search. So, with implicit def, I can do things like this:

type CharsetMap = Map[Charset, Byte]

implicit def seqtup2CharsetMap(input: Seq[(String, Int)]): CharsetMap = {
  Map.empty  // placeholder
}

def somef(a: Int, b:Int, p: CharsetMap) = p
somef(1, 3, Seq(("hey", 2), ("there", 9)))

which lets me call somef with a Seq[(String, Int)] object as a parameter. The problem is that I have something like this…

def somef2(p: (CharsetMap) => Int) = p

and this does not work:

val p = (a: Seq[(String, Int)]) => 19
somef2(p)

How can I do this without doing an implicit def specifically for (Seq[(String, Int)]) => Int?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:18:07+00:00Added an answer on June 15, 2026 at 5:18 pm

    It looks like you want to implicitly convert some function A => B to a function that goes from C => B. You can do that with this generic implicit:

    implicit def f2InputConverter[A, B, C](f: A => B)(implicit i: C => A): C => B = (c: C) => f(i(c))
    

    Once you have that in scope, in your particular case, you’ll need an implicit function which is the inverse of the one that you’ve defined in the question:

    implicit def charsetMap2Seqtup(input: CharsetMap): Seq[(String, Int)] = {
      Nil  // placeholder
    }
    

    and then you should be able to call somef2 with p

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, forgive me if this is a duplicate question. I don't know anything
Forgive me if this is a repeated question but I am having trouble finding
OKay gang, forgive me if this question is ubernoobness, but i am having trouble
Forgive a newbie, I don't even know how to ask this question properly: I
Forgive this super basic question, from a search newbie. I want to implement a
Forgive the duplicate question. I'd like to see this solved in Emacs Lisp too,
Forgive if this question is silly. I just started reading the SugarCRM developer documentation
Forgive me if this question has been asked before but I am new to
This is my first Bash script so forgive me if this question is trivial.
Please forgive the simplicity of this question. The answer will be obvious to many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.