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.
Internal modules are always subject to change from version to version.
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.
Mimics the Haskell Prelude, but with singleton types. Includes the basic singleton definitions. Note: This is currently very incomplete! Because many of these definitions are produced by Template Haskell, it is not possible to create proper Haddock documentation. Also, please excuse the apparent repeated variable names. This is due to an interaction between Template Haskell and Haddock.
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 "") "/usr/lib")
FilePath "/usr/lib/python3.4/idlelib/"
FilePath "/usr/lib/python3.4/idlelib/"
FilePath "/usr/lib/python3.4/idlelib/"
FilePath "/usr/lib/python3.4/idlelib/"
Use fold to reduce the output of a Shell stream:
>>> import qualified Control.Foldl as Fold

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

>>> fold (find (suffix "") "/usr/lib") Fold.head
Just (FilePath "/usr/lib/python3.4/idlelib/")
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")
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"))

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

>>> stdout (sed exclaim (input "foo.txt"))
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"))

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

>>> stdout (grep (suffix "3") (input "foo.txt"))
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 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 is an Internal module consisting of released, unreleased and unimplemented APIs. For stable and released APIs please see Streamly.Prelude module. This module provides documentation only for the unreleased and unimplemented APIs. For documentation on released APIs please see Streamly.Prelude module.
This module is designed to be imported qualified:
import qualified Streamly.Prelude as S
Functions with the suffix M are general functions that work on monadic arguments. The corresponding functions without the suffix M work on pure arguments and can in general be derived from their monadic versions but are provided for convenience and for consistency with other pure APIs in the base package. In many cases, short definitions of the combinators are provided in the documentation for illustration. The actual implementation may differ for performance reasons. Functions having a MonadAsync constraint work concurrently when used with appropriate stream type combinator. Please be careful to not use parallely with infinite streams. Deconstruction and folds accept a SerialT type instead of a polymorphic type to ensure that streams always have a concrete monomorphic type by default, reducing type errors. In case you want to use any other type of stream you can use one of the type combinators provided in the Streamly module to convert the stream type.
This module defines the explicitly clocked counterparts of the functions defined in Clash.Prelude.
Clash is a functional hardware description language that borrows both its syntax and semantics from the functional programming language Haskell. The merits of using a functional language to describe hardware comes from the fact that combinational circuits can be directly modeled as mathematical functions and that functional languages lend themselves very well at describing and (de-)composing mathematical functions. This package provides:
  • Prelude library containing datatypes and functions for circuit design
To use the library: For now, Clash.Prelude is also the best starting point for exploring the library. A preliminary version of a tutorial can be found in Clash.Tutorial. Some circuit examples can be found in Clash.Examples.
This module is presents a prelude mostly like the post-Applicative-Monad world of base >= 4.8 / ghc >= 7.10, as well as the post-Semigroup-Monoid world of base >= 4.11 / ghc >= 8.4, even on earlier versions. It's intended as an internal library for llvm-hs-pure and llvm-hs; it's exposed only to be shared between the two.
Generic deriving for standard classes in base


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.
This module contains convenience functions that clash with names in Prelude and is intended to be imported qualified.
The bidirectional "Prelude", which re-exports various bijections similar to functions from Prelude. Most "un"-functions are left out for obvious reasons.
Custom Prelude, compatible across many GHC versions.