Home

Awesome

šŸ”® Summoner

wizard

GitHub CI

Hackage Stackage Lts Stackage Nightly MPL-2.0 license

So many of our dreams at first seem impossible, then they seem improbable, and then, when we summon the will, they soon become inevitable.

Christopher Reeve

Summoner is a tool for scaffolding fully configured batteries-included production-level Haskell projects.

Do you want to create a library that is to be uploaded to Hackage/Stackage, that builds with both Cabal and Stack and supports the latest three major GHC versions? Or are you building a production application which uses a custom prelude and has CI with GitHub Actions or Travis Linux and AppVeyors Windows checks? Maybe do you want to play with your idea in a single module without introducing the whole complexity of the Haskell projects? Summoner can help you do all that with minimal effort from you - it can even upload the project to GitHub if you wish!

By the way, Summoner operates as either CLI or TUI application, so you can choose what you are more comfortable with and install only the required one.

Structure

Demo

[Back to the Table of Contents] ā†‘

TUI demo

[Back to the Table of Contents] ā†‘

TUI demo

CLI demo

[Back to the Table of Contents] ā†‘

CLI demo

Examples

[Back to the Table of Contents] ā†‘

You can also see complete examples in the following folder:

The directory contains the following examples:

Features

[Back to the Table of Contents] ā†‘

Summoner is a tool that combines predefined configurations, command-line arguments and a chosen interface.

To fully understand the power in your hands with the help of Summoner, please read this section.

Below you can see highlighted features in different categories.

Project

[Back to the Table of Contents] ā†‘

Features related to the structure and content of the generated projects.

GitHub

[Back to the Table of Contents] ā†‘

CI

[Back to the Table of Contents] ā†‘

Others

[Back to the Table of Contents] ā†‘

Project structure example

[Back to the Table of Contents] ā†‘

This is an example of the project hierarchy you can get if you are running Summoner's new command with all options enabled:

project-name/
ā”œā”€ā”€ app/
ā”‚Ā Ā  ā””ā”€ā”€ Main.hs
ā”œā”€ā”€ benchmark/
ā”‚Ā Ā  ā””ā”€ā”€ Main.hs
ā”œā”€ā”€ src/
ā”‚   ā”œā”€ā”€ ProjectName.hs
ā”‚Ā Ā  ā””ā”€ā”€ Prelude.hs
ā”œā”€ā”€ test/
ā”‚Ā Ā  ā””ā”€ā”€ Spec.hs
ā”œā”€ā”€ CHANGELOG.md
ā”œā”€ā”€ CONTRIBUTING.md
ā”œā”€ā”€ LICENSE
ā”œā”€ā”€ project-name.cabal
ā”œā”€ā”€ README.md
ā”œā”€ā”€ Setup.hs
ā”œā”€ā”€ stack.yaml
ā”œā”€ā”€ stack-8.6.5.yaml
ā”œā”€ā”€ appveyor.yml
ā”œā”€ā”€ .git
ā”œā”€ā”€ .gitignore
ā”œā”€ā”€ .stylish-haskell.yaml
ā””ā”€ā”€ .travis.yml

Get started

[Back to the Table of Contents] ā†‘

Prerequisites

[Back to the Table of Contents] ā†‘

To start using Summoner make sure that you have the following tools installed on your machine:

We also have minimal version requirements for build tools:

However, it is always recommended to use the newest versions of build tools.

Installation

[Back to the Table of Contents] ā†‘

Summon contains two executables:

Below you can find the description of how to install each of them so you can choose the one you want.

Summon-TUI

[Back to the Table of Contents] ā†‘

NOTE: summon-tui is not supported on Windows. See this issue.

TUI: download binary

[Back to the Table of Contents] ā†‘

You can download binary directly from GitHub releases.

After downloading binary, make it executable and copy it under convenient location, for example:

chmod +x summon-cli-linux
mv summon-cli-linux ~/.local/bin/summon
TUI: Homebrew

[Back to the Table of Contents] ā†‘

If you are on MacOS, you can get Summoner using Homebrew Kowainik's Tap.

You need to run the following command for that:

$ brew install kowainik/tap/summoner-tui
TUI: Ubuntu

[Back to the Table of Contents] ā†‘

If you are on Ubuntu, you can get Summoner from Kowainik's PPA.

You need to run the following commands for that:

$ sudo add-apt-repository ppa:kowainik/summoner-tui
$ sudo apt update
$ sudo apt install summoner-tui
TUI: from Hackage

[Back to the Table of Contents] ā†‘

Using cabal:

cabal update
cabal install summoner-tui
TUI: from source

[Back to the Table of Contents] ā†‘

Fetch the repo using cabal:

cabal get -s summoner

or clone the directory from GitHub:

git clone https://github.com/kowainik/summoner.git

Step into the directory:

cd summoner

Build and install using cabal:

cabal install summoner-tui:exe:summon-tui

Build and install using stack:

stack install summoner-tui:exe:summon-tui

Summon-CLI

[Back to the Table of Contents] ā†‘

CLI: download binary

[Back to the Table of Contents] ā†‘

You can download binary directly from GitHub releases.

After downloading binary, make it executable and copy it under convenient location, for example:

chmod +x summon-cli-linux
mv summon-cli-linux ~/.local/bin/summon
CLI: Homebrew

[Back to the Table of Contents] ā†‘

If you are on MacOS, you can get Summoner using Homebrew Kowainik's Tap.

You need to run the following command for that:

$ brew install kowainik/tap/summoner-cli
CLI: Ubuntu

[Back to the Table of Contents] ā†‘

If you are on Ubuntu, you can get Summoner from Kowainik's PPA.

You need to run the following commands for that:

$ sudo add-apt-repository ppa:kowainik/summoner-cli
$ sudo apt update
$ sudo apt install summoner-cli
CLI: from Hackage

[Back to the Table of Contents] ā†‘

Using cabal:

cabal update
cabal install summoner
CLI: from source

[Back to the Table of Contents] ā†‘

Fetch the repo using cabal:

cabal get -s summoner

or clone the directory from GitHub:

git clone https://github.com/kowainik/summoner.git

Step into the directory:

cd summoner

Build and install using cabal:

cabal install summoner-cli:exe:summon

Build and install using stack:

stack install summoner:exe:summon

Setup

[Back to the Table of Contents] ā†‘

You can turn on bash auto-completion by running the following command:

source <(summon --bash-completion-script `which summon`)

Usage

[Back to the Table of Contents] ā†‘

To start summoning projects nothing additional is required. However, to tweak your settings further, you can use additional configuration settings. There are several options you can use to set particular configurations for new projects (in increasing order of priority):

  1. Default configuration file (~/.summoner.toml).
  2. Fields user.login, user.name and user.email from ~/.gitconfig.
  3. Explicitly specified configuration file by --file FILENAME option (used instead of the default one if specified).
  4. Options that are stated by CLI arguments.
  5. User input. It could be
    • TUI ā€“ User data specified in the window of summon-tui.
    • CLI ā€“ Interactively inputted answers during execution of the summon command (for the options that were not specified on previous steps).

To cut a long story short, the configuration uses Partial Options Monoid Pattern.

File configuration

[Back to the Table of Contents] ā†‘

Here is the list of the options that can be configured to suit your needs. If options are not specified, they are asked interactively (or some sensible defaults are used).

FieldTypeDescription
cabalBoolAdd Cabal support?
stackBoolAdd Stack support?
ownerTextGitHub login.
fullNameTextFull name.
emailTextE-mail address.
licenseLicenseOne of: MIT, BSD2, BSD3, GPL-2, GPL-3, LGPL-2.1, LGPL-3, AGPL-3, Apache-2.0, MPL-2.0, None.
ghcVersions[GHC]summoner uses default GHC-9.0.2. However, additionally you can specify other versions. For each version x.y.z the stack-x.y.z.yaml will be created. Use summon show ghc to see all supported GHC versions.
githubBoolTurn on GitHub integration by default?
gitignore[Text]List of files you want added to the default .gitignore. (Ignored if github = false)
noUploadBoolDo not upload to GitHub, but create all GitHub related files if specified (Ignored if github = false)
privateBoolCreate private repository by default? (Ignored if github = false)
githubActionsBoolTurn on GitHub Actions integration by default? (Currently working with Cabal only. Ignored if github = false)
travisBoolTurn on Travis integration by default? (Ignored if github = false)
appveyorBoolTurn on AppVeyor integration by default? (Ignored if github = false)
libBoolCreate src folder with simple ProjectName.hs file and library target?
exeBoolCreate app folder with simple Main.hs file and executable target?
testBoolCreate test folder with simple Spec.hs file and test target?
benchBoolCreate benchmark folder with Main.hs file with gauge library usage example?
extensions[Text]List of the default extensions to add into default-extensions section in the .cabal.
ghc-options[Text]List of the default GHC options to add into ghc-options section in the .cabal.
filesMap FilePath SourceCustom mapping of files to their sources. Represented as a list of inline tables in TOML in a format like files = [ { path = "foo", url = "https://..." }, ... ]. Supported file types: url, local, raw.
[prelude]
packageTextThe package name of the custom prelude you'd like to use in the project (doesn't work without module field).
moduleTextThe module name of the custom prelude you'd like to use in the project (doesn't work without package field).

You can create default configuration using the summon config command. See the default content here.

For a real-life example of the configuration, see the configuration for projects of the Kowainik organization.

Command line arguments

[Back to the Table of Contents] ā†‘

Available commands:

Usage:
  summon COMMAND
      Set up your own Haskell project

Available commands:
  new                      Create a new Haskell project
  script                   Create a new Haskell script
  show                     Show available licenses or ghc versions
  config                   Create default TOML configuration for summoner

Available global options:
  -h, --help               Show this help text
  -v, --version            Show summoner's version

summon new command:

[Back to the Table of Contents] ā†‘

Usage:
  summon new PROJECT_NAME [--ignore-config] [--no-upload] [--offline]
             [-f|--file FILENAME]
             [--cabal]
             [--stack]
             [--prelude-package PACKAGE_NAME]
             [--prelude-module MODULE_NAME]
             [with    [OPTIONS]]
             [without [OPTIONS]]

Available options:
  -h, --help               Show this help text
  --ignore-config          Ignore configuration file
  --no-upload              Do not upload to GitHub. Special case of the '--offline' flag.
  --offline                Offline mode: create project with 'All Rights Reserved' license
                           and without uploading to GitHub.
  --cabal                  Cabal support for the project
  --stack                  Stack support for the project
  -f, --file FILENAME      Path to the toml file with configurations. If not
                           specified '~/.summoner.toml' will be used by default
  --prelude-package PACKAGE_NAME
                           Name for the package of the custom prelude to use in
                           the project
  --prelude-module MODULE_NAME
                           Name for the module of the custom prelude to use in
                           the project

Available commands:
  with                     Specify options to enable
  without                  Specify options to disable

Available command options:
  -h, --help               Show this help text
  -g, --github             Github integration
  -p, --private            Create private GitHub repository
  -a, --actions            GitHub Actions CI integration
  -c, --travis             Travis CI integration
  -w, --app-veyor          AppVeyor CI integration
  -l, --library            Library target
  -e, --exec               Executable target
  -t, --test               Tests
  -b, --benchmark          Benchmarks

summon script command:

[Back to the Table of Contents] ā†‘

Usage:
  summon script BUILD_TOOL [-g|--ghc GHC_VERSION] [-n|--name FILE_NAME]
      Create a new Haskell script

Available options:
  -h,--help                Show this help text
  -g,--ghc GHC_VERSION     Version of the compiler to be used for script
  -n,--name FILE_NAME      Name of the script file

summon show command:

[Back to the Table of Contents] ā†‘

Usage:
  summon show COMMAND
      Show supported licenses or ghc versions

Available commands:
  ghc                      Show available ghc versions
  license                  Show available licenses
  license [LICENSE_NAME]   Show specific license text

Available options:
  -h, --help               Show this help text

For example, the following command preconfigures the project settings with the custom prelude relude, included library, executable, test stanzas (but without benchmarks), creates a private repository on GitHub with the GitHub Actions CI, Travis CI and AppVeyor CI integrated.

summon new my-project with -letgcpwa without -b --prelude-package relude --prelude-module Relude

summon config command:

[Back to the Table of Contents] ā†‘

Usage: summon config [-f|--file=FILENAME]
  Create a default TOML configuration file for summoner

Available options:
  -h,--help                Show this help text
  -f,--file=FILENAME       Path to the toml file with configurations. If not
                           specified '~/.summoner.toml' will be used by default

This command will generate a TOML configuration file with the default settings that can be used to scaffold future Haskell packages. It contains all options supported by Summoner with comments and examples. Though, all options would be turned off by default and to use them one will need to uncomment the corresponding lines. See the default content here.

Possible command usages:

summon config
summon config --file ~/.summoner-demo.toml

TUI

[Back to the Table of Contents] ā†‘

TUI new command

[Back to the Table of Contents] ā†‘

summon new TUI

Section 1 ā€“ The main section where user inputs data or changes the configurations.

Section 2 ā€“ The structure of the project that is going to be created with the current configurations. This tree changes on-the-fly.

Section 3 ā€“ Hints, project status, or current errors in the configurations.

Section 4 ā€“ Useful hotkeys.

The TUI window opens with the pre-filled information received from a config file and command-line arguments. However, it's possible to change any field as per your needs.

In the screenshot you can see that you'll be given a few text fields to fill in or some checkboxes that represent boolean values of the configurations. To help you fill in the correct input, there are some ā“˜ info messages in the Status section, which give additional details about the current field.

To help you navigate between the form fields here are the available hotkeys:

KeyAction
<kbd>Esc</kbd>Abort summoner
<kbd>Enter</kbd>If input is valid go to the Confirm window
<kbd>Tab</kbd>Change the focus to the next active field
<kbd>Shift</kbd> + <kbd>Tab</kbd>Change the focus to the previous active field
<kbd>Space</kbd>Enable/disable current checkbox or radio button
<kbd>Ctrl</kbd> + <kbd>d</kbd>Delete the input of the current text field
<kbd>Ctrl</kbd> + <kbd>u</kbd>Delete the input of the current text field from the cursor position to the beginning
<kbd>Ctrl</kbd> + <kbd>k</kbd>Delete the input of the current text field from the cursor position to the end
<kbd>Ctrl</kbd> + <kbd>a</kbd>Move the cursor to the beginning of the current input field
<kbd>Ctrl</kbd> + <kbd>e</kbd>Move the cursor to the end of the current input field
<kbd>Up</kbd>/<kbd>Down</kbd>Scroll license list when focused

Note that the form should be valid in order to be able to go to the Confirm window. If there are some errors in the input, you could see details about these errors in the Status section of the form.

TUI script command

[Back to the Table of Contents] ā†‘

See CLI description of the summon script command.

TUI show command

[Back to the Table of Contents] ā†‘

These commands display the list of supported GHC versions or Licenses. Also, when the license name is specified the window with the scrollable content of the License text is shown.

CLI

[Back to the Table of Contents] ā†‘

CLI new command

[Back to the Table of Contents] ā†‘

In CLI mode of operation Summoner asks about every project setting. Most of the questions contain a default value, so you can press <kbd>Enter</kbd> to choose the default value. If some option is specified via a configuration file or CLI arguments, then the question is skipped and the predefined value is used.

CLI script command

[Back to the Table of Contents] ā†‘

This command creates minimal cabal or stack script file which allows you to save some keystrokes and eliminates the need to remember magic words for scripts.

Cabal example: summon script cabal -n Main.hs generates executable file Main.hs with the following content:

#!/usr/bin/env cabal
{- cabal:
build-depends:
  , base ^>= 4.13.0.0
-}

main :: IO ()
main = putStrLn "Hello, World!"

Stack example: summon script stack -n Main.hs generates executable file Main.hs with the following content:

#!/usr/bin/env stack
{- stack
  --resolver lts-15.5
  script
  --package base
-}

main :: IO ()
main = putStrLn "Hello, World!"

CLI show command

[Back to the Table of Contents] ā†‘

These commands display the list of supported GHC versions, or Licenses. Also, when the license name is specified, the content of the License is outputted to the terminal.

FAQ

[Back to the Table of Contents] ā†‘

I want to use HTTPS remote for the created GitHub project, but it creates SSH one. How should I fix this?

We are using hub tool to create the projects at GitHub. It uses SSH so that you would get the remote links in the following format:

git@github.com:user/repo.git

We can not change or configure this behaviour, but there are several workarounds in case you need to use HTTPS link for the remote.

  1. Change the remote of the repository after its creation:
    git remote set-url origin https://github.com/user/repo.git
    
  2. Change hub configurations globally. Simply run the following command:
    git config --global hub.protocol https
    
  3. Alternatively, change hub configurations for a single session:
    export HUB_PROTOCOL="https"
    
<hr>

Why some of the Stack checks on my TravisCI matrix are marked as "This job is allowed to fail"?

Due to the Stack problem of working with older versions of Cabal, the build can fail with Stack for some older GHCs. We are adding these checks into allow_failures section, as this is a known issue, and there is no need for the whole build to fail because of that.

For more information about the issue and some workarounds from Stack developers, see the following ticket:

For Developers

[Back to the Table of Contents] ā†‘

If you'd like to take part in the development processes, here are a few things to keep in mind:

Dependencies

[Back to the Table of Contents] ā†‘

On Linux, to build the summoner-tui you'll need to have libtinfo installed. The easiest way to get this is from your system's package manager and is usually available as the package libtinfo-dev.

Build

[Back to the Table of Contents] ā†‘

To build the project you can use the following commands:

cabal build all

for Cabal and

stack build

for Stack.

Test

[Back to the Table of Contents] ā†‘

Summoner uses the golden tests technique for assuring the correctness of the generated files. For this purpose, we have the golden folder with two sample projects to test against.

To actually run tests you need to run:

cabal test all

or, if using Stack

stack test

Run

[Back to the Table of Contents] ā†‘

Building Summoner with the recommended method creates two executables: summon and summon-tui. To run the compiled executable you can use the following commands:

cabal exec summon -- SOME_COMMAND
cabal exec summon-tui -- SOME_COMMAND

or, if using Stack

stack exec summon -- SOME_COMMAND
stack exec summon-tui -- SOME_COMMAND

Generate golden tests

To regenerate the content of all projects on disk, use the following command:

cabal run gg

Acknowledgments

[Back to the Table of Contents] ā†‘

This project was inspired by Aelve/new-hs, which is the tool with the same goal but it's only for creating cabal projects.

Icons made by Nikita Golubev from Flaticon is licensed by CC 3.0 BY.