Prelude

The Prelude: a standard module. The Prelude is imported by default into all Haskell modules unless either there is an explicit import statement for it, or the NoImplicitPrelude extension is enabled.
Mostly for compatibility across different base Prelude changes.
Custom GHC Prelude This module serves as a replacement for the Prelude module and abstracts over differences between the bootstrapping GHC version, and may also provide a common default vocabulary.
General purpose utilities The names in this module clash heavily with the Haskell Prelude, so I recommend the following import scheme:
import Pipes
import qualified Pipes.Prelude as P  -- or use any other qualifier you prefer
Note that String-based IO is inefficient. The String-based utilities in this module exist only for simple demonstrations without incurring a dependency on the text package. Also, stdinLn and stdoutLn remove and add newlines, respectively. This behavior is intended to simplify examples. The corresponding stdin and stdout utilities from pipes-bytestring and pipes-text preserve newlines.
A module to re-export most of the functionality of the diagrams core and standard library.
The names exported by this module are closely modeled on those in Prelude and Data.List, but also on Pipes.Prelude, Pipes.Group and Pipes.Parse. The module may be said to give independent expression to the conception of Producer / Source / Generator manipulation articulated in the latter two modules. Because we dispense with piping and conduiting, the distinction between all of these modules collapses. Some things are lost but much is gained: on the one hand, everything comes much closer to ordinary beginning Haskell programming and, on the other, acquires the plasticity of programming directly with a general free monad type. The leading type, Stream (Of a) m r is chosen to permit an api that is as close as possible to that of Data.List and the Prelude. Import qualified thus:
import Streaming
import qualified Streaming.Prelude as S
For the examples below, one sometimes needs
import Streaming.Prelude (each, yield, next, mapped, stdoutLn, stdinLn)
import Data.Function ((&))
Other libraries that come up in passing are
import qualified Control.Foldl as L -- cabal install foldl
import qualified Pipes as P
import qualified Pipes.Prelude as P
import qualified System.IO as IO
Here are some correspondences between the types employed here and elsewhere:
streaming             |            pipes               |       conduit       |  io-streams
-------------------------------------------------------------------------------------------------------------------
Stream (Of a) m ()                  | Producer a m ()                | Source m a          | InputStream a
| ListT m a                      | ConduitM () o m ()  | Generator r ()
-------------------------------------------------------------------------------------------------------------------
Stream (Of a) m r                   | Producer a m r                 | ConduitM () o m r   | Generator a r
-------------------------------------------------------------------------------------------------------------------
Stream (Of a) m (Stream (Of a) m r) | Producer a m (Producer a m r)  |
--------------------------------------------------------------------------------------------------------------------
Stream (Stream (Of a) m) r          | FreeT (Producer a m) m r       |
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
ByteString m ()                     | Producer ByteString m ()       | Source m ByteString  | InputStream ByteString
--------------------------------------------------------------------------------------------------------------------
This module provides a large suite of utilities that resemble Unix utilities. Many of these commands are just existing Haskell commands renamed to match their Unix counterparts:
>>> :set -XOverloadedStrings

>>> cd "/tmp"

>>> pwd
FilePath "/tmp"
Some commands are Shells that emit streams of values. view prints all values in a Shell stream:
>>> view (ls "/usr")
FilePath "/usr/lib"
FilePath "/usr/src"
FilePath "/usr/sbin"
FilePath "/usr/include"
FilePath "/usr/share"
FilePath "/usr/games"
FilePath "/usr/local"
FilePath "/usr/bin"

>>> view (find (suffix "Browser.py") "/usr/lib")
FilePath "/usr/lib/python3.4/idlelib/ClassBrowser.py"
FilePath "/usr/lib/python3.4/idlelib/RemoteObjectBrowser.py"
FilePath "/usr/lib/python3.4/idlelib/PathBrowser.py"
FilePath "/usr/lib/python3.4/idlelib/ObjectBrowser.py"
Use fold to reduce the output of a Shell stream:
>>> import qualified Control.Foldl as Fold

>>> fold (ls "/usr") Fold.length
8

>>> fold (find (suffix "Browser.py") "/usr/lib") Fold.head
Just (FilePath "/usr/lib/python3.4/idlelib/ClassBrowser.py")
Create files using output:
>>> output "foo.txt" ("123" <|> "456" <|> "ABC")

>>> realpath "foo.txt"
FilePath "/tmp/foo.txt"
Read in files using input:
>>> stdout (input "foo.txt")
123
456
ABC
Format strings in a type safe way using format:
>>> dir <- pwd

>>> format ("I am in the "%fp%" directory") dir
"I am in the /tmp directory"
Commands like grep, sed and find accept arbitrary Patterns
>>> stdout (grep ("123" <|> "ABC") (input "foo.txt"))
123
ABC

>>> let exclaim = fmap (<> "!") (plus digit)

>>> stdout (sed exclaim (input "foo.txt"))
123!
456!
ABC
Note that grep and find differ from their Unix counterparts by requiring that the Pattern matches the entire line or file name by default. However, you can optionally match the prefix, suffix, or interior of a line:
>>> stdout (grep (has    "2") (input "foo.txt"))
123

>>> stdout (grep (prefix "1") (input "foo.txt"))
123

>>> stdout (grep (suffix "3") (input "foo.txt"))
123
You can also build up more sophisticated Shell programs using sh in conjunction with do notation:
{-# LANGUAGE OverloadedStrings #-}

import Turtle

main = sh example

example = do
-- Read in file names from "files1.txt" and "files2.txt"
file <- fmap fromText (input "files1.txt" <|> input "files2.txt")

-- Stream each file to standard output only if the file exists
True <- liftIO (testfile file)
line <- input file
liftIO (echo line)
See Turtle.Tutorial for an extended tutorial explaining how to use this library in greater detail.
Simple resource management functions
This module re-exports the Streamly.Data.Stream module from the "streamly-core" package and additionally provides concurrency, time and lifted exception operations as well in a single module. Also see the following modules for more pre-release operations:
Deprecated: Please use Streamly.Data.Stream.Prelude from streamly package and Streamly.Data.Fold from streamly-core package instead.
This module does two things:
  • Acts as a compatibility layer, like base-compat.
  • Provides commonly used imports.
This module may change between minor releases. Do not rely on its contents.
A prelude composed by overlaying numhask on Prelude, together with a few minor tweaks needed for RebindableSyntax.
Generic deriving for standard classes in base

Warning

This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time. If something here seems useful, please report it or create a pull request to export it from an external module.

Summary

This module supplies a convenient set of imports for working with the dimensional package, including aliases for common Quantitys and Dimensions, and a comprehensive set of SI units and units accepted for use with the SI. It re-exports the Prelude, hiding arithmetic functions whose names collide with the dimensionally-typed versions supplied by this package.
This module reexports the non-conflicting definitions from the modules exported by this package, providing a much more featureful alternative to the standard Prelude. For details check out the source.
This module contains convenience functions that clash with names in Prelude and is intended to be imported qualified.
| Copyright: (C) 2013 Amgen, Inc. DEPRECATED: use Language.R instead.
Utility functions and re-exports for a more ergonomic developing experience. Users themselves will not find much use here.
The bidirectional "Prelude", which re-exports various bijections similar to functions from Prelude. Most "un"-functions are left out for obvious reasons.