Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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 Layer
s, merges them into one list by combining all RelativeChildren
of Layer
s with the exact same API.
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 #
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 Layer
s contains a Layer
with the API of the given Layer
,
merge the first matching Layer
with the given Layer
by combining their RelativeChildren
.
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' |