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

Purescript 0.11 #28

Merged
merged 4 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Servant/PureScript/CodeGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ genGetReaderParams = stack . map (genGetReaderParam . psVar . _pName)


genSignature :: Text -> [PSType] -> Maybe PSType -> Doc
genSignature = genSignatureBuilder $ "forall eff m." <+/> "(MonadAsk (SPSettings_ SPParams_) m, MonadError AjaxError m, MonadAff ( ajax :: AJAX | eff) m)" <+/> "=>"
genSignature = genSignatureBuilder $ "forall eff m." <+/> "MonadAsk (SPSettings_ SPParams_) m => MonadError AjaxError m => MonadAff ( ajax :: AJAX | eff) m" <+/> "=>"

genSignatureBuilder :: Doc -> Text -> [PSType] -> Maybe PSType -> Doc
genSignatureBuilder constraint fnName params mRet = fName <+> "::" <+> align (constraint <+/> parameterString)
Expand Down Expand Up @@ -121,7 +121,7 @@ genFnBody rParams req = "do"
</> ", headers =" <+> "defaultRequest.headers <> reqHeaders"
</> case req ^. reqBody of
Nothing -> "}"
Just _ -> ", content =" <+> "toNullable <<< Just <<< printJson <<< encodeJson $ reqBody" </> "}"
Just _ -> ", content =" <+> "toNullable <<< Just <<< stringify <<< encodeJson $ reqBody" </> "}"
)
</> "affResp <- affjax affReq"
</> "getResult affReq decodeJson affResp" <> line
Expand Down
9 changes: 4 additions & 5 deletions src/Servant/PureScript/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,16 @@ defaultSettings = Settings {
, _standardImports = importsFromList
[ ImportLine "Control.Monad.Reader.Class" (Set.fromList [ "class MonadAsk", "ask" ])
, ImportLine "Control.Monad.Error.Class" (Set.fromList [ "class MonadError" ])
, ImportLine "Control.Monad.Aff.Class" (Set.fromList [ "class MonadAff", "liftAff" ])
, ImportLine "Control.Monad.Aff.Class" (Set.fromList [ "class MonadAff" ])
, ImportLine "Network.HTTP.Affjax" (Set.fromList [ "AJAX" ])
, ImportLine "Global" (Set.fromList [ "encodeURIComponent" ]) -- from package globals
, ImportLine "Data.Nullable" (Set.fromList [ "Nullable()", "toNullable" ])
, ImportLine "Servant.PureScript.Affjax" (Set.fromList [ "defaultRequest", "affjax", "AjaxError(..)" ])
, ImportLine "Data.Nullable" (Set.fromList [ "toNullable" ])
, ImportLine "Servant.PureScript.Affjax" (Set.fromList [ "AjaxError", "defaultRequest", "affjax" ])
, ImportLine "Servant.PureScript.Settings" (Set.fromList [ "SPSettings_(..)", "gDefaultToURLPiece" ])
, ImportLine "Servant.PureScript.Util" (Set.fromList [ "encodeListQuery", "encodeURLPiece", "encodeQueryItem", "getResult", "encodeHeader" ])
, ImportLine "Prim" (Set.fromList [ "String" ]) -- For baseURL!
, ImportLine "Data.Argonaut.Generic.Aeson" (Set.fromList [ "encodeJson", "decodeJson" ]) -- Should not be necessary - compiler bug!
, ImportLine "Data.Maybe" (Set.fromList [ "Maybe(..)"])
, ImportLine "Data.Argonaut.Printer" (Set.fromList [ "printJson" ])
, ImportLine "Data.Argonaut.Core" (Set.fromList [ "stringify" ])
]
, _generateSubscriberAPI = False
}
Expand Down
2 changes: 1 addition & 1 deletion src/Servant/PureScript/MakeRequests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ genFnBody rParams req = "do"
</> ", httpQuery:" <+> "reqQuery"
</> ", httpBody:" <+> case req ^. reqBody of
Nothing -> "\"\""
Just _ -> "printJson <<< encodeJson $ reqBody"
Just _ -> "stringify <<< encodeJson $ reqBody"
</> "}")
</> "pure spReq"
) <> "\n"
Expand Down
2 changes: 1 addition & 1 deletion stack-8.0.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-8.5
resolver: lts-8.12
packages:
- '.'
- './examples/central-counter'
Expand Down