Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si authored Jan 9, 2024
0 parents commit 63d3ad3
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
pull_request:
push:
branches: [main]

jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04, macos-12]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Stack
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-no-global: true

- name: Cache Stack build files
uses: actions/cache@v3
with:
path: |
~/.stack
.stack-work
key: >-
${{ runner.os }}-stack-${{
hashFiles('stack.yaml.lock', 'package.yaml') }}
restore-keys: |
${{runner.os}}-stack
- name: Test
run: stack test --ghc-options="-O2"

- name: Copy binary to ~/.local/bin so it can be uploaded
run: stack install

- name: Upload ${{ runner.os }} Release
uses: actions/upload-artifact@v3
with:
path: ~/.local/bin/haskell-template
name: haskell-template_${{ runner.os }}_${{ runner.arch }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.stack-work
/*.cabal
8 changes: 8 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Main where

import Protolude (IO, putStrLn, ($))
import Lib (sayHello)

main :: IO ()
main = do
putStrLn $ sayHello "World!"
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Haskell Template

- 2023-11-27 - 0.0.0.0
- Initial release
12 changes: 12 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
indentation: 2
function-arrows: leading
comma-style: leading
import-export-style: diff-friendly
indent-wheres: true
record-brace-space: false
newlines-between-decls: 2
haddock-style: multi-line-compact
let-style: auto
in-style: left-align
respectful: true
unicode: never
11 changes: 11 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: test
test:
stack test

.PHONY: build
build:
stack build

.PHONY: install
install:
stack install
51 changes: 51 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: haskell-template
version: 0.0.0.0
synopsis: A opinionated template for Haskell projects
description: Please check out the README for more information.
homepage: https://github.com/Airsequel/haskell-template#readme
license: AGPL-3.0-or-later
author: Adrian Sieber
maintainer: [email protected]
copyright: Adrian Sieber
category: Web

extra-source-files:
- readme.md

dependencies:
- base
- protolude

default-extensions:
- NoImplicitPrelude
- OverloadedRecordDot
- OverloadedStrings

ghc-options:
- -Wall
- -Wcompat
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wredundant-constraints
- -fno-warn-orphans

library:
language: GHC2021
source-dirs: source

executables:
haskell-template:
language: GHC2021
source-dirs: app
main: Main.hs
dependencies:
- haskell-template

tests:
haskell-template-test:
language: GHC2021
source-dirs: tests
main: Spec.hs
dependencies:
- haskell-template
- hspec
21 changes: 21 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Haskell Template

Opinionated template for new Haskell projects.


## Used Technologies

- [Stack](https://docs.haskellstack.org/en/stable/README/)
- [Fourmolu](https://fourmolu.github.io)
- [Haskell Language Server ](https://github.com/haskell/haskell-language-server)
- [Protolude](https://github.com/protolude/protolude)


## Usage

1. Clone this repository
1. Rename the folder to your project name
1. Replace all occurences of `haskell-template` with your project name
1. Run `stack test` to build the project and run the tests
1. Run `stack run` to run the project
1. Run `stack install` to install the project (make it available in your PATH)
7 changes: 7 additions & 0 deletions source/Lib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Lib where

import Protolude (Text, (<>))

sayHello :: Text -> Text
sayHello name =
"Hello " <> name <> "!"
5 changes: 5 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resolver: lts-21.15
packages:
- "."

extra-deps: []
12 changes: 12 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
snapshots:
- completed:
sha256: 350737ef1c4c748f4c7ff56b6e74f2f6d15039a2f148662a8ec1aded016b80d0
size: 640033
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/15.yaml
original: lts-21.15
10 changes: 10 additions & 0 deletions tests/Spec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Protolude (IO, ($))
import Test.Hspec (hspec, shouldBe, describe, it)

import Lib (sayHello)

main :: IO ()
main = hspec $ do
describe "Haskell Template" $ do
it "prints 'Hello World!'" $ do
sayHello "World" `shouldBe` "Hello World!"

0 comments on commit 63d3ad3

Please sign in to comment.