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 4004418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:16:16+00:00 2026-05-20T08:16:16+00:00

Referring to a previous answer of mine on stackoverflow The core of the complexity

  • 0

Referring to a previous answer of mine on stackoverflow

The core of the complexity is illustrated in just one method:

implicit def traversableToFilterOps[CC[X] <: Traversable[X], T]
(xs: CC[T])(implicit witness: CC[T] <:< TraversableLike[T,CC[T]]) =
  new MoreFilterOperations[CC[T], T](xs)

With two questions:

  1. Is there any way to give the compiler a hint that Map meets the signature CC[X] <: Traversable[X]?
    I would expect it to match as a Traversable[Tuple2[_,_]] but this doesn’t happen. In the end, I had to write a second method taking CC[KX,VX] <: Map[KX,VX], but that feels redundant

  2. witness: CC[T] <:< TraversableLike[T,CC[T]] also seems redundant given the first type parameter, my gut feeling is that this is enforced by the type of Traversable and must always hold true for any possible subclass or value of X, so there should be no reason to explicitly require it as a witness.

If I test this using an existential type in the REPL, then the compiler seems to agree with me:

scala> implicitly[Traversable[X] <:< TraversableLike[X,Traversable[X]] forSome { type X }]
res8: <:<[Traversable[X],scala.collection.TraversableLike[X,Traversable[X]]] forSome { type X } = <function1>

Is there therefore any way to do away with the boilerplate?

  • 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-05-20T08:16:17+00:00Added an answer on May 20, 2026 at 8:16 am

    I’m a Scala noob, so please don’t shoot me down if this doesn’t help.

    Assuming this:

    class MoreFilterOperations[Repr <% TraversableLike[T,Repr], T] (xs: Repr) {}
    

    Would something like this work?

    // t2fo is short for traversableToFilterOps
    implicit def t2fo[Repr <% TraversableLike[T, Repr], T](xs: Repr) = 
      new MoreFilterOperations[Repr, T](xs)
    
    // m2fo is short for mapToFilterOps
    implicit def m2fo[Repr <% Map[K, V] <% TraversableLike[(K,V), Repr], K, V]
      (xs: Repr) = new MoreFilterOperations[Repr, (K, V)](xs)
    

    This should work because (according to the book I have.. Programming Scala, p264) the following method definition with a view bound:

    def m [A <% B](arglist): R = ...
    

    It is effectively the same as this method definition:

    def m [A](arglist)(implicit viewAB: A => B): R = ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Referring to the first answer about python's bound and unbound methods here, I have
Referring to a previous question , i was wondering if its always possible to
I am referring to the information from my previous question which tells me in
Hello Referring to my previous question where I wanted a horizontal list: Remove extra
I am referring to my previous question but this time I used the java
Ok, referring back to my previous question, I am still working on learning haskell
Duplicate: Finding previous page Url How do I find the referring url that brought
I am referring Previous Post for storing NSURL of iPod Library in NSUserDefault. But
referring to my previous question at Unable to perform any action before Process.Runtime.exec statement
referring to my previous question I came accross to another problem. The div I

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.