Coder Social home page Coder Social logo

Comments (9)

nightscape avatar nightscape commented on May 18, 2024

Ok, to answer my last question: The correct term seems to be intersection types.

from compossible.

cvogt avatar cvogt commented on May 18, 2024

Well, I called them intersection types in my talk, but that is actually not the entire story, because sub-typing applies as well.

Looking at your code, I don't remember if I tried that, but I doubt the compiler would support something like this where you split up the type. You should be able to do that with (more) macros. Either directly, or by implementing a shapeless LabelledGeneric instance for TMaps as a macro, and then allow you to use shapeless' tooling to recurse over the keys and produce shows for them. There are macros that operate on the sets of keys here: https://github.com/cvogt/compossible/blob/tmp/0.2/src/main/scala/TMap.scala#L125

from compossible.

nightscape avatar nightscape commented on May 18, 2024

Ok, I'll try my luck with macros then. Maybe it's even something that can be contributed back to compossible as PR.

from compossible.

cvogt avatar cvogt commented on May 18, 2024

sure :)! I want to get back to compossible eventually myself. But my free time is currently occupied by the things I'll talk about at nescala and the typelevel summit.

from compossible.

Ciantic avatar Ciantic commented on May 18, 2024

@nightscape did you also look at https://github.com/scala-records/scala-records/ if compossible is merged, like it may be scala-records/scala-records#112 Scala could have a single good Record library.

I think having defacto Record library would make Scala amazing language, right now I think lack of Record library makes a difference in other frameworks. I know that developer of http://getquill.io/ wanted initially to implement own Record like DSL but thought it would be too much to learn, if Scala had records maybe it would be using it instead.

I really want to have a SQL library with a Record support in it's core, after all SQL is all about records.

from compossible.

nightscape avatar nightscape commented on May 18, 2024

@Ciantic I had a look at scala-records and it looks very nice in fact. For my specific use case though a type-indexed map is the perfect fit 👍

from compossible.

cvogt avatar cvogt commented on May 18, 2024

@nightscape Another idea: You may be able to implement something like TMap on top of shapeless encoding the included types as an HList, which does allow element-wise extraction.

from compossible.

nightscape avatar nightscape commented on May 18, 2024

I thought about that, too. But would that allow me to extract types in arbitrary order?
For type class instances that require more than one parameter from the map I can't guarantee that they were added to the HList in the corresponding order.

from compossible.

cvogt avatar cvogt commented on May 18, 2024

if shapeless hlists have some kind of contains operation, it should work. you'd need to ask for each of the parameters separately if they are contained

from compossible.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.