turtle-1.2.0: Shell programming, Haskell-style

Safe HaskellNone




See Turtle.Tutorial to learn how to use this library or Turtle.Prelude for a quick-start guide.

Here is the recommended way to import this library:

{-# LANGUAGE OverloadedStrings #-}

import Turtle
import Prelude hiding (FilePath)

This module re-exports the rest of the library and also re-exports useful modules from base:

Turtle.Format provides type-safe string formatting

Turtle.Pattern provides Patterns, which are like more powerful regular expressions

Turtle.Shell provides a Shell abstraction for building streaming, exception-safe pipelines

Turtle.Prelude provides a library of Unix-like utilities to get you started with basic shell-like programming within Haskell

Control.Applicative provides two classes:

Control.Monad provides two classes:

Control.Monad.IO.Class provides one class:

Data.Monoid provides one class:

Control.Monad.Managed.Safe provides Managed resources

Filesystem.Path.CurrentOS provides FilePath-manipulation utilities

Additionally, you might also want to import the following modules qualified:



data Fold a b :: * -> * -> * where

Efficient representation of a left fold that preserves the fold's step function, initial accumulator, and extraction function

This allows the Applicative instance to assemble derived folds that traverse the container only once

A 'Fold a b' processes elements of type a and results in a value of type b.


Fold :: (x -> a -> x) -> x -> (x -> b) -> Fold a b

Fold step initial extract


Profunctor Fold 
Functor (Fold a) 
Applicative (Fold a) 
Floating b => Floating (Fold a b) 
Fractional b => Fractional (Fold a b) 
Num b => Num (Fold a b) 
Monoid b => Monoid (Fold a b) 

data FoldM m a b :: (* -> *) -> * -> * -> * where

Like Fold, but monadic.

A 'FoldM m a b' processes elements of type a and results in a monadic value of type m b.


FoldM :: (x -> a -> m x) -> m x -> (x -> m b) -> FoldM m a b

FoldM step initial extract


Monad m => Functor (FoldM m a) 
Monad m => Applicative (FoldM m a) 
(Monad m, Floating b) => Floating (FoldM m a b) 
(Monad m, Fractional b) => Fractional (FoldM m a b) 
(Monad m, Num b) => Num (FoldM m a b) 
(Monoid b, Monad m) => Monoid (FoldM m a b) 

data Text :: *

A space efficient, packed, unboxed Unicode text type.


IsList Text 
Eq Text 
Data Text

This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.

This instance was created by copying the updated behavior of Data.Set.Set and Data.Map.Map. If you feel a mistake has been made, please feel free to submit improvements.

The original discussion is archived here: could we get a Data instance for Data.Text.Text?

The followup discussion that changed the behavior of Set and Map is archived here: Proposal: Allow gunfold for Data.Map, ...

Ord Text 
Read Text 
Show Text 
IsString Text 
Monoid Text 
Binary Text 
NFData Text 
Hashable Text 
Semigroup Text 
Typeable * Text 
type Item Text = Char 

data UTCTime :: *

This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.

data NominalDiffTime :: *

This is a length of time, as measured by UTC. Conversion functions will treat it as seconds. It has a precision of 10^-12 s. It ignores leap-seconds, so it's not necessarily a fixed amount of clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.

data Handle :: *

Haskell defines operations to read and write characters from and to files, represented by values of type Handle. Each value of this type is a handle: a record used by the Haskell run-time system to manage I/O with file system objects. A handle has at least the following properties:

  • whether it manages input or output or both;
  • whether it is open, closed or semi-closed;
  • whether the object is seekable;
  • whether buffering is disabled, or enabled on a line or block basis;
  • a buffer (whose length may be zero).

Most handles will also have a current I/O position indicating where the next input or output operation will occur. A handle is readable if it manages only input or both input and output; likewise, it is writable if it manages only output or both input and output. A handle is open when first allocated. Once it is closed it can no longer be used for either input or output, though an implementation cannot re-use its storage while references remain to it. Handles are in the Show and Eq classes. The string produced by showing a handle is system dependent; it should include enough information to identify the handle for debugging. A handle is equal according to == only to itself; no attempt is made to compare the internal state of different handles for equality.

data ExitCode :: *

Defines the exit codes that a program can return.



indicates successful termination;

ExitFailure Int

indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system).

class IsString a where

Class for string-like datastructures; used by the overloaded string extension (-XOverloadedStrings in GHC).


fromString :: String -> a

(&) :: a -> (a -> b) -> b infixl 1 Source

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.