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

  • Home
  • SEARCH
  • 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 8328251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:22:34+00:00 2026-06-09T01:22:34+00:00

I can define a function that accepts a Seq[Char] def f(s: Seq[Char]) = s

  • 0

I can define a function that accepts a Seq[Char]

def f(s: Seq[Char]) = s

and it works if I pass in a String:

scala> f("this")
res8: Seq[Char] = this

which means that I can use it in a map:

scala> List("this").map(s => f(s))
res9: List[Seq[Char]] = List(this)

So why can’t I do this?:

scala> List("this").map(f)
<console>:10: error: type mismatch;
 found   : Seq[Char] => Seq[Char]
 required: java.lang.String => ?
              List("this").map(f)
                               ^
  • 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-09T01:22:36+00:00Added an answer on June 9, 2026 at 1:22 am

    You can’t do that because there is no promotion of an implicit conversion A => B to F[A] => F[B]. In particular, f is actually an instance of type Seq[Char] => Seq[Char], and you would require that the implicit conversion from String => Seq[Char] would generate a function String => Seq[Char]. Scala doesn’t do two-step implicit conversions such as this.

    If you write s => f(s), Scala is free to fiddle with the types so that s is converted to Seq[Char] before being passed in to f.

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

Sidebar

Related Questions

One can easily define a function that accepts a 1d array argument like this:
In Python I can define a function as follows: def func(kw1=None,kw2=None,**kwargs): ... In this
Can I define a function which, when called, inserts new locals into the caller's
I have a function which accepts a parameter named IV. Is there anyway that
How can I define a function that will accept my type and return its
I know that when you define a function in vim, you can use the
I know that when you define a function in vim, you can use the
If I define a function which accepts an rvalue reference parameter: template <typename T>
If function accepts structural type, it can be defined as: def doTheThings(duck: { def
I want to define functions that can be used in the fixedpoint rule. For

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.