Skip to content

Commit

Permalink
Merge pull request #28 from legrostdg/purescript-0.11
Browse files Browse the repository at this point in the history
Purescript 0.11
  • Loading branch information
eskimor authored May 3, 2017
2 parents 0ee0700 + cf4bafd commit 2029173
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
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

0 comments on commit 2029173

Please sign in to comment.