-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathminimal.hsfiles
168 lines (133 loc) · 4.25 KB
/
minimal.hsfiles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
{-# START_FILE .dir-locals.el #-}
((haskell-mode . ((haskell-indent-spaces . 4)
(haskell-process-use-ghci . t)))
(hamlet-mode . ((hamlet/basic-offset . 4)
(haskell-process-use-ghci . t))))
{-# START_FILE .gitignore #-}
dist*
static/tmp/
static/combined/
config/client_session_key.aes
*.hi
*.o
*.sqlite3
*.sqlite3-shm
*.sqlite3-wal
.hsenv*
cabal-dev/
.stack-work/
.stack-work-devel/
yesod-devel/
.cabal-sandbox
cabal.sandbox.config
.DS_Store
*.swp
*.keter
*~
\#*
{{name}}.cabal
{-# START_FILE README.md #-}
> *Note: This project was generated from the `yesod-minimal` scaffolding, and does not support features like `yesod devel`. If you want these features, use the `yesod-simple` stack template.*
## Haskell Setup
1. If you haven't already, [install Stack](https://haskell-lang.org/get-started)
* On POSIX systems, this is usually `curl -sSL https://get.haskellstack.org/ | sh`
2. Install GHC: `stack setup`
3. Build libraries: `stack build`
## Development
Start a development server with:
```
stack build --exec test-minimal
```
## Documentation
* Read the [Yesod Book](https://www.yesodweb.com/book) online for free
* Check [Stackage](http://stackage.org/) for documentation on the packages in your LTS Haskell version, or [search it using Hoogle](https://www.stackage.org/lts/hoogle?q=). Tip: Your LTS version is in your `stack.yaml` file.
* For local documentation, use:
* `stack haddock --open` to generate Haddock documentation for your dependencies, and open that documentation in a browser
* `stack hoogle <function, module or type signature>` to generate a Hoogle database and search for your query
* The [Yesod cookbook](https://github.com/yesodweb/yesod-cookbook) has sample code for various needs
## Getting Help
* Ask questions on [Stack Overflow, using the Yesod or Haskell tags](https://stackoverflow.com/questions/tagged/yesod+haskell)
* Ask the [Yesod Google Group](https://groups.google.com/forum/#!forum/yesodweb)
* There are several chatrooms you can ask for help:
* For IRC, try Freenode#yesod and Freenode#haskell
* [Functional Programming Slack](https://fpchat-invite.herokuapp.com/), in the #haskell, #haskell-beginners, or #yesod channels.
{-# START_FILE app/Main.hs #-}
import Application () -- for YesodDispatch instance
import Foundation
import Yesod.Core
main :: IO ()
main = warp 3000 App
{-# START_FILE package.yaml #-}
name: {{name}}
version: "0.0.0"
dependencies:
- base
- yesod-core
# The library contains all of our application code. The executable
# defined below is just a thin wrapper.
library:
source-dirs: src
# Runnable executable for our application
executables:
{{name}}:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- {{name}}
{-# START_FILE routes.yesodroutes #-}
/ HomeR GET
/add/#Int/#Int AddR GET
{-# START_FILE src/Add.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Add where
import Foundation
import Yesod.Core
getAddR :: Int -> Int -> Handler TypedContent
getAddR x y = selectRep $ do
provideRep $ defaultLayout $ do
setTitle "Addition"
[whamlet|#{x} + #{y} = #{z}|]
provideJson $ object ["result" .= z]
where
z = x + y
{-# START_FILE src/Application.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Application where
import Foundation
import Yesod.Core
import Add
import Home
mkYesodDispatch "App" resourcesApp
{-# START_FILE src/Foundation.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module Foundation where
import Yesod.Core
data App = App
mkYesodData "App" $(parseRoutesFile "routes.yesodroutes")
instance Yesod App
{-# START_FILE src/Home.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Home where
import Foundation
import Yesod.Core
getHomeR :: Handler Html
getHomeR = defaultLayout $ do
setTitle "Minimal Multifile"
[whamlet|
<p>
<a href=@{AddR 5 7}>HTML addition
<p>
<a href=@{AddR 5 7}?_accept=application/json>JSON addition
|]