Help - I'm completely lost with building a really simple app with Snap and Groundhog

Hi, I am learning Haskell by trying to implement a really simple CRUD like web app with Snap and Groundhog - and I'm completely lost, cannot get it to work. The relevant code is here: https://github.com/matthiasbeyer/rate.hs/tree/restart_clean What the app should be able to do: - CRUD Categories, where a category can have several subcategories or Ratings - CRUD Ratings, where a rating has a title, a description and, of course, a rating (something like a number from 0-10) That's it. Backend should be postgresql, frontend should contain a list of all categories with all ratings (a simple tree) and each rating should have its own page where the description is listed. So, I guess, this is not really complex or anything, but I'm completely list with both integrating groundhog and heist, the former beeing my current step. Can someone digg into my code and tell me what I'm doing wrong? Or maybe even provide a _good_ tutorial for me? Or even be my mentor for this? Would be really nice! Good night, Haskell community! -- Mit freundlichen Grüßen, Kind regards, Matthias Beyer Proudly sent with mutt. Happily signed with gnupg.

On Sat, Jun 20, 2015 at 09:54:27PM +0200, Matthias Beyer wrote:
I am learning Haskell by trying to implement a really simple CRUD like web app with Snap and Groundhog - and I'm completely lost, cannot get it to work.
Since you seem to know what all of those things are, I'm going to assume you have some background in imperative programming. This assumption is backed by your GitHub history. I'm guessing, after the initial few languages, with most programming languages you've encountered thus far, you can learn a new one in a week or two. Haskell isn't like other languages. It requires a fundamentally different manner of thinking about your program. It's like learning to program all over again. It is worth it, I promise. As for learning Haskell, Chris Allen's tutorial has links to resources covering everything under the sun: https://github.com/bitemyapp/learnhaskell. Now, regarding your actual question: what's wrong with the code you have posted? 1. First of all, your dependencies are way too strict in your cabal file. In fact, most of them conflict. I couldn't even run `cabal install`. If you want to make sure the packages play together nicely, you should use Stackage http://www.stackage.org. 2. Nobody uses old versions of base anymore. You don't need that old-base stuff. 3. Your cabal file needs a default-language field. 4. Snap is a bit labor-intensive. Yesod http://www.yesodweb.com is much more well-suited for non-trivial web applications. Once I cleaned up the cabal file, I was able to get the standard Hello, World Snap application running on localhost. I forked your repository on GitHub. You can see the changes I made here: https://github.com/matthiasbeyer/rate.hs/compare/master...pharpend:master. Note that I am using GHC 7.10, which is the latest version. You might be on an old version of GHC, in which case, you should do the following: rm cabal.config cabal install cabal freeze To run the application, I just used `cabal run`. Peter Harpending

And I just realized I based all of this off of what was in the master branch. Oh well. See if it's helpful anyway. Peter Harpending On Sat, Jun 20, 2015 at 05:50:49PM -0600, Peter Harpending wrote:
On Sat, Jun 20, 2015 at 09:54:27PM +0200, Matthias Beyer wrote:
I am learning Haskell by trying to implement a really simple CRUD like web app with Snap and Groundhog - and I'm completely lost, cannot get it to work.
Since you seem to know what all of those things are, I'm going to assume you have some background in imperative programming. This assumption is backed by your GitHub history.
I'm guessing, after the initial few languages, with most programming languages you've encountered thus far, you can learn a new one in a week or two.
Haskell isn't like other languages. It requires a fundamentally different manner of thinking about your program. It's like learning to program all over again. It is worth it, I promise.
As for learning Haskell, Chris Allen's tutorial has links to resources covering everything under the sun: https://github.com/bitemyapp/learnhaskell.
Now, regarding your actual question: what's wrong with the code you have posted?
1. First of all, your dependencies are way too strict in your cabal file. In fact, most of them conflict. I couldn't even run `cabal install`.
If you want to make sure the packages play together nicely, you should use Stackage http://www.stackage.org.
2. Nobody uses old versions of base anymore. You don't need that old-base stuff.
3. Your cabal file needs a default-language field.
4. Snap is a bit labor-intensive. Yesod http://www.yesodweb.com is much more well-suited for non-trivial web applications.
Once I cleaned up the cabal file, I was able to get the standard Hello, World Snap application running on localhost.
I forked your repository on GitHub. You can see the changes I made here: https://github.com/matthiasbeyer/rate.hs/compare/master...pharpend:master. Note that I am using GHC 7.10, which is the latest version. You might be on an old version of GHC, in which case, you should do the following:
rm cabal.config cabal install cabal freeze
To run the application, I just used `cabal run`.
Peter Harpending

Hi, thanks a lot for your reply. Answer is inline: On 20-06-2015 17:53:24, Peter Harpending wrote:
And I just realized I based all of this off of what was in the master branch. Oh well. See if it's helpful anyway.
nvm, I'll read through it and apply onto my branch, thanks!
On Sat, Jun 20, 2015 at 05:50:49PM -0600, Peter Harpending wrote:
On Sat, Jun 20, 2015 at 09:54:27PM +0200, Matthias Beyer wrote:
I am learning Haskell by trying to implement a really simple CRUD like web app with Snap and Groundhog - and I'm completely lost, cannot get it to work.
Since you seem to know what all of those things are, I'm going to assume you have some background in imperative programming. This assumption is backed by your GitHub history.
I'm guessing, after the initial few languages, with most programming languages you've encountered thus far, you can learn a new one in a week or two.
Haskell isn't like other languages. It requires a fundamentally different manner of thinking about your program. It's like learning to program all over again. It is worth it, I promise.
There is no need to convince me! I already lost my soul to FP and Haskell! I know the concept is completely different from what I've learned so far, and I know I have to re-learn things, but I also know that it's worth it!
As for learning Haskell, Chris Allen's tutorial has links to resources covering everything under the sun: https://github.com/bitemyapp/learnhaskell.
Thanks for reminding me of this!
Now, regarding your actual question: what's wrong with the code you have posted?
My problem was that I didn't get groundhog to be integrated in my web app. I already solved this, as you can see here: https://github.com/matthiasbeyer/rate.hs/tree/restart_clean But still, I am not able to get my migrations running.
1. First of all, your dependencies are way too strict in your cabal file. In fact, most of them conflict. I couldn't even run `cabal install`.
Hm. I can run `cabal configure` without problems. I did not run `cabal install`, though, as I'm on nixos and it won't work anyways!
If you want to make sure the packages play together nicely, you should use Stackage http://www.stackage.org.
I'm using the cabal packages from nixos (haskellngPackages set). I'm not sure how to know whether they play nicely together or not...
2. Nobody uses old versions of base anymore. You don't need that old-base stuff.
Ok, will remove it. It is what `snap init` gave me, as far as I can remember!
3. Your cabal file needs a default-language field.
Will add that.
4. Snap is a bit labor-intensive. Yesod http://www.yesodweb.com is much more well-suited for non-trivial web applications.
I won't switch to yesod. Yesod is far more complex as far as I can tell. It might be well suited for the app I want to write after this one, which will be much more complex, but I guess I will still stick with Snap as it is (IMHO) easier to learn. Maybe you can convince me here.
Once I cleaned up the cabal file, I was able to get the standard Hello, World Snap application running on localhost.
I forked your repository on GitHub. You can see the changes I made here: https://github.com/matthiasbeyer/rate.hs/compare/master...pharpend:master. Note that I am using GHC 7.10, which is the latest version. You might be on an old version of GHC, in which case, you should do the following:
I'm on GHC 7.10.1, thanks! NixOS ships the latest, thankfully! :-) -- Mit freundlichen Grüßen, Kind regards, Matthias Beyer Proudly sent with mutt. Happily signed with gnupg.

El Jun 20, 2015, a las 16:50, Peter Harpending
On Sat, Jun 20, 2015 at 09:54:27PM +0200, Matthias Beyer wrote:
I am learning Haskell by trying to implement a really simple CRUD like web app with Snap and Groundhog - and I'm completely lost, cannot get it to work.
Since you seem to know what all of those things are, I'm going to assume you have some background in imperative programming. This assumption is backed by your GitHub history.
I'm guessing, after the initial few languages, with most programming languages you've encountered thus far, you can learn a new one in a week or two.
Haskell isn't like other languages. It requires a fundamentally different manner of thinking about your program. It's like learning to program all over again. It is worth it, I promise.
As for learning Haskell, Chris Allen's tutorial has links to resources covering everything under the sun: https://github.com/bitemyapp/learnhaskell.
Now, regarding your actual question: what's wrong with the code you have posted?
1. First of all, your dependencies are way too strict in your cabal file. In fact, most of them conflict. I couldn't even run `cabal install`.
If you want to make sure the packages play together nicely, you should use Stackage http://www.stackage.org.
2. Nobody uses old versions of base anymore. You don't need that old-base stuff.
3. Your cabal file needs a default-language field.
4. Snap is a bit labor-intensive. Yesod http://www.yesodweb.com is much more well-suited for non-trivial web applications.
[[citation needed]] Snap is used for lots of large production sites, and I don't think anyone would claim it's more complex for a beginner. Not starting a flamewar, just disputung that one is worse.
Once I cleaned up the cabal file, I was able to get the standard Hello, World Snap application running on localhost.
I forked your repository on GitHub. You can see the changes I made here: https://github.com/matthiasbeyer/rate.hs/compare/master...pharpend:master. Note that I am using GHC 7.10, which is the latest version. You might be on an old version of GHC, in which case, you should do the following:
rm cabal.config cabal install cabal freeze
To run the application, I just used `cabal run`.
Peter Harpending _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (3)
-
amindfv@gmail.com
-
Matthias Beyer
-
Peter Harpending