forked from commercialhaskell/stack-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
haskeleton.hsfiles
275 lines (230 loc) · 7.97 KB
/
haskeleton.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
{-# START_FILE {{ name }}.cabal #-}
-- This file has been generated from package.yaml by hpack version 0.9.0.
--
-- see: https://github.com/sol/hpack
name: {{ name }}
version: 0.0.0
synopsis: A new Haskeleton package.
description: {{ name }} is a new Haskeleton package.
category: Other
homepage: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{ name }}#readme
bug-reports: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{ name }}/issues
maintainer: {{author-name}}{{^author-name}}Author name here{{/author-name}}
license: MIT
build-type: Simple
cabal-version: >= 1.10
extra-source-files:
CHANGELOG.md
LICENSE.md
package.yaml
README.md
stack.yaml
source-repository head
type: git
location: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{ name }}
library
hs-source-dirs:
library
ghc-options: -Wall
build-depends:
base
exposed-modules:
Example
default-language: Haskell2010
executable {{ name }}
main-is: Main.hs
hs-source-dirs:
executable
ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N
build-depends:
base
, {{ name }}
default-language: Haskell2010
test-suite {{ name }}-test-suite
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs:
test-suite
ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N
build-depends:
base
, {{ name }}
, tasty
, tasty-hspec
default-language: Haskell2010
benchmark {{ name }}-benchmarks
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs:
benchmark
ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N
build-depends:
base
, {{ name }}
, criterion
default-language: Haskell2010
{-# START_FILE package.yaml #-}
# This YAML file describes your package. Stack will automatically generate a
# Cabal file when you run `stack build`. See the hpack website for help with
# this file: <https://github.com/sol/hpack>.
benchmarks:
{{ name }}-benchmarks:
dependencies:
- base
- {{ name }}
- criterion
ghc-options:
- -rtsopts
- -threaded
- -with-rtsopts=-N
main: Main.hs
source-dirs: benchmark
category: Other
description: {{ name }} is a new Haskeleton package.
executables:
{{ name }}:
dependencies:
- base
- {{ name }}
ghc-options:
- -rtsopts
- -threaded
- -with-rtsopts=-N
main: Main.hs
source-dirs: executable
extra-source-files:
- CHANGELOG.md
- LICENSE.md
- package.yaml
- README.md
- stack.yaml
ghc-options: -Wall
github: {{github-username}}{{^github-username}}githubuser{{/github-username}}/{{ name }}
library:
dependencies:
- base
source-dirs: library
license: MIT
maintainer: {{author-name}}{{^author-name}}Author name here{{/author-name}}
name: {{ name }}
synopsis: A new Haskeleton package.
tests:
{{ name }}-test-suite:
dependencies:
- base
- {{ name }}
- tasty
- tasty-hspec
ghc-options:
- -rtsopts
- -threaded
- -with-rtsopts=-N
main: Main.hs
source-dirs: test-suite
version: '0.0.0'
{-# START_FILE .gitignore #-}
# Stack uses this directory as scratch space.
/.stack-work/
# Stack generates the Cabal file from `package.yaml` through hpack.
/*.cabal
{-# START_FILE CHANGELOG.md #-}
# Change log
{{ name }} uses [Semantic Versioning][].
The change log is available through the [releases on GitHub][].
[Semantic Versioning]: http://semver.org/spec/v2.0.0.html
[releases on GitHub]: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{ name }}/releases
{-# START_FILE LICENSE.md #-}
[The MIT License (MIT)][]
Copyright (c) {{year}}{{^year}}2016{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[The MIT License (MIT)]: https://opensource.org/licenses/MIT
{-# START_FILE README.md #-}
# [{{ name }}][]
Thanks for starting a project with Haskeleton! If you haven't heard of it
before, I suggest reading the introductory blog post. You can find it here:
<http://taylor.fausak.me/2014/03/04/haskeleton-a-haskell-project-skeleton/>.
Before you get started, there are a few things that this template couldn't
provide for you. You should:
- Add a synopsis to `package.yaml`. It should be a short (one sentence)
explanation of your project.
- Add a description to `package.yaml`. This can be whatever you want it to
be.
- Add a category to `package.yaml`. A list of categories is available on
Hackage at <http://hackage.haskell.org/packages>.
- Rename `library/Example.hs` to whatever you want your top-level module to
be called. Typically this is the same as your package name but in
`CamelCase` instead of `kebab-case`.
- Don't forget to rename the reference to it in
`executable/Main.hs`!
- If you are on an older version of Stack (<1.0.4), delete `package.yaml` and
remove `/*.cabal` from your `.gitignore`.
Once you've done that, start working on your project with the Stack commands
you know and love.
``` sh
# Build the project.
stack build
# Run the test suite.
stack test
# Run the benchmarks.
stack bench
# Generate documentation.
stack haddock
```
Thanks again, and happy hacking!
[{{ name }}]: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{ name }}
{-# START_FILE Setup.hs #-}
-- This script is used to build and install your package. Typically you don't
-- need to change it. The Cabal documentation has more information about this
-- file: <https://www.haskell.org/cabal/users-guide/installing-packages.html>.
import qualified Distribution.Simple
main :: IO ()
main = Distribution.Simple.defaultMain
{-# START_FILE benchmark/Main.hs #-}
-- You can benchmark your code quickly and effectively with Criterion. See its
-- website for help: <http://www.serpentine.com/criterion/>.
import Criterion.Main
main :: IO ()
main = defaultMain [bench "const" (whnf const ())]
{-# START_FILE executable/Main.hs #-}
-- It is generally a good idea to keep all your business logic in your library
-- and only use it in the executable. Doing so allows others to use what you
-- wrote in their libraries.
import qualified Example
main :: IO ()
main = Example.main
{-# START_FILE library/Example.hs #-}
-- | An example module.
module Example (main) where
-- | An example function.
main :: IO ()
main = return ()
{-# START_FILE test-suite/Main.hs #-}
-- Tasty makes it easy to test your code. It is a test framework that can
-- combine many different types of tests into one suite. See its website for
-- help: <http://documentup.com/feuerbach/tasty>.
import qualified Test.Tasty
-- Hspec is one of the providers for Tasty. It provides a nice syntax for
-- writing tests. Its website has more info: <https://hspec.github.io>.
import Test.Tasty.Hspec
main :: IO ()
main = do
test <- testSpec "{{ name }}" spec
Test.Tasty.defaultMain test
spec :: Spec
spec = parallel $ do
it "is trivially true" $ do
True `shouldBe` True