Skip to content

Instantly share code, notes, and snippets.

@Ailrun
Last active September 23, 2021 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Ailrun/5672bc0fa8d0269c5cfc6219e2b4f496 to your computer and use it in GitHub Desktop.
Save Ailrun/5672bc0fa8d0269c5cfc6219e2b4f496 to your computer and use it in GitHub Desktop.
Stack templates
{-# START_FILE package.yaml #-}
spec-version: 0.31.0
name: {{name}}
version: 0.1.0.0
# synopsis:
# description:
category: {{category}}{{^category}}Language{{/category}}
homepage: https://github.com/{{github-username}}{{^github-username}}Ailrun{{/github-username}}/{{name}}#readme
bug-reports: https://github.com/{{github-username}}{{^github-username}}Ailrun{{/github-username}}/{{name}}/issues
author: {{author-name}}{{^author-name}}Junyoung/Clare Jang{{/author-name}}
maintainer: {{author-email}}{{^author-email}}example@example.com{{/author-email}}
copyright: {{copyright}}{{^copyright}}{{year}}{{^year}}2021{{/year}} {{author-name}}{{^author-name}}Junyoung/Clare Jang{{/author-name}}{{/copyright}}
license: MIT
license-file: LICENSE
# tested-with:
# build-type:
extra-source-files:
- README.md
# extra-doc-files:
# data-files:
# data-dir:
github: {{github-username}}{{^github-username}}Ailrun{{/github-username}}/{{name}}
# custom-setup:
# dependencies:
# flags:
library:
## Common fields
source-dirs:
- src
dependencies:
- base
## Library fields
# exposed:
# exposed-modules:
# generated-exposed-modules:
# other-modules:
# generated-other-modules:
# reexported-modules:
# signatures:
# internal-libraries:
executables:
{{name}}:
## Common fields
source-dirs:
- app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
dependencies:
- {{name}}
- base
## Executable fields
main: Main.hs
# other-modules:
# generated-other-modules:
# executable:
tests:
{{name}}-test:
## Common fields
source-dirs:
- test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
dependencies:
- {{name}}
- base
- hspec
- QuickCheck
## Test fields
main: Spec.hs
# other-modules:
# generated-other-modules:
# benchmarks:
# defaults:
# github:
# ref:
# path:
# local:
## Common fields
# buildable:
# source-dirs:
## Simulate GHC2021 and more
default-language: Haskell2010
default-extensions:
BangPatterns
BinaryLiterals
ConstrainedClassMethods
ConstraintKinds
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
DerivingStrategies
EmptyCase
EmptyDataDecls
EmptyDataDeriving
ExistentialQuantification
ExplicitForAll
FlexibleContexts
FlexibleInstances
ForeignFunctionInterface
GADTSyntax
GeneralizedNewtypeDeriving
HexFloatLiterals
ImportQualifiedPost
InstanceSigs
KindSignatures
LambdaCase
MultiParamTypeClasses
NamedFieldPuns
NamedWildCards
NumericUnderscores
PolyKinds
PostfixOperators
RankNTypes
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
StandaloneKindSignatures
StarIsType
TupleSections
TypeApplications
TypeFamilies
TypeOperators
TypeSynonymInstances
# other-extensions:
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wmissing-deriving-strategies
-Wmissing-home-modules -Wmonomorphism-restriction -Wpartial-fields
-Wredundant-constraints -Wunused-packages -Wunused-type-patterns
# ghc-prof-options:
# ghcjs-options:
# cpp-options:
# cc-options:
# c-sources:
# cxx-options:
# cxx-sources:
# js-sources:
# extra-lib-dirs:
# extra-libraries:
# include-dirs:
# install-includes:
# frameworks:
# extra-frameworks-dirs:
# ld-options:
# dependencies:
# pkg-config-dependencies:
# build-tools:
# system-build-tools:
# when:
{-# START_FILE .gitignore #-}
# Haskell
*.hi
*.o
# Cabal
*.cabal
# Haskell Tool Stack
.stack-work/
dist/
{-# START_FILE Setup.hs #-}
import Distribution.Simple
main = defaultMain
{-# START_FILE test/Spec.hs #-}
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
{-# START_FILE test/Data/String/StripSpec.hs #-}
module Data.String.StripSpec
( main
, spec
)
where
import Test.Hspec
import Test.QuickCheck
import Data.String.Strip
-- `main` is here so that this module can be run from GHCi on its own. It is
-- not needed for automatic spec discovery.
main :: IO ()
main = hspec spec
spec :: Spec
spec = do
describe "strip" $ do
it "removes leading and trailing whitespace" $ do
strip "\t foo bar\n" `shouldBe` "foo bar"
it "is idempotent" $ property $
\str -> strip str === strip (strip str)
{-# START_FILE src/Data/String/Strip.hs #-}
module Data.String.Strip (strip) where
import Data.Char
strip :: String -> String
strip = dropWhile isSpace . reverse . dropWhile isSpace . reverse
{-# START_FILE app/Main.hs #-}
module Main where
import Data.String.Strip
main :: IO ()
main = interact strip
{-# START_FILE LICENSE #-}
Copyright {{year}}{{^year}}2021{{/year}}-present {{author-name}}{{^author-name}}Junyoung/Clare Jang{{/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.
{-# START_FILE README.md #-}
# {{name}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment