MyNixOS website logo
Description

Interactive terminal prompt.

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

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 String
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 String
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 [String]
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 [String]
main = multiselectWithDefault
         "What are your favourite films?"
         ["Titanic", "Matrix", "The Gladiator"]
         ["The Gladiator"]

Inspiration

This script is heavily inspired by survey (golang)

Metadata

Version

2.0.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows