BSD3 licensed and maintained by Neil Mitchell

Module documentation for 0.3.15

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:

  • 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.


Changelog for Safe

Support QuickCheck 2.10
#20, fix for GHC 7.10.1
#20, require GHC 7.4 or above
#19, add Safe.Partial exposing a Partial typeclass
#19, add support for GHC call stacks
#16, add Safe succ and pred
#16, add readEitherSafe for better errors than readEither
#14, add Safe zip3Exact
#15, add Safe cycle
#9, add Safe toEnum
#8, remove unnecessary Ord constraints from Foldable functions
Add Def variants of the Exact functions
#6, remove unnecessary Ord constraints from maximumBy/minimumBy
Add Safe elemIndexJust/findIndexJust functions
Add Safe scan functions
Add Safe minimumBy/maximumBy functions
Add a module of Exact functions
Add Foldable minimum functions
Clean up the Foldable module, deprecate the Safe variants
#1, improve the string clipping in readNote
#494, add foldl1' wrappings
Add a Safe.Foldable module
Add findJust, safe wrapping of fromJust/find
Start of changelog
Depends on:
Used by 283 packages:
acid-state-dist, agentx, amby, antigate, api-tools, arena, arion, authoring, avers, aws, aws-elastic-transcoder, aws-sdk, aws-sdk-text-converter, aws-sign4, bake, basic-prelude, black-jewel, blacktip, blaze-html-contrib, BlogLiterately-diagrams, brittany, buchhaltung, byteunits, cblrepo, cgen, cgrep, chorale, citation-resolve, clac, clanki, cmaes, Coadjute, codecov-haskell, concorde, conduit-parse, configifier, convert-annotation, crockford, csv-enumerator, cubicspline, currency-codes, cursedcsv, darcsden, DarcsHelpers, darcswatch, data-easy, datarobot, data-structure-inferrer, data-variant, Deadpan-DDP, dequeue, dicom, digestive-functors-aeson, dns, doi, DP, draw-poker, dustme, easy-bitcoin, ecma262, eddie, errors, eventful-dynamodb, eventful-memory, exact-cover, exference, fadno, fastedit, fay, fay-builder, feed, fpco-api, ftdi, geek, gendocs, ghc-imported-from, ghc-mod, ginger, gitignore, gitit, git-sanity, goat, GoogleCodeJam, graph-core, grasp, gridland, hack2-handler-mongrel2-http, hack2-interface-wai, halberd, happstack-helpers, happs-tutorial, haskeline-repl, haskell-aliyun, haskell-gi, haskellscrabble, haskell-tools-ast-fromghc, haskell-tools-backend-ghc, haskoon, hbro, hbro-contrib, hdbi-postgresql, hellage, hellnet, HGE2D, hipbot, hledger, hledger-api, hledger-chart, hledger-lib, hledger-ui, hledger-vty, hledger-web, hmark, hmt, hold-em, hpaco-lib, hpaste, hpasteit, hpc-coveralls, hpqtypes-extras, hsc3, hsc3-data, hsc3-db, hsc3-lisp, hscurses-fish-ex, hsenv, hspec-stack-rerun, hs-scrape, hs-snowtify, hstradeking, HStringTemplateHelpers, httpspec, http-trace, hw-bits, hw-eliasfano, hw-excess, hw-packed-vector, hw-rankselect-base, idris, imprevu, imprevu-happstack, indieweb-algorithms, inilist, intricacy, intro, introduction, iptables-helpers, iptadmin, jmacro, jose, jsons-to-schema, kawaii, kawhi, keystore, legion-extra, lifted-protolude, linode, logic-classes, Lykah, macbeth-lib, MailchimpSimple, mathgenealogy, mbox, memis, microformats2-parser, midair, minirotate, montage, montage-client, newt, noether, Nomyx, nomyx-api, nomyx-core, Nomyx-Core, nomyx-language, Nomyx-Language, nomyx-library, Nomyx-Rules, nomyx-server, nomyx-web, Nomyx-Web, on-a-horse, pager, paypal-rest-client, phoityne, phoityne-vscode, pipeclip, postgrest, preamble, pregame, presto-hdbc, protolude, prove-everywhere-server, puffytools, pure-io, purescript, pushme, putlenses, quenya-verb, quickbench, reflex-dom, reflex-dom-contrib, respond, rest-core, rest-example, rest-gen, rest-snap, roundtrip, roundtrip-xml, rset, rss2irc, rss-conduit, ruff, salvia, salvia-protocol, salvia-sessions, scyther-proof, servant-auth-token-acid, servant-auth-token-leveldb, servant-auth-token-rocksdb, servant-client, servant-haxl-client, servant-server, shadower, shelltestrunner, shopify, skylighting, snap-extras, snaplet-mongoDB, snaplet-persistent, snm, snowtify, source-code-server, spiros, sprinkles, stack, stackage-curator, stackage-types, statistics-linreg, store, structural-induction, syntaxnet-haskell, t3-game, t3-server, tabl, taffybar, tak, tamarin-prover, tamarin-prover-term, tamarin-prover-theory, tamper, threepenny-gui, th-reify-many, Tic-Tac-Toe, tidal, time-warp, trurl, ttask, typerbole, universum, uri, util-plus, virthualenv, waldo, web-fpco, wobsurv, wsedit, xlsx, y0l0bot, yesod-alerts, yesod-auth, yesod-core, yesod-crud, yesod-platform, yi-keymap-vim, zifter, zifter-cabal, zifter-google-java-format, zifter-hindent, zifter-hlint, zifter-stack, zipkin
comments powered byDisqus