cvogt / compossible Goto Github PK
View Code? Open in Web Editor NEWScala Records: Extensible records and type-indexed maps
Home Page: https://www.youtube.com/watch?v=pA2js-TV1Ck
Scala Records: Extensible records and type-indexed maps
Home Page: https://www.youtube.com/watch?v=pA2js-TV1Ck
make sure that cases that aren't supposed to compile actually don't compile
I went through this: http://downloads.typesafe.com/website/presentations/ScalaDaysSF2015/T4_Vogt_Compossible.pdf
I've been looking a FP language with anonymous records. They are potentially immensely useful when dealing with SQL, as you pointed out in TODO.
I'm curious what is the status of this effort? Did you get the sense Scala itself could support this in future? Relaying on this feature in production would probably require some official support.
I wish Scala compiler was built like Roslyn (the compiler service of C#) so there wouldn't be holes in auto-completion.
Hi @cvogt,
I know you don't have much time for compossible atm, but maybe you could give me a hint on how one could destructure a TMap when using typeclasses.
I've put up an example project and the problematic case (it's only a few lines) is here:
https://github.com/nightscape/scala-destructure-tmap/blob/master/src/main/scala/TMapDeconstruction.scala
I'm trying to extract multiple keys out of a TMap and processing them with type-classes and had hoped I could split up a TMap[Int with String]
into an Int
and a String
in a generic way, but the compiler seems to split it up into a Int with String
and something else.
I would be happy even if you could just throw me some terms to search for, I don't even know what the correct term for the Int with String
part is...
Thanks a lot!
Martin
Record is covariant in its type parameter. Making it invariant and allowing conversions via an implicit would allow to throw out the lost fields in the underlying map.
currently there is &
which is a union operator on the key value pairs. The default should probably rather be a disjoint union that throws a type error in case of overlap.
Overview of useful operators that should be implemented
&
)|
&
r \ (select field1 & field2)
or r(remove field1 & field2)
orIs it worth changing the repo name itself from records to compossible?
https://oss.sonatype.org/content/repositories/snapshots/org/cvogt/ no longer appears to have this library present.
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.cvogt#compossible_2.11;0.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
(I enjoyed your scaladays SF presentation on this, btw)
Have you abandoned the project?
Something like
val p = person1(rename name to p1_name) & person3(rename name to p2_name)
p.p1_name
p.p2_name
However, while the .apply(rename.foo.(to).bar)
builder api works, but is a bit weird and probably impossible to get ide code completion without specialized ide support. But how else to refer to non-existing fields? Maybe not allow renames, but only remove and add, like
person1(remove name) & Record(p1_name = person1.name) & person2(remove name) & Record(p2_name = person2.name)
or
(person1(remove name).p1_name = person1.name) & (person2(remove name).p2_name = person2.name)
Still brainstorming about the api.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.