The fortytwo package

[ Tags: library, mit, prompt ] [ Propose Tags ]

List of Prompt helpers to pimp the UIs of your haskell programs


[Skip to Readme]

Properties

Versions 0.0.1, 0.0.2, 0.0.3, 0.0.4, 1.0.0, 1.0.1, 1.0.2
Dependencies ansi-terminal (>=0.6.0.0 && <=0.7.1.1), base (>=4.7 && <5), fortytwo, text (<=1.2.2.2) [details]
License MIT
Copyright Gianlua Guarini
Author Gianluca Guarini
Maintainer gianluca.guarini@gmail.com
Category Prompt
Home page https://github.com/gianlucaguarini/fortytwo#readme
Source repository head: git clone https://github.com/gianlucaguarini/fortytwo
Uploaded Wed Oct 25 13:41:19 UTC 2017 by gianlucaguarini
Distributions NixOS:1.0.2
Executables demo
Downloads 222 total (222 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-10-25 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Flags

NameDescriptionDefaultType
demos

Build with demos

DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for fortytwo-1.0.2

[back to package description]

fortytwo

Interactive terminal prompt

Build Status MIT License

fortytwo

Installation

cabal install fortytwo

Demo

Demo

API

Prompts

Input

Ask a simple question requiring the user to type any string. It returns always a String

import FortyTwo (input)

main :: IO String
main = input "What's your name?"

inputWithDefault will let you define a fallback answer if no answer will be provided

import FortyTwo (inputWithDefault)

main :: IO String
main = inputWithDefault "What's your name?" "Undefined"

Confirm

Confirm prompt returning a boolean either True or False. If no answer will be provided it will return False

import FortyTwo (confirm)

main :: IO Bool
main = confirm "Are you old enough to see this?"

confirmWithDefault will let you define a fallback answer if no answer will be provided

import FortyTwo (confirmWithDefault)

main :: IO Bool
main = confirmWithDefault "Are you old enough to see this?" True

Password

Password prompt hiding the values typed by the user. It will always return a String

import FortyTwo (password)

main :: IO String
main = password "What's your secret password?"

Select

Select prompt letting users decide between one of many possible answers. It will always return a String

import FortyTwo (select)

main :: IO Bool
main = select
         "What's your favourite color?"
         ["Red", "Yellow", "Blue"]

selectWithDefault will let you define a fallback answer if no answer will be provided

import FortyTwo (selectWithDefault)

main :: IO Bool
main = selectWithDefault
         "What's your favourite color?"
         ["Red", "Yellow", "Blue"]
         "Red"

Multiselect

Multiselect prompt letting users decide between multiple possible choices. It will always return a collection [String]

import FortyTwo (multiselect)

main :: IO Bool
main = multiselect
         "What are your favourite films?"
         ["Titanic", "Matrix", "The Gladiator"]

multiselectWithDefault will let you define a fallback answer if no answer will be provided

import FortyTwo (multiselectWithDefault)

main :: IO Bool
main = multiselectWithDefault
         "What are your favourite films?"
         ["Titanic", "Matrix", "The Gladiator"]
         ["The Gladiator"]

Inspiration

This script is heavily inspired by survey (golang)