ADD default template with all my compile flags

This commit is contained in:
Nathan Dwarshuis 2023-02-12 15:16:31 -05:00
parent 6eb119cc33
commit 0007284a67
2 changed files with 288 additions and 0 deletions

View File

@ -7,6 +7,7 @@
# you intend to use 'stack new'.
# See https://docs.haskellstack.org/en/stable/yaml_configuration/#templates
templates:
scm-init: git
params:
author-name: Nathan Dwarshuis
author-email: ndwar@yavin4.ch

View File

@ -0,0 +1,287 @@
{-# 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}}2022{{/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: Web
# 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: Please see the README on Github at <https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{name}}#readme>
default-extensions:
# incentivise rio
- NoImplicitPrelude
# avoid using strings
- OverloadedStrings
# more powerful type system
- FlexibleContexts
- FlexibleInstances
- InstanceSigs
- MultiParamTypeClasses
- RankNTypes
- GADTs
- FunctionalDependencies
- EmptyDataDecls
# derive all the things
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveLift
- DeriveTraversable
- DerivingStrategies
- DeriveDataTypeable
- GeneralizedNewtypeDeriving
- StandaloneDeriving
# better function syntax
- EmptyCase
- LambdaCase
- MultiWayIf
- NamedFieldPuns
- TupleSections
- BangPatterns
- BinaryLiterals
# better type syntax
- PartialTypeSignatures
- TypeOperators
- ScopedTypeVariables
- TypeApplications
- ConstraintKinds
- DefaultSignatures
- DataKinds
- TypeFamilies
- ViewPatterns
ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints
dependencies:
- base >= 4.11 && < 10
- rio >= 0.1.12.0
library:
source-dirs: src
executables:
{{name}}-exe:
main: Main.hs
source-dirs: app
dependencies:
- {{name}}
- optparse-simple
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
tests:
{{name}}-test:
main: Spec.hs
source-dirs: test
dependencies:
- {{name}}
- hspec
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
{-# START_FILE Setup.hs #-}
import Distribution.Simple
main = defaultMain
{-# START_FILE app/Main.hs #-}
{-# LANGUAGE TemplateHaskell #-}
module Main (main) where
import Import
import Run
import RIO.Process
import Options.Applicative.Simple
import qualified Paths_{{name-as-varid}}
main :: IO ()
main = do
(options, ()) <- simpleOptions
$(simpleVersion Paths_{{name-as-varid}}.version)
"Header for command line arguments"
"Program description, also for command line arguments"
(Options
<$> switch ( long "verbose"
<> short 'v'
<> help "Verbose output?"
)
)
empty
lo <- logOptionsHandle stderr (optionsVerbose options)
pc <- mkDefaultProcessContext
withLogFunc lo $ \lf ->
let app = App
{ appLogFunc = lf
, appProcessContext = pc
, appOptions = options
}
in runRIO app run
{-# START_FILE src/Import.hs #-}
module Import
( module RIO
, module Types
) where
import RIO
import Types
{-# START_FILE src/Run.hs #-}
module Run (run) where
import Import
run :: RIO App ()
run = do
logInfo "We're inside the application!"
{-# START_FILE src/Types.hs #-}
module Types
( App (..)
, Options (..)
) where
import RIO
import RIO.Process
-- | Command line arguments
data Options = Options
{ optionsVerbose :: !Bool
}
data App = App
{ appLogFunc :: !LogFunc
, appProcessContext :: !ProcessContext
, appOptions :: !Options
-- Add other app-specific configuration information here
}
instance HasLogFunc App where
logFuncL = lens appLogFunc (\x y -> x { appLogFunc = y })
instance HasProcessContext App where
processContextL = lens appProcessContext (\x y -> x { appProcessContext = y })
{-# START_FILE src/Util.hs #-}
-- | Silly utility module, used to demonstrate how to write a test
-- case.
module Util
( plus2
) where
import RIO
plus2 :: Int -> Int
plus2 = (+ 2)
{-# START_FILE test/Spec.hs #-}
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
{-# START_FILE test/UtilSpec.hs #-}
module UtilSpec (spec) where
import Import
import Util
import Test.Hspec
import Test.Hspec.QuickCheck
spec :: Spec
spec = do
describe "plus2" $ do
it "basic check" $ plus2 0 `shouldBe` 2
it "overflow" $ plus2 maxBound `shouldBe` minBound + 1
prop "minus 2" $ \i -> plus2 i - 2 `shouldBe` i
{-# START_FILE README.md #-}
# {{name}}
## Execute
* Run `stack exec -- {{name}}-exe` to see "We're inside the application!"
* With `stack exec -- {{name}}-exe --verbose` you will see the same message, with more logging.
## Run tests
`stack test`
{-# START_FILE CHANGELOG.md #-}
# Changelog for `{{ name }}`
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
## Unreleased
## 0.1.0.0 - YYYY-MM-DD
{-# START_FILE LICENSE #-}
Copyright {{author-name}}{{^author-name}}Author name here{{/author-name}} (c) {{year}}{{^year}}2022{{/year}}
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Author name here nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE {{copyright}}{{^copyright}}{{year}}{{^year}}2022{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}{{/copyright}} HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE {{copyright}}{{^copyright}}{{year}}{{^year}}2022{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}{{/copyright}}
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{-# START_FILE .gitignore #-}
*~
*.swp
tarballs/
.stack-work/