Connecting a Haskell backend to a Purescript frontend using purescript-bridge - #46
Conversation
e357098 to
00be448
Compare
00be448 to
355c48b
Compare
c5fb021 to
a32c875
Compare
e0694c7 to
9288925
Compare
| @@ -0,0 +1,339 @@ | |||
| --- | |||
| title: Connecting a Haskell Backend to a Purescript Frontend | |||
There was a problem hiding this comment.
@javcasas According to the official page, the name is written as PureScript.
| --- | ||
| # Connecting a Haskell Backend to a Purescript Frontend | ||
| ## Introduction | ||
| At Stackbuilders we are working on a full-stack app with CollegeVine https://www.collegevine.com/ using functional languages. |
There was a problem hiding this comment.
@javcasas Could you replace Stackbuilders with Stack Builders please?
There was a problem hiding this comment.
I would suggest to also link the name to the web page like Stack Builders and CollegeVine wydt?
There was a problem hiding this comment.
Ok, I'm getting the hang of linking in Markdown
There was a problem hiding this comment.
Lots of links placed.
| # Connecting a Haskell Backend to a Purescript Frontend | ||
| ## Introduction | ||
| At Stackbuilders we are working on a full-stack app with CollegeVine https://www.collegevine.com/ using functional languages. | ||
| We have a Haskell backend, based on Servant, that manipulates the database and offers some endpoints to a Purescript frontend, |
There was a problem hiding this comment.
@javcasas Could we remove some commas here in order to make reading more fluid? What about:
We have a backend written in Servant that manipulates the database and offers some endpoints to a PureScript frontend ...
Also, I think would be nice to include some links to some of the packages you are referencing.
There was a problem hiding this comment.
Removed commas, preparing to link stuff
| --- | ||
| # Connecting a Haskell Backend to a Purescript Frontend | ||
| ## Introduction | ||
| At Stackbuilders we are working on a full-stack app with CollegeVine https://www.collegevine.com/ using functional languages. |
There was a problem hiding this comment.
@javcasas I noticed you capitalize Functional some paragraphs below. Maybe we want to keep some consistency. What about replacing functional languages with Functional languages or Functional Languages perhaps?
There was a problem hiding this comment.
Changed to Functional Languages, and in general Functional <capitalized word>
|
|
||
| ### Motivation | ||
| The problem is that we have two different codebases: one in Haskell and the other in Purescript. | ||
| The syntax is almost the same, but that small difference means we can't directly share files. |
There was a problem hiding this comment.
@javcasas I'm not sure what you are referring to on this statement but that small difference. I understand it has to be with Haskell and PureScript but maybe we need to be more explicit about what specific difference we are talking about.
There was a problem hiding this comment.
Examples of differences provided.
|
|
||
| ### The next best thing | ||
| Well, if we can't use the same files, we have to look for something not that far from that ideal world. | ||
| If we can somehow automatically generate the Purescript code from the Haskell code, |
There was a problem hiding this comment.
@javcasas what about:
If we can somehow automatically generate PureScript types from Haskell, we could prevent type mismatches.
You may notice that I replace code with types. That's because purescript-bridge description on Hackage mentioned:
Generate PureScript data types from Haskell data types.
So maybe we need to clarify that we are going to generate only types. What do you think?
There was a problem hiding this comment.
Changed from code to types.
|
|
||
| ### `purescript-bridge` to the rescue | ||
| Turns out this idea is not new, and Robert Klotzner has already done it for us, which is quite nice. | ||
| From the docs, purescript-bridge tells us it will write Purescript code from Haskell types, |
There was a problem hiding this comment.
@javcasas same here maybe we need to clarify that we are only going to generate types:
PureScript types from Haskell types
instead of:
Purescript code from Haskell types
There was a problem hiding this comment.
Changed to types again.
| But let's not talk about limitations. Instead, let's talk about awesomeness. But, before that, let's review the general architecture. | ||
|
|
||
| ## Simple WebApp | ||
| Our app will be split in two parts: |
There was a problem hiding this comment.
@javcasas split into two parts instead of split in two parts maybe?
| ## Simple WebApp | ||
| Our app will be split in two parts: | ||
| * A Haskell backend that talks to the database, coordinates people, sends emails and all that awesome stuff backends do. | ||
| * A Purescript frontend that compiles to Javascript and runs on the browser; |
There was a problem hiding this comment.
@javcasas please replace Javascript with JavaScript.
There was a problem hiding this comment.
Fixed across the document.
| * A Purescript frontend that compiles to Javascript and runs on the browser; | ||
| showing, in marvellous details using React, all the data that fetches from the backend. | ||
|
|
||
| The two parts have to talk to eachother in order to have something useful. |
There was a problem hiding this comment.
@javcasas each other instead of eachother perhaps?
|
Another question: the code is in my Github domain (github.com/javcasas). Shall I move it to StackBuilders? How do we do that? |
| --- | ||
| # Connecting a Haskell Backend to a PureScript Frontend | ||
| ## Introduction | ||
| At [Stack Builders](https://www.stackbuilders.com) we are working on a full-stack app with [CollegeVine](https://www.collegevine.com/) using Functional Languages. |
There was a problem hiding this comment.
Is it okay to disclose the company's name?.Just checking
There was a problem hiding this comment.
Mohan told Cynthia he was interested in the tutorial. I'll send the draft to him so he can decide if he wants his company to be included or not.
There was a problem hiding this comment.
Waiting for confirmation from the client in order to see if he wants us to name the company.
There was a problem hiding this comment.
Mohan approved the tutorial:
Looks great! I wouldn't say that I was worried you were going to say something negative,
but more that I wanted to see the tone and language of the article since we don't really talk about our engineering publicly. Overall we are happy to be part of this great discovery! :)
| we could prevent the problem of type difference. We would effectively extend the typesystem from the backend to the frontend. | ||
|
|
||
| ### `purescript-bridge` to the rescue | ||
| Turns out this idea is not new, and Robert Klotzner has already done it for us, which is quite nice. |
There was a problem hiding this comment.
Can yo reference Robert Klotzner with a link to his personal website of Twitter account?
|
BTW, you should add the code inside a code |
nebtrx
left a comment
There was a problem hiding this comment.
Ok, I'm going to request changes in order to remember you adding the code :)
|
|
||
| ### `purescript-bridge` to the rescue | ||
| Turns out this idea is not new, and Robert Klotzner has already done it for us, which is quite nice. | ||
| From the docs, [`purescript-bridge`](https://hackage.haskell.org/package/purescript-bridge) tells us it will write PureScript types from Haskell types, |
There was a problem hiding this comment.
@javcasas adding quotes to a link seems like a redundant emphasize. What do you think?
| bFoos :: [Foo] | ||
| } deriving (Generic) | ||
| ``` | ||
| Whereas if I want to get a Generic instance for my `Blah` type, in PureScript I have to do: |
There was a problem hiding this comment.
@javcasas Usually, tutorials are written using third person form. What do you think about rewriting this paragraph as follows:
Whereas, if we want to get a Generic instance for `Blah` type, in PureScript we have to do:
| @@ -0,0 +1,66 @@ | |||
| # This file was automatically generated by 'stack init' | |||
There was a problem hiding this comment.
could you remove all this boilerplate, please? :)
…sh://github.com/stackbuilders/tutorials into connecting_haskell_backend_to_purescript_frontend
|
Ok, I'm going to merge this to see how well does it look on Staging. |
No description provided.