Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type safe value accessor methods to product types #83

Closed
fommil opened this issue Nov 7, 2017 · 3 comments
Closed

Add type safe value accessor methods to product types #83

fommil opened this issue Nov 7, 2017 · 3 comments

Comments

@fommil
Copy link
Contributor

fommil commented Nov 7, 2017

It would be good to have an accessor for products and coproducts.

Even better if there was a way to get a tuple / nested scalaz disjunction.

And for products, even better if there was a macro that allowed me to pass a Prod to a method that accepts X parameters 😄

@andyscott
Copy link
Member

  • For accessors to products, do you mean type safe indexed based accessors?

  • It would be reasonable to provide two/from tuple conversions for Prod for valid tuple arities.

  • What would that look like?

For the last point, consider:

def methodTakesManyParams(a: String, b: Double, c: Int): Foo = // ...
val prod = Prod[String :: Double :: Int :: TNil]("hi", 1.0, 100)

I don't think there's a way to support syntax such as

methodTakesManyParams(prod.expand)

The following may be possible, though:

prod.passTo(methodTakesManyParams)

@andyscott andyscott changed the title accessors Add type safe value accessor methods to product types Nov 7, 2017
@fommil
Copy link
Contributor Author

fommil commented Nov 7, 2017

prod.passTo sounds good! I don't really care about typesafe indexing (although that would be pretty cool if the index was passed as a constant!)... a .toTuple or something would be nice as a basic way to access, but maybe best not to add features that aren't needed.

@andyscott
Copy link
Member

I broke this out into #98 and #98 for the second and third bullet points.

@fommil fommil closed this as completed Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants