packages feed

servant-flatten 0.1 → 0.2

raw patch · 3 files changed

+14/−10 lines, 3 files

Files

README.md view
@@ -34,5 +34,5 @@ Get '[JSON] [String] ``` -See the documentation of `flatten` in `src/Servant/API/Flatten.hs`-for more explanations and some examples.+See the documentation of `flatten` in `Servant.Flatten`+for more.
servant-flatten.cabal view
@@ -1,5 +1,5 @@ name:                servant-flatten-version:             0.1+version:             0.2 synopsis:            Utilities for flattening servant API types description:         Utilities for flattening servant API types                      .@@ -15,7 +15,7 @@ build-type:          Simple extra-source-files:  ChangeLog.md, README.md cabal-version:       >=1.10-tested-with:         GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1+tested-with:         GHC == 8.0.2, GHC == 8.2.2  source-repository head   type:     git
src/Servant/API/Flatten.hs view
@@ -69,7 +69,7 @@ flatten Proxy = Proxy  -- | Flatten and transform the API type a little bit.-type Flat api = Reassoc (Flatten (Reassoc (Flatten api)))+type Flat api = Reassoc (Flatten api) -- looks like Flatten/Reassoc are missing some opportunities the first time, -- so we apply them twice for now... @@ -87,11 +87,15 @@   Redex a a first = Flatten first :> a   Redex a b first = Flatten (first :> b) --- | Reassociates '(:<|>)' to the right.-type family Reassoc api where-  Reassoc ((a :<|> b) :<|> c) = Reassoc a :<|> Reassoc (b :<|> c)-  Reassoc (a :<|> b) = a :<|> Reassoc b-  Reassoc a = a+-- | Reassociates ':<|>' to the right.+type Reassoc api = ReassocBranch api '[]++-- | Helper type family that "enumerates" the different endpoints left+--   to right.+type family ReassocBranch (currentAPI :: *) (otherEndpoints :: [*]) where+  ReassocBranch (a :<|> b)        rest = ReassocBranch a (b ': rest)+  ReassocBranch a                  '[] = a+  ReassocBranch a          (b ': rest) = a :<|> ReassocBranch b rest  -- * Utilities that we can define on a flat representation