There is no TH, just TF, Symbols and so on.
* 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
- Is it interesting? I suppose it could be used as basis for Persistent (instead of TH). Is it? Other application?