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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:51:56+00:00 2026-05-13T16:51:56+00:00

I came across existential quantification over values in the Scala Language Specification (3.2.10 Existential

  • 0

I came across existential quantification over values in the Scala Language
Specification (3.2.10 Existential Types).

x: y.Inner forSome{val y : Outer}

Does someone have illustrative use cases for it?

T forSome {val x: S} is defined as T forSome { type t <: S with Singleton }. The Singletron trait is mentioned in the Specification (3.2.1 Singleton Types) but I could not find it in the Scaladoc. Where is it defined?

  • 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-13T16:51:56+00:00Added an answer on May 13, 2026 at 4:51 pm

    It is useful along with inner classes as alluded in the type names. See for example the Graph and Node classes defined in A Tour of Scala: Inner Classes. Existential quantification over a value is used to write the type of the nodes of some unspecified graph.

    type SomeNode = g.Node forSome { val g: Graph }
    

    This might be useful if you wanted to have a method that took two nodes as arguments that had to come from the same graph.

    def somethingWithTwoNodes[N <: g.Node forSome { val g: Graph }](n1: N, n2: N) = (n1,n2)
    

    Note that 2.7 will not accept that method definition because it thinks there’s some sort of recursion in N.

    Then if you have

    val g1 = new Graph
    val g2 = new Graph
    

    then these compile

    somethingWithTwoNodes(g1.newNode, g1.newNode)
    somethingWithTwoNodes(g2.newNode, g2.newNode)
    

    but these doesn’t

    somethingWithTwoNodes(g1.newNode, g2.newNode)
    somethingWithTwoNodes(g2.newNode, g1.newNode)
    

    As for the Singleton trait, it’s not really defined in the typical way, i.e. there isn’t a class file for it. It’s like the types Any, AnyVal, AnyRef and Null. It is defined in src/compiler/scala/tools/nsc/symtab/Definitions.scala along with these other types, but I doubt that is very useful information to have. It’s also an odd beast being a final trait which means you can’t mix it in when defining a trait or class, it’s really more of a marker that the compiler ascribes to a type to say that it is unique from any other type.

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

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can only synchronize threads within a single blocks. It… May 14, 2026 at 6:11 pm
  • Editorial Team
    Editorial Team added an answer There is no guaranteed behavior for what happens when add… May 14, 2026 at 6:11 pm
  • Editorial Team
    Editorial Team added an answer Actually I tend to err on the side of passing… May 14, 2026 at 6:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.