Is it possible to do do polymorphic row (or record) projections in PureScript?

126 Views Asked by At

I'm curious if there is a polymorphic function like project below, or if it is possible to design such a function in PureScript:

type MyRecRow = (a :: Int, b :: String)

type MyRec = Record MyRecRow

type MyRecA = {a :: Int}

foo :: MyRec
foo = {a: 5, b: "bbb"}

bar :: MyRecA
bar = project(foo)

My current understanding suggestions this might be possible at the type level using things like Prim.Row's Cons and Lacks, and possibly something like purescript-heterogeneous for the implementation, though that is a bit beyond my currently fluency level with PureScript.

0

There are 0 best solutions below