Extra functions I use. https://github.com/ndmitchell/extra#readme

Version on this page:1.1
LTS Haskell 8.12:1.5.2
Stackage Nightly 2017-04-23:1.5.2
Latest on Hackage:1.5.2
BSD3 licensed and maintained by Neil Mitchell

Module documentation for 1.1

There are no documented modules for this package.

Extra Hackage version Stackage version Linux Build Status Windows 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.2. 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.
  • System.Environment.Extra.lookupEnv is a function available in GHC 7.6 and above. On GHC 7.6 and above this package reexports the version from System.Environment while on GHC 7.4 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. 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

The following GHC versions correspond to the following base library versions:

  • base 4.9 == GHC 8.0
  • base 4.8 == GHC 7.10
  • base 4.7 == GHC 7.8
  • base 4.6 == GHC 7.6
  • base 4.5 == GHC 7.4
  • base 4.4 == GHC 7.2

A more complete list can be found here.


Changelog for Extra

Add errorWithoutStackTrace to Control.Exception.Extra
#25, add zipFrom and zipWithFrom
#24, add eitherToMaybe and maybeToEither
Add fromLeft' and fromRight'
Change fromLeft/fromRight signatures to follow the base libraries
Add writeVar
Require QuickCheck 2.9
#23, deprecate offsetTimeIncrease and subtract
#22, improve offsetTime to give reliable measurements
Depend on the clock library
Add Data.Typeable.Extra containing typeRep, Proxy, (:~:)
Add line1
Add displayException
#21, add concatForM
#11, add maybeM and eitherM
#17, change fileEq on files that do not exist to be an error
#14, add mconcatMap and mconcatMapM
#16, add fileEq
#15, add isMac
Add Data.Version.Extra
Make concatMapM/mapMaybeM faster
Make temp file functions workaround GHC bug #10731
Add retryBool
Add stripInfix and stripInfixEnd
#9, support directory-1.2.3
Add whenJustM
Add errorIO
Add onceFork
Make once async exception safe
Fix a deadlock in once when two people request in parallel
Fix a missing hClose in captureOutput
#7, add nubOrd, nubOrdOn, nubOrdBy
#6, add groupSortOn and groupSortBy
#5, add splitAtEnd
Make listFilesAvoid drop trailing path separators before testing
#3, add a constraint base >= 4.4
No changes
Fix a bug in writeFileEncoding/writeFileUTF8
Fix for missing case in withNumCapabilities
Ensure barrier is thread-safe
Make subsequent signalBarrier calls throw an exception
Add timeout function
Make sure sleep never wraps round an Int
Use uncons from GHC 7.9 and above
Use the sortOn from GHC 7.9 and above
Remove getProcessorCount
Remove getDirectoryContentsRecursive in favour of listFilesRecursive
Change the signature for newTempFile/newTempDir
Add a once function
Remove all but the extractors on triples
Remove groupSortOn
Remove dropAround
Remove use of ===, allows older QuickCheck versions
Fix a bug in breakEnd/spanEnd
Rename showTime to showDuration
Add stringException
Eliminate rep/reps, use replace instead
Switch distinct for allSame/anySame
Optimise the numeric conversions
Rename chop to repeatedly
Add whenM/unlessM
Redo the Tuple module, additions and deletions
Add newTempFile, newTempDir
Add createDirectoryPrivate
Rename strip* to trim*
Generalise showException
Redo the cons/uncons functions
Add withTempDir
Rename withTemporaryFile to withTempFile
Change trim to strip (follow text naming convention)
Ensure operators get exported
Initial version, still unstable
comments powered byDisqus