natefaubion/purescript-typelevel-eval

Literals + reflection - could this library be useful for value level expression generation?

paluh opened this issue · 3 comments

paluh commented

I want to ask you about opinion because I'm not capable to answer it definitively myself (so it is quite probable that this is just stupid question ;-))

Let's assume that we have a layer of literals + some form of reflection for them (a very limited stub and discussion).
Let's say that I want to generate typelevel expression which evaluates to a literal with record of lenses literals for a given record and then I reflect it.
I think that we would not be able to use a generated value like this easily as a type for the reflected record won't be "known" and fields won't be easily accessible because of this: purescript/purescript#3242

Do you think that it is feasible? Do you think that there is a way to overcome somehow limitation from the issue linked above? Do you think that this approach can be useful and it is worth further exploration?

paluh commented

Or maybe if I "accumulate" constraints like Row.Cons I will be able to access these lenses at the end by using Record.get... I'm not sure.

paluh commented

It seems that it is feasible. Sorry for the spam ;-)

paluh commented

P.S.

I was able to build a working really ugly prototype for lenses generation thanks to your lib + purescript-literal + reflection:

https://github.com/paluh/purescript-literal/blob/master/test/Main.purs#L79