• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

Safe/H24-May-2020-443229

LICENSEH A D08-Mar-20201.5 KiB3125

README.mdH A D26-May-20191.3 KiB1611

Safe.hsH A D24-May-202014.1 KiB394222

Setup.hsH A D09-May-201545 22

Test.hsH A D28-Nov-20175.8 KiB156120

safe.cabalH A D24-May-20202.3 KiB7467

README.md

1# Safe [![Hackage version](https://img.shields.io/hackage/v/safe.svg?label=Hackage)](https://hackage.haskell.org/package/safe) [![Stackage version](https://www.stackage.org/package/safe/badge/nightly?label=Stackage)](https://www.stackage.org/package/safe) [![Build status](https://img.shields.io/travis/ndmitchell/safe/master.svg?label=Build)](https://travis-ci.org/ndmitchell/safe)
2
3A library wrapping `Prelude`/`Data.List` functions that can throw exceptions, such as `head` and `!!`. Each unsafe function has up to four variants, e.g. with `tail`:
4
5* <tt>tail :: [a] -> [a]</tt>, raises an error on `tail []`.
6* <tt>tailMay :: [a] -> <i>Maybe</i> [a]</tt>, turns errors into `Nothing`.
7* <tt>tailDef :: <i>[a]</i> -> [a] -> [a]</tt>, takes a default to return on errors.
8* <tt>tailNote :: <i>String</i> -> [a] -> [a]</tt>, takes an extra argument which supplements the error message.
9* <tt>tailSafe :: [a] -> [a]</tt>, returns some sensible default if possible, `[]` in the case of `tail`.
10
11This package is divided into three modules:
12
13* `Safe` contains safe variants of `Prelude` and `Data.List` functions.
14* `Safe.Foldable` contains safe variants of `Foldable` functions.
15* `Safe.Exact` creates crashing versions of functions like `zip` (errors if the lists are not equal) and `take` (errors if there are not enough elements), then wraps them to provide safe variants.
16