haskell - narrowing type of a vinyl record based on the lens/index chosen -
extensible records provided http://hackage.haskell.org/package/vinyl different other libraries (hlist , others grapefruit-records/records) provide. because result of lookup based on pair (result type, label)
, while other libraries have lookup based on label
only. example of happening vinyl:
{-# language datakinds, typeoperators #-} import data.vinyl r = fixrecord $ (field :: "x" ::: a) =: (3::double) <+> (field :: "x" ::: a) =: (2::int) main = print $ rget (field :: "x" ::: int) r print $ rget (field :: "x" ::: double) r -- prints 2\n3
for application http://hackage.haskell.org/package/rlang-qq, type of elements of record determined usage later on, seems need "x" uniquely determine value that's stored there.
i want avoid "redundant" type signature in expression
(rget (field :: "z" ::: [double]) (ans :: plainrec ("z" ::: [double] ': '[])))
and have more like:
(rget (field :: "z" ::: [double]) ans)
the whole code in http://code.haskell.org/~aavogt/rlang-qq/examples/test2.hs there way achieve using vinyl, or should adapt code use library?
vinyl changed have lookups based on label only. in meantime had changed rlang-qq use hlist.
Comments
Post a Comment