MyNixOS website logo
Description

fortune-mod clone.

fortune-mod clone, in library and executable form.

misfortune

This is a fortune-mod clone. In addition to the features generally expected of a fortune program, this can be used as a Haskell library (import Data.Fortune) and also supports UTF-8 fortune files, configurable search paths, automatic merging of fortune databases with the same name (so you can have a local fortunes folder that just adds to existing fortune databases), filtering fortunes by line lengths, and a "print fortune matching regex" mode (instead of just "print all fortunes matching regex" mode).

Usage

Most of the command-line flags from fortune work with misfortune as well. To just print a fortune, run:

misfortune

To index a new fortune file (or update the index on an existing one), run:

misfortune-strfile path/to/file

To use the fortune API in your Haskell programs:

import Data.Fortune
import qualified Data.Text as T

main = do
    f <- openFortuneFile "pangrams" '%' True
    
    appendFortune f (T.pack "The quick brown fox jumps over the lazy dog.")
    appendFortune f (T.pack "Quick blowing zephyrs vex daft Jim.")
    
    closeFortuneFile f
    
    putStrLn =<< randomFortune ["pangrams"]

This example will create or append to a file "pangrams" in the working directory, and create or update the corresponding index file "pangrams.dat". It then closes that file and requests a random fortune from all databases named "pangrams" in the search path - so it will either print one of the two just written or one found in another "pangrams" file. Every eligible fortune is equally likely.

Installation

Get the current release from Hackage:

cabal install misfortune

Or build the latest version from git:

git clone https://github.com/ncfavier/misfortune
cd misfortune
cabal install
Metadata

Version

0.1.2.1

License

Executables (2)

  • bin/misfortune-strfile
  • bin/misfortune

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