I'm new to Purescript. I'm searching for an OAuth client and found this. I'm not sure how to build it, but this is what I've tried.
I've copied the source under the first project I've created following the getting started guide.
The first error when I pulp build
was
Error 1 of 3:
at src\Network\OAuth.purs:138:1 - 138:1 (line 138, column 1 - line 138, column 1)
Unable to parse module:
expecting indentation past column 1
which I fixed by commenting out the unfinished tokenByAuthorizationToken, right?
But then I'm getting
Error 1 of 3:
at src\Network\OAuth.purs:228:3 - 228:3 (line 228, column 3 - line 228, column 3)
Unable to parse module:
unexpected {
expecting data constructor name
How am I supposed to fix the following code (assuming all I've done up till now is fine... which I don't know either)?
data TokenEndpointSuccessResponse a =
{ access_token :: a -- See 7.1: Access Token Types
, token_type :: AccessTokenType
, expires_in :: Maybe Seconds -- recommended
, refresh_token :: Maybe RefreshToken
, scope :: Maybe AccessScope
}
I was looking at the documentation for types and syntax and I couldn't immediately spot the error (except what I'm writing next). In particular it seems a correct record definition, as per the language rule
PureScript records correspond to JavaScript objects. They may have zero or more named fields, each with their own types. For example:
{name :: String, greet :: String -> String }
corresponds to a JavaScript object with precisely two fields:name
, which is aString
, andgreet
, which is a function that takes aString
and returns aString
.
So I've done an experiment by adding a couple of lines before the error which are an extrapolation of the documentation for the data
keyword and from another question about the record type
data Foo a = Foo | Bar a
type ThreeStringProps = {prop1:: string, prop2:: string, prop3:: string}
and both the above lines compile fine and also the following
type Foo a = {foo :: Foo | bar :: Bar a}
so I guess I have to replace data
with type
, but does it make sense? The following fix seems to work (but I have other erros in other files of the code from github...)
type TokenEndpointSuccessResponse a = { access_token :: a -- See 7.1: Access Token Types
, token_type :: AccessTokenType
, expires_in :: Maybe Seconds -- recommended
, refresh_token :: Maybe RefreshToken
, scope :: Maybe AccessScope
}
Am I on right path anyway (to implement an OAuth client in Purescript)?