Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type family Normalize does not always reach fix point #12

Open
bruderj15 opened this issue Dec 24, 2024 · 1 comment
Open

Type family Normalize does not always reach fix point #12

bruderj15 opened this issue Dec 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bruderj15
Copy link
Owner

In Servant.Hateoas.Layer there is below type-family for normalizing an API to a shared prefix form:

type family Normalize api where
  Normalize ((prefix :> a) :<|> (prefix :> b)) = Normalize (prefix :> (Normalize a :<|> Normalize b))
  Normalize (a :<|> b)                         = Normalize a :<|> Normalize b
  Normalize ((prefix :> a) :>   (prefix :> b)) = Normalize (prefix :> (Normalize a :>   Normalize b))
  Normalize (a :> b)                           = a :> Normalize b
  Normalize a                                  = a

Normalize (a :<|> b) = Normalize a :<|> Normalize b may lead to a common prefix and therefore needs to be applied again.
However just applying Normalize (Normalize a :<|> Normalize b) obviously results in a loop.
We need a better way to apply Normalize until a fix-point is reached.

@bruderj15 bruderj15 added the bug Something isn't working label Dec 24, 2024
@bruderj15
Copy link
Owner Author

I wonder if we need the normalization at all.
We already apply MergeLayers from Servant.Hateoas.Layer.Merge which gets rid of the multiple Layers for the same endpoint problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant