servant-hateoas-0.3.0: HATEOAS extension for servant
Safe HaskellSafe-Inferred
LanguageGHC2021

Servant.Hateoas.Layer.Merge

Synopsis

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 #

Returns True iff the given list of Layers contains a Layer with the given API.

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'