higherkindness / mu-haskell

Mu (μ) is a purely functional framework for building micro services.
http://higherkindness.io/mu-haskell/
Apache License 2.0
333 stars 19 forks source link

Optics: how do I use `record` with tuples with more than 3 elements? #343

Closed listx closed 1 year ago

listx commented 1 year ago

TL;DR:

req = record (a, b, c)

works but

req = record (a, b, c, d)

does not. What am I doing wrong?

I see that record only supports tuples of 0, 2 or 3 elements: https://github.com/higherkindness/mu-haskell/blob/920cbdcbb2ce062a3103a52ae326db813fe17817/core/optics/src/Mu/Schema/Optics.hs#L65-L90. The message I'm trying to construct has 4 elements in it (well, I only noticed this today because I added a new 4th field and now my code no longer compiles).

If limiting the flexibility of record to a max of 3 elements is working-as-intended, what options to I have? How can I construct a Term out of my record that has more than 3 fields?

listx commented 1 year ago

OK, apparently I just needed to use toSchema (src). Sorry for the noise.