Comments (1)
That kind of looks like a nicer way of writing this:
case class Person(name: String, age: Int)
case class Student(name: String, age: Int, university: String)
def checkin[P](p: P)(using t: Transformer[P, Person]): IO[P] = {
val person = t.transform(p)
doTheStuff(person.name, person.age)
}
checkin(Student("Joe", 27, "Oxford")) // ok
checkin(Person("Bob", 21)) // ok
so I'd say it's not really in scope for ducktape
- what's more, I'm not sure if your proposed syntax is even possible without some type refinement astronautics or else the compiler won't able to tell you if p.name
is possible at all.
Or if you're feeling crazy enough (pseudo code, dunno if it works):
given [A, B](using t: Transformer[A, B]: Conversion[A, B] = t.transform
case class Person(name: String, age: Int)
case class Student(name: String, age: Int, university: String)
def checkin[P](p: P)(using Conversion[P, Person]): IO[P] =
doTheStuff(p.name, p.age)
from ducktape.
Related Issues (20)
- Support configuration options for fallible Coproducts
- Properly document auto-derivation of `Transformers` and `Transformer.Fallible` for coproducts HOT 1
- [0.2.0] allow configuration of nested products/coproducts
- Mapping field names based on a constant function HOT 4
- [0.2.0] Compiletime error accumulation
- Creating generic transformers HOT 5
- Package information in compilation error messages HOT 3
- Bad owners reported under `-Xcheck-macros` for Accumulating transformations of products with collections with other products containing fallible transformations
- Investigate and report a compiler crash when configuring `element` types in non-definition `Accumulating` transformations
- Bring back warnings for fields or cases that were configured multiple times
- Support tuple to product (and back) transformations
- traverseCollection is not working for Map after the migration to 0.2 HOT 2
- Misleading error message when trying to use `_.into.transform()` or `_.to` in a `given Transformer` definition HOT 2
- Allow F-unwrapping transformations HOT 1
- Make configurations more lens-like HOT 1
- Change in implicit resolution? HOT 7
- New `F-unwrapping` example would not work in Scala 3.4+ HOT 3
- Cannot transform from a non-widened tuple
- Macro crash due to implicit dependencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ducktape.