Diceware

Here is a program that generates diceware passwords.

All the I/O is here in the entry point; the rest is pure. Here’s how to call it:

λ> diceware 6 "-"
pulp-turk-nn-trip-aloof-nadir

Or here’s an entry point that uses command-line arguments:

You can run that from a terminal using:

% runhaskell A09Sol.lhs 5 "$"
police$keyed$mule$i's$berea

or simulate sending arguments to the main program in GHCi like this:

λ> withArgs ["5", "/"] main
feat/xg/drop/hanna/cony

In the terminal, if you want an empty string for the separator, you have to put empty quotes:

% runhaskell A09Sol.lhs 5 ""
availlaban19thbathbelch
% runhaskell A09Sol.lhs 5
Usage: diceware NUM-WORDS SEPARATOR-STRING