extra: Extra functions I use.

[ bsd3, development, library ] [ Propose Tags ] [ Report a vulnerability ]

A library of extra functions for the standard Haskell libraries. Most functions are simple additions, filling out missing functionality. A few functions are available in later versions of GHC, but this package makes them available back to GHC 7.2.

The module Extra documents all functions provided by this library. Modules such as Data.List.Extra provide extra functions over Data.List and also reexport Data.List. Users are recommended to replace Data.List imports with Data.List.Extra if they need the extra functionality.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.2, 0.3, 0.3.1, 0.3.2, 0.4, 0.5, 0.5.1, 0.6, 0.7, 0.8, 1.0, 1.0.1, 1.1, 1.2, 1.3, 1.3.1, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.11, 1.6.12, 1.6.13, 1.6.14, 1.6.15, 1.6.16, 1.6.17, 1.6.18, 1.6.19, 1.6.20, 1.6.21, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10, 1.7.11, 1.7.12, 1.7.13, 1.7.14, 1.7.15, 1.7.16, 1.8
Change log CHANGES.txt
Dependencies base (>=4.9 && <4.19), clock (>=0.7), directory, filepath, process, time, unix [details]
Tested with ghc ==9.0, ghc ==8.10, ghc ==8.8, ghc ==8.6
License BSD-3-Clause
Copyright Neil Mitchell 2014-2022
Author Neil Mitchell <ndmitchell@gmail.com>
Maintainer Neil Mitchell <ndmitchell@gmail.com>
Revised Revision 1 made by Bodigrim at 2024-10-02T22:47:58Z
Category Development
Home page https://github.com/ndmitchell/extra#readme
Bug tracker https://github.com/ndmitchell/extra/issues
Source repo head: git clone https://github.com/ndmitchell/extra.git
Uploaded by NeilMitchell at 2022-08-21T15:35:00Z
Distributions Arch:1.7.16, Debian:1.7.4, Fedora:1.7.14, FreeBSD:1.4.1, LTSHaskell:1.7.16, NixOS:1.7.16, Stackage:1.8, openSUSE:1.7.16
Reverse Dependencies 257 direct, 299 indirect [details]
Downloads 178616 total (793 in the last 30 days)
Rating 2.5 (votes: 3) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-08-21 [all 1 reports]

Readme for extra-1.7.11

[back to package description]

Extra Hackage version Stackage version Build status

A library of extra functions for the standard Haskell libraries. Most functions are simple additions, filling out missing functionality. A few functions are available in later versions of GHC, but this package makes them available back to GHC 7.10. A few examples:

  • Control.Monad.Extra.concatMapM provides a monadic version of concatMap, in the same way that mapM is a monadic version of map.
  • Data.Tuple.Extra.fst3 provides a function to get the first element of a triple.
  • Control.Exception.Extra.retry provides a function that retries an IO action a number of times.
  • Data.Either.Extra.fromLeft is a function available in GHC 8.0 and above. On GHC 8.0 and above this package reexports the version from Data.Either while on GHC 7.10 and below it defines an equivalent version.

The module Extra documents all functions provided by this library. Modules such as Data.List.Extra provide extra functions over Data.List and also reexport Data.List. Users are recommended to replace Data.List imports with Data.List.Extra if they need the extra functionality.

Which functions?

When producing a library of extra functions I have been guided by a few principles. I encourage others with small useful utility functions contribute them here, perhaps as a temporary stop before proposing they join the standard libraries.

  • I have been using most of these functions in my packages - they have proved useful enough to be worth copying/pasting into each project.
  • The functions follow the spirit of the original Prelude/base libraries. I am happy to provide partial functions (e.g. fromRight), and functions which are specialisations of more generic functions (whenJust).
  • Most of the functions have trivial implementations that are obvious from their name/signature. If a beginner couldn't write the function, it probably doesn't belong here.
  • I have defined only a few new data types or type aliases. It's a package for defining new utilities on existing types, not new types or concepts.

Base versions

A mapping between base versions and GHC compiler versions can be found here.

Contributing

My general contribution preferences are available here. In addition, this repo contains some generated code which is checked in, namely src/Extra.hs and test/TestGen.hs. You can generate those files by either running runghc Generate.hs or ghci (which uses the .ghci file) and typing :generate. All PR's should contain regenerated versions of those files.