Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
Safe/ | H | 24-May-2020 | - | 443 | 229 | |
LICENSE | H A D | 08-Mar-2020 | 1.5 KiB | 31 | 25 | |
README.md | H A D | 26-May-2019 | 1.3 KiB | 16 | 11 | |
Safe.hs | H A D | 24-May-2020 | 14.1 KiB | 394 | 222 | |
Setup.hs | H A D | 09-May-2015 | 45 | 2 | 2 | |
Test.hs | H A D | 28-Nov-2017 | 5.8 KiB | 156 | 120 | |
safe.cabal | H A D | 24-May-2020 | 2.3 KiB | 74 | 67 |
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