fcf-composite: Type-level computation for composite using first-class-families.

[ composite, library, mit, types ] [ Propose Tags ]

Type-level computation for composite using first-class-families.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0
Change log ChangeLog.md
Dependencies 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) [details]
License MIT
Copyright Daniel Firth
Author Daniel Firth
Maintainer dan.firth@homotopic.tech
Revised Revision 1 made by locallycompact at 2021-08-27T10:14:01Z
Category Composite, Types
Source repo head: git clone https://gitlab.homotopic.tech/haskell/fcf-composite
Uploaded by locallycompact at 2021-08-26T07:32:09Z
Distributions NixOS:0.1.1.0
Downloads 152 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-08-26 [all 1 reports]

Readme for fcf-composite-0.1.1.0

[back to package description]

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.