Yet Another Named Record

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