The safe package

[Tags:bsd3, library]

A 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:

This package is divided into three modules:


[Skip to Readme]

Properties

Versions 0.2, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9
Change log CHANGES.txt
Dependencies base (<5) [details]
License BSD3
Copyright Neil Mitchell 2007-2015
Author Neil Mitchell <ndmitchell@gmail.com>
Maintainer Neil Mitchell <ndmitchell@gmail.com>
Stability Unknown
Category Unclassified
Home page https://github.com/ndmitchell/safe#readme
Bug tracker https://github.com/ndmitchell/safe/issues
Source repository head: git clone https://github.com/ndmitchell/safe.git
Uploaded Sat May 9 20:01:36 UTC 2015 by NeilMitchell
Distributions Arch:0.3.9, Debian:0.3.9, Fedora:0.3.9, FreeBSD:0.3.9, LTSHaskell:0.3.9, NixOS:0.3.9, Stackage:0.3.9, Tumbleweed:0.3.9
Downloads 95955 total (38 in the last 30 days)
Votes
1 []
Status Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for safe

Readme for safe-0.3.9

Safe Hackage version Build Status

A 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:

  • <tt>tail :: [a] -> [a]</tt>, raises an error on tail [].
  • <tt>tailMay :: [a] -> <i>Maybe</i> [a]</tt>, turns errors into Nothing.
  • <tt>tailDef :: <i>[a]</i> -> [a] -> [a]</tt>, takes a default to return on errors.
  • <tt>tailNote :: <i>String</i> -> [a] -> [a]</tt>, takes an extra argument which supplements the error message.
  • <tt>tailSafe :: [a] -> [a]</tt>, returns some sensible default if possible, [] in the case of tail.

This package is divided into three modules:

  • Safe contains safe variants of Prelude and Data.List functions.
  • Safe.Foldable contains safe variants of Foldable functions.
  • 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.