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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:07:09+00:00 2026-06-05T19:07:09+00:00

I’m trying to use shapeless to accumulate easily objects in a type safe manner.

  • 0

I’m trying to use shapeless to accumulate easily objects in a type safe manner.

The problem is when I want to concat (:::) two HList. I’m encountering a newbie (it seems at least) problem. It misses a Prepend implicit instance in the context.

However, looking into hlist.scala, I can see that generic implicit def are defined in the objects Prepend and PrependAux.

Adding import Prepend and import PrependAux manually didn’t change anything (obviously…).

So here the code reduced to the minimum:

enter code here

import shapeless._
import HList._
import Prepend._
import PrependAux._

object test {

  val a:HList = 1 :: 4 :: "A" :: HNil
  val b:HList = "R" :: false :: HNil

  val c:HList = a ::: b   // <<<<<<<<<<< NEEDS A Prepend in the context 

}

In the console now:

[error]     test.scala:10: could not find implicit value for parameter prepend: shapeless.Prepend[shapeless.HList,shapeless.HList]
[error]     val c:HList = a ::: b   // this needs an implicit Prepend in the current context

What should burn my eyes?

thanks

EDIT

A little update to re-complexify a bit the real problem, because to vulgarization was to strong before.

Here is the kind of thing that I would be able to do:

case class A[L<:HList](a:L) { 
  def doSmth[C <:HList](c:C) = a ::: c 
}

So I’ve not the access to the real type, only I know that they are HList s.

  • 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-05T19:07:10+00:00Added an answer on June 5, 2026 at 7:07 pm

    The up-casts to HList are the problem here. There’s almost nothing you can do with a plain old HList (apart from adding new elements to it).

    You can either provide more informative type annotations:

    val a: Int :: Int :: String :: HNil = 1 :: 4 :: "A" :: HNil
    val b: String :: Boolean :: HNil = "R" :: false :: HNil
    val c: Int :: Int :: String :: String :: Boolean :: HNil = a ::: b
    

    Or just let the types be inferred, which is usually much more convenient:

    val a = 1 :: 4 :: "A" :: HNil
    val b = "R" :: false :: HNil
    val c = a ::: b
    

    In response to your comment: you can do what you want if you make sure you’ve got the evidence you need (note that I’ve assumed that a: A was a typo for a: L, and that you’ll need -Ydependent-method-types for this to work):

    case class A[L <: HList](a: L) {
      def doSmth[C <: HList](c: C)(implicit p: Prepend[L, C]) = a ::: c
    }
    

    In general you can just look at the implicits that are necessary for the operations you’re using, and then include them on your method.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.