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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:54:28+00:00 2026-06-07T07:54:28+00:00

I want to make my Scala code more readable, so I added custom types

  • 0

I want to make my Scala code more readable, so I added custom types for all parametrized types.

So I have in package object, for simplicity,

type IntSeq = Seq[Int]

However, now I cannot do simple apply on companion object. From REPL:

scala> IntSeq(1, 2, 3)
<console>:8: error: not found: value IntSeq
              IntSeq(1, 2, 3)
              ^

What to do?

(just to make sure: my actual aliased objects are more complicated than Seq[Int])

edit: There is a similar question – Scala type alias including companion object [beginner]

On that question, there are two replies, both of them not working.

One is to define my custom object with apply, but I am not sure how to do that in my case, plus it is a little verbose.

The other – to write val IntSeq = Seq produces the error

warning: previously defined trait Seq is not a companion to value IntSeq.
Companions must be defined together; you may wish to use :paste mode for this.

  • 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-07T07:54:29+00:00Added an answer on June 7, 2026 at 7:54 am

    The second error is just because of the way REPL operates. In REPL, the companions must be defined together using the :paste mode; however, in the package object, that is not an issue.

    So, the other approach – to write val IntSeq = Seq – will actually work.

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

Sidebar

Related Questions

I have some Scala code roughly analogous to this: object Foo { val thingA
I want to write a code to make a fairy fly all around screen
I have style sheet with a class name changebackgroundcolor i want make change in
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have uploaded a app in production mode to linode. I want make changes
I want to make my Azure web role scalable in a self-contained manner. All
I have a number of operands of different types and want to define how
(sort of followup to How to make a code thread safe in scala? )
Newbie Scala Question: Say I want to do this [Java code] in Scala: public
In Play 2.0, with Scala, I want to make a factory that takes an

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.