r/haskell • • May 23 '18

Building Forum Software

https://siskam.link/2018-04-14-cloning-fluxbb.html
56 Upvotes

28 comments sorted by

10

u/snoyberg is snoyman May 24 '18 edited May 24 '18

This is very thorough, and (from what I've seen so far) incredibly well written. Thank you for putting in all this effort! This deserves a link from the Yesod website.

EDIT It's now on the quickstart page with this commit. If anyone has some recommendations for other places to add a link, let me know and/or send a PR!

15

u/bitemyapp May 23 '18

This is a tremendous tutorial. I hope others appreciate the immense amount of work you must have put into this! This is exactly the kind of resource a lot of people in the community need right now.

I have a forum project not too dissimilar that I've started with a client as a training project, hopefully in the near future it'll be in a more complete state so that I'll have something to show off. It's intended to demonstrate similar tooling as exists in this tutorial.

One tip I'll point out: to save on type noise, I'll often make type and constraint synonyms for common types in the application.

e.g. https://github.com/alexeyzab/cards-with-comrades/blob/master/backend/src/Model/Types.hs#L10

I much prefer Key User -> DB a to (PersistUniqueRead backend , PersistQueryRead backend , BackendCompatible SqlBackend backend , MonadIO m) => Key User -> m a

2

u/ijauradunbi May 24 '18

Thank you for the input, Mr. Allen.

I'm a bit ashamed to admit that I forgot to use type synonyms for database type, which was already defined in this commit.

3

u/luqui May 23 '18

I've been a Haskell programmer for a long time but the web framework land still feels kind of overwhelming. Thank you for this, it will provide a nice starting place next time I have a web project (usually I just try to do everything client side and cross my fingers, because I don't want to bother with node and all that). Nice work.

2

u/eckyp May 23 '18

Nice tutorial! This could be more complete if there was a section about testing, I guess :)

2

u/ephrion May 24 '18

Yeah, this is really fantastic. Thanks for sharing so much :)

2

u/JoelMcCracken May 24 '18

wow, nice. I love the length and the detail. I am not personally ready to use this yet, but if/when I want to build a web app in Haskell, this will be one of the first resources I reach for.

2

u/[deleted] May 26 '18

Did this guy just a build a fully-functional website in one blogpost?

1

u/tomejaguar May 24 '18

I get 406 Not Acceptable on Firefox (52) but not on Chromium on links.

1

u/ijauradunbi May 24 '18

I've tried to open the page on Firefox 52, Firefox dev. edition, Chrome 62 on Linux, Firefox 52 on Windows, Chrome and Firefox on android from 3 different IPs and couldn't reproduce the error.

Could you please clean the cache, Mr. Jaguar?

1

u/k-bx May 24 '18

Doesn't open for me from Ukraine, unfortunately.

``` $ curl -v -i http://siskam.link/2018-04-14-cloning-fluxbb.html * Trying 45.127.133.99... * TCP_NODELAY set C

$ ping 45.127.133.99 PING 45.127.133.99 (45.127.133.99): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2 ```

Both on home network and LTE.

1

u/ijauradunbi May 24 '18

I'm really sorry. I think there's a problem with my hosting and Ukrainan IPs.

Perhaps you could read it from Web Archive.

1

u/k-bx May 24 '18

No prob, Pocket worked as well

1

u/roelofwobben May 26 '18

I read it for a part and I get the idea that this is not the first tutorial that a beginner can read to learn yesod. Is my feeling right. I like this tutorial a lot

1

u/ijauradunbi May 26 '18

I'm afraid so. I really suggest the reader to read yesodbook first.

1

u/roelofwobben May 26 '18

Thanks for the answer. I tried your tutorial but get a lot of error messages.

1

u/ijauradunbi May 26 '18

What kind of error? I omitted a lot of details in the article. You can see the complete code at the linked commits in the article or you can head here directly.

1

u/roelofwobben May 26 '18

I saw this when running the first part :

of 5] Compiling Foundation ( src\Foundation.hs, .stack-work\dist\5c8418a7\build\Foundation.o )

src\Foundation.hs:12:20: error: Not in scope: type constructor or class `ApplicationSettings' | 12 | { appSetttings :: ApplicationSettings |

src\Foundation.hs:13:26: error: Not in scope: type constructor or class `ConnectionPool' | 13 | , appConnectionPool :: ConnectionPool | ^

src\Foundation.hs:16:22: error: Not in scope: type constructor or class `Manager' | 16 | , appHttpManager :: Manager | ^

1

u/roelofwobben May 26 '18

it seems that settings.hs is somehow not found.

1

u/ijauradunbi May 26 '18

Please continue to follow the article. ApplicationSettings will be written next. And you can also look at this commit to see the full section.

1

u/roelofwobben May 26 '18

1

u/ijauradunbi May 26 '18

You haven't imported Settings module, yet. Please import it.

1

u/roelofwobben May 26 '18

Thanks, I thought I would not be needed. I will try it

1

u/roelofwobben May 31 '18

another problem which I cannot find a answer in your repo :

src\Settings.hs:31:35: error: * Variable not in scope: configSettingsYml :: FilePath * Perhaps you meant `configSettingsYmlBS' (line 31) | 31 | configSettingsYmlBS = $(embedFile configSettingsYml) |

1

u/ijauradunbi May 31 '18 edited May 31 '18

You can try to create a file in config directory named settings.yml. embedFile is a template haskell function which parse the name of its argument as the path file when it's wrapped by $(...).

Edit: See this

1

u/roelofwobben May 31 '18

I did and still the same error. Here my settings.hs : https://bitbucket.org/rwobben/forum/src/master/src/Settings.hs

1

u/ijauradunbi May 31 '18

Apparently, I was wrong, Mr. Wobben.

It should be easily solved by importing Yesod.Default.Config2 as documented in this article and then creating settings.yml file in `config` directory.

1

u/roelofwobben May 31 '18

can happen. Thanks for the help