Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-09-24 18:30:45 +02:00
.github/workflows Support GHC 9.8 in the testing 2023-10-15 17:54:26 +01:00
Safe MicroHs: avoid ambiguity in Prelude vs Foldable 2025-09-24 18:30:45 +02:00
.ghci Update .ghci 2022-03-21 20:57:52 +00:00
.gitignore Add to gitignore 2020-09-17 13:19:09 +01:00
.hlint.yaml Update .hlint.yaml 2020-03-08 13:37:07 +00:00
CHANGES.txt #35, exclude GHC 7.10 as it doesn't support new-style warnings 2024-02-04 16:44:07 +00:00
LICENSE Update the copyright year 2024-01-14 10:10:43 +00:00
PULL_REQUEST_TEMPLATE.md Update PULL_REQUEST_TEMPLATE.md 2018-09-07 15:15:45 +01:00
README.md Update README.md 2023-10-15 14:18:57 +01:00
safe.cabal #35, exclude GHC 7.10 as it doesn't support new-style warnings 2024-02-04 16:44:07 +00:00
Safe.hs Undo the Eta expansion 2024-01-18 16:45:37 +00:00
Setup.hs Initial version of the safe library 2006-11-14 19:04:43 +00:00
Test.hs Add a warning supression about orphans in the test suite 2017-11-28 21:18:03 +00:00

Safe Hackage version Stackage 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:

  • tail :: [a] -> [a], raises an error on tail [].
  • tailMay :: [a] -> Maybe [a], turns errors into Nothing.
  • tailDef :: [a] -> [a] -> [a], takes a default to return on errors.
  • tailNote :: String -> [a] -> [a], takes an extra argument which supplements the error message.
  • tailSafe :: [a] -> [a], 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.