rest-gen 0.16 → 0.16.0.1
raw patch · 3 files changed
+15/−7 lines, 3 filesdep ~semigroupsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: semigroups
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−1
- rest-gen.cabal +2/−2
- src/Rest/Gen/Haskell.hs +6/−4
CHANGELOG.md view
@@ -1,6 +1,12 @@ # Changelog -#### 0.16+#### 0.16.0.1++* Fix a bug where the generated Haskell client for a resource with a+ name that was a Haskell keyword would contain invalid code.+* Relax bounds on semigroups.++## 0.16 You don't have to regenerate clients for this release, but it is strongly recommended!
rest-gen.cabal view
@@ -1,5 +1,5 @@ name: rest-gen-version: 0.16+version: 0.16.0.1 description: Documentation and client generation from rest definition. synopsis: Documentation and client generation from rest definition. maintainer: code@silk.co@@ -65,7 +65,7 @@ , process >= 1.0 && < 1.3 , rest-core >= 0.31 && < 0.34 , safe >= 0.2 && < 0.4- , semigroups == 0.15.*+ , semigroups >= 0.5.0 && < 0.16 , scientific >= 0.3.2 && < 0.4 , split >= 0.1 && < 0.3 , tagged >= 0.2 && < 0.8
src/Rest/Gen/Haskell.hs view
@@ -188,7 +188,7 @@ (responseHaskellType errorI)) (responseHaskellType output))] qualIdent (H.Ident s)- | s == res = H.TyCon $ H.UnQual tyIdent+ | s == cleanHsName res = H.TyCon $ H.UnQual tyIdent | otherwise = H.TyCon $ H.Qual (H.ModuleName $ modName s) tyIdent qualIdent H.Symbol{} = error "Rest.Gen.Haskell.mkFunction.qualIdent - not expecting a Symbol" inp | Just i <- mInp@@ -247,7 +247,7 @@ [] -> ac (LResource r : a@(LAccess _) : xs) | not (hasParam a) -> urlParts res xs (rlnk ++ [H.List [H.Lit $ H.String r]], pars)- | otherwise -> urlParts res xs (rlnk', pars ++ [H.Ident r])+ | otherwise -> urlParts res xs (rlnk', pars ++ [H.Ident . cleanHsName $ r]) where rlnk' = rlnk ++ (H.List [H.Lit $ H.String $ r] : tailed) tailed = [H.App (useMQual qual $ H.Ident "readId") (use $ hsName (cleanName r))]@@ -316,9 +316,11 @@ hsName :: [String] -> H.Name hsName [] = H.Ident ""-hsName (x : xs) = H.Ident $ clean $ downFirst x ++ concatMap upFirst xs+hsName (x : xs) = H.Ident $ cleanHsName $ downFirst x ++ concatMap upFirst xs++cleanHsName :: String -> String+cleanHsName s = if s `elem` reservedNames then s ++ "_" else s where- clean s = if s `elem` reservedNames then s ++ "_" else s reservedNames = ["as","case","class","data","instance","default","deriving","do" ,"foreign","if","then","else","import","infix","infixl","infixr","let"