BSD-3-Clause licensed and maintained by Neil Mitchell

Module documentation for 1.0

This version can be pinned in stack with:[email protected]:d4393e372b4bca0c8a47a3780430c3548879921bf41c56c1fefabf79e51acdb7,2465
  • Control
    • Control.Concurrent
      • Control.Concurrent.Extra
    • Control.Exception
      • Control.Exception.Extra
    • Control.Monad
      • Control.Monad.Extra
  • Data
    • Data.Either
      • Data.Either.Extra
    • Data.IORef
      • Data.IORef.Extra
    • Data.List
      • Data.List.Extra
    • Data.Tuple
      • Data.Tuple.Extra
  • Extra
  • Numeric
    • Numeric.Extra
  • System
    • System.Directory
      • System.Directory.Extra
    • System.Environment
      • System.Environment.Extra
    • System.IO
      • System.IO.Extra
    • System.Info
      • System.Info.Extra
    • System.Process
      • System.Process.Extra
    • System.Time
      • System.Time.Extra

Extra Hackage 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.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 functional 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.

Changes

Changelog for Extra

1.0
No changes
0.8
Fix a bug in writeFileEncoding/writeFileUTF8
0.7
Fix for missing case in withNumCapabilities
0.6
Ensure barrier is thread-safe
Make subsequent signalBarrier calls throw an exception
Add timeout function
Make sure sleep never wraps round an Int
0.5.1
Use uncons from GHC 7.9 and above
0.5
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
0.4
Remove all but the extractors on triples
Remove groupSortOn
Remove dropAround
0.3.2
Remove use of ===, allows older QuickCheck versions
0.3.1
Fix a bug in breakEnd/spanEnd
0.3
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
0.2
Redo the cons/uncons functions
Add withTempDir
Rename withTemporaryFile to withTempFile
Change trim to strip (follow text naming convention)
Ensure operators get exported
0.1
Initial version, still unstable
Used by 4 packages in lts-0.7(full list with versions):