| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Servant.Hateoas.Layer.Merge
Synopsis
- type family MergeLayers ls acc where ...
- type family ContainsLayerApi ls api where ...
- type family WithAllChildrenOfLayerApi ls l where ...
Merge
type family MergeLayers ls acc where ... Source #
Given two lists of Layers, merges them into one list by combining all RelativeChildren of Layers with the exact same API.
Equations
| MergeLayers '[] acc = acc | |
| MergeLayers (l ': ls) acc = MergeLayers ls (If (ContainsLayerApi acc (LayerApiCs l)) (WithAllChildrenOfLayerApi acc l) (l ': acc)) |
Utilities
type family ContainsLayerApi ls api where ... Source #
Equations
| ContainsLayerApi '[] _ = 'False | |
| ContainsLayerApi ('Layer api _ _ ': ls) api = 'True | |
| ContainsLayerApi (_ ': ls) api = ContainsLayerApi ls api |
type family WithAllChildrenOfLayerApi ls l where ... Source #
If a list of Layers contains a Layer with the API of the given Layer,
merge the first matching Layer with the given Layer by combining their RelativeChildren.
Equations
| WithAllChildrenOfLayerApi '[] _ = '[] | |
| WithAllChildrenOfLayerApi ('Layer api cs verb ': ls) ('Layer api cs' verb) = 'Layer api (cs ++ cs') verb ': ls | |
| WithAllChildrenOfLayerApi (l ': ls) l' = l ': WithAllChildrenOfLayerApi ls l' |