forked from vzarytovskii/haskell-dev-env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-test.hsfiles
271 lines (235 loc) · 6.15 KB
/
setup-test.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
{-# START_FILE stack.yaml #-}
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# resolve to lts-18.19, which has ghc 8.10.7 that's compatible with the current haskell
# language server. This should be changed when HLS is a higher version.
resolver: lts-18.19
# default to using the system GHC if we can--and we hope Docker will have the right one for us
system-ghc: true
# fix some problems with hspec and windows terminals, this only affects windows
# machines and is not needed on linux Docker installs
#flags:
# mintty:
# Win32-2-13-1: false
# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
# subdirs:
# - auto-update
# - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
# extra-deps: []
# Override default flag values for local packages and extra-deps
# flags: {}
# Extra package databases containing global packages
# extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.7"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
{-# START_FILE package.yaml #-}
name: {{name}}
version: 0.1.0.0
github: "{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{name}}"
license: BSD3
author: "{{author-name}}{{^author-name}}Author name here{{/author-name}}"
maintainer: "{{author-email}}{{^author-email}}example@example.com{{/author-email}}"
copyright: "{{copyright}}{{^copyright}}{{year}}{{^year}}2019{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}{{/copyright}}"
extra-source-files:
- README.md
- ChangeLog.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: {{category}}{{^category}}Web{{/category}}
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: "Stack template project for COMP 3351"
dependencies:
- base >= 4.7 && < 5
- hspec
default-extensions:
- EmptyCase
- FlexibleContexts
- FlexibleInstances
- InstanceSigs
- MultiParamTypeClasses
- LambdaCase
- MultiWayIf
- NamedFieldPuns
- TupleSections
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveLift
- DeriveTraversable
- DerivingStrategies
- GeneralizedNewtypeDeriving
- StandaloneDeriving
- BangPatterns
- KindSignatures
- TypeOperators
- OverloadedStrings
- ScopedTypeVariables
- TypeApplications
- ConstraintKinds
library:
source-dirs: src
executables:
{{name}}-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -haddock
- -Wall
- -Wcompat
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wredundant-constraints
dependencies:
- {{name}}
tests:
{{name}}-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -haddock
- -Wall
- -Wcompat
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wredundant-constraints
dependencies:
- {{name}}
{-# START_FILE Setup.hs #-}
import Distribution.Simple
main = defaultMain
{-# START_FILE test/Spec.hs #-}
-- file test/Spec.hs
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
{-# START_FILE src/Lib.hs #-}
module Lib
( someFunc
) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
{-# START_FILE app/Main.hs #-}
module Main where
import Lib
main :: IO ()
main = someFunc
{-# START_FILE README.md #-}
# {{name}}
{-# START_FILE ChangeLog.md #-}
# {{name}}
{-# START_FILE hie.yaml #-}
cradle:
stack:
{-# START_FILE src/WeekOne.hs #-}
module WeekOne where
pow :: (Eq b, Num b) => (b, b) -> b
pow (x, y) =
if y == 0
then 1
else x * pow(x, y - 1)
pow2 :: (Eq p, Num p) => p -> p -> p
pow2 x y =
if y == 0
then 1
else x * pow2 x (y - 1)
cube :: (Eq p, Num p) => p -> p
cube = flip pow2 3
{-# START_FILE test/WeekOneSpec.hs #-}
module WeekOneSpec where
import Test.Hspec
import WeekOne
spec :: Spec
spec = do
describe "pow function" $ do
it "raising something to exponent 0 is 1" $
pow (4, 0) `shouldBe` (1 :: Integer)
it "raising k to l should be k ** l" $
pow (5, 3) `shouldBe` (5 ** 3 :: Double)
describe "pow2 function" $ do
it "raising something to exponent 0 is 1" $
pow2 4 0 `shouldBe` (1 :: Integer)
it "raising k to l should be k ** l" $
pow2 8 17 `shouldBe` (8 ** 17 :: Double)
describe "cube function" $ do
it "cubing 0 should be 0" $
cube 0 `shouldBe` (0 :: Double)
it "cubing 42 should be 42**3" $
cube 42 `shouldBe` (42 ** 3 :: Double)
{-# START_FILE .gitignore #-}
dist
dist-*
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
*.ll
*.tokens
**/out/
*~
\#*\#
*.swp
*.bak
*.class
*.dep
*.zo
**/compiled/
**/workspace.xml
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*