<div dir="ltr">Hello, cafe!<div><br></div><div>I made a small library <a href="https://github.com/odr/pers">https://github.com/odr/pers</a>. It is my attempt for Named Record problem.</div><div>There is no TH, just TF, Symbols and so on.</div><div><br></div><div>With this library one can now:</div><div><div><br></div><div>* Construct record sequentially (record is balanced tuple-based tree):</div><div>type T = "a":>Int +> "b":>String +> "c":>Maybe Int</div><div>rec = V 5 +> V "b" +> V (Just 3) :: T</div><div><br></div><div>* Get Lens' for fields or record (group of fields) with O(k*log n) access:</div><div>lb = fieldLens (Proxy :: "b":>String) :: Lens' T String</div><div>lca = recLens :: Lens' T ("c:>Maybe Int +> "a":>Int)</div><div><br></div><div>Note that recLens is Projection!</div><div><br></div><div>* Lift all fields into Functor:</div><div>type LT = Lifted Maybe T</div><div>-- LT == "a":>Maybe Int +> "b":>Maybe String +> "c":>Maybe (Maybe Int)</div><div><br></div><div>If all fields has Default instances, record has it also. It is the case for Lifted Maybe T.</div><div><br></div><div>* Convert from and to Map of fields (using PersistField and PersistValue from persistent package)</div><div>m = M.fromList  [ (someSymbolVal "a", toPersistValue 1)</div><div>                , (someSymbolVal "b", toPersistValue "xx")</div><div>                -- value for "c" is optional</div><div>                ]</div><div>recEither = mapToRec (Proxy :: Proxy T) m :: Either [SomeSymbol] T</div><div>m' = fmap toMap recEither</div></div><div><br></div><div><br></div><div>I wonder:</div><div><br></div><div>- Are there similar attempts?</div><div>- Is it interesting? I suppose it could be used as basis for Persistent (instead of TH). Is it? Other application? </div><div>- What other features you want to add here? </div><div><br></div><div>Best regards,</div><div>Dmitry Olshansky</div></div>