@hackage fcf-composite0.1.1.0
Type-level computation for composite using first-class-families.
Categories
License
MIT
Maintainer
dan.firth@homotopic.tech
Links
Versions
Installation
Dependencies (5)
- base >=4.7 && <5
- composite-base >=0.7.0.0 && <0.8
- fcf-containers >=0.5.0 && <0.7
- first-class-families >=0.8.0.0 && <0.9
- vinyl >=0.13.0 && <0.14 Show all…
Dependents (0)
fcf-composite
first-class-families support for composite records. This gives bidirection between a composite
style [s :-> a] and MapC s a from
fcf-containers.
Using this we can compute record types via the Map operations in Fcf.
data Difference :: [Type] -> [Type] -> Exp [Type]
type instance Eval (Difference xs ys) = Eval (ToComposite =<< Fcf.Data.MapC.Difference (Eval (FromComposite xs)) (Eval (FromComposite ys)))
type A = ["a" :-> Int, "b" :-> String, "c" :-> ()]
type B = ["a" :-> Int, "c" :-> ()]
myRec :: Record (Eval (Difference A B))
myRec = "foo" :*: RNil -- checks!
Note: The ordering of the fields is predictable, but not obvious and commutations matter, so you may need to use rcast liberally.