tidal-0.9.10: Pattern language for improvised music

Safe HaskellNone
LanguageHaskell2010

Sound.Tidal.Context

Synopsis

Documentation

(++) :: [a] -> [a] -> [a] infixr 5 #

Append two lists, i.e.,

[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]

If the first list is not finite, the result is the first list.

filter :: (a -> Bool) -> [a] -> [a] #

filter, applied to a predicate and a list, returns the list of those elements that satisfy the predicate; i.e.,

filter p xs = [ x | x <- xs, p x]

zip :: [a] -> [b] -> [(a, b)] #

zip takes two lists and returns a list of corresponding pairs. If one input list is short, excess elements of the longer list are discarded.

zip is right-lazy:

zip [] _|_ = []

map :: (a -> b) -> [a] -> [b] #

map f xs is the list obtained by applying f to each element of xs, i.e.,

map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
map f [x1, x2, ...] == [f x1, f x2, ...]

(<$) :: Functor f => a -> f b -> f a infixl 4 #

Replace all locations in the input with the same value. The default definition is fmap . const, but this may be overridden with a more efficient version.

class Functor f => Applicative (f :: * -> *) where #

A functor with application, providing operations to

  • embed pure expressions (pure), and
  • sequence computations and combine their results (<*> and liftA2).

A minimal complete definition must include implementations of pure and of either <*> or liftA2. If it defines both, then they must behave the same as their default definitions:

(<*>) = liftA2 id
liftA2 f x y = f <$> x <*> y

Further, any definition must satisfy the following:

identity
pure id <*> v = v
composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
homomorphism
pure f <*> pure x = pure (f x)
interchange
u <*> pure y = pure ($ y) <*> u

The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:

As a consequence of these laws, the Functor instance for f will satisfy

It may be useful to note that supposing

forall x y. p (q x y) = f x . g y

it follows from the above that

liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v

If f is also a Monad, it should satisfy

(which implies that pure and <*> satisfy the applicative functor laws).

Minimal complete definition

pure, ((<*>) | liftA2)

Methods

pure :: a -> f a #

Lift a value.

(<*>) :: f (a -> b) -> f a -> f b infixl 4 #

Sequential application.

A few functors support an implementation of <*> that is more efficient than the default one.

liftA2 :: (a -> b -> c) -> f a -> f b -> f c #

Lift a binary function to actions.

Some functors support an implementation of liftA2 that is more efficient than the default one. In particular, if fmap is an expensive operation, it is likely better to use liftA2 than to fmap over the structure and then use <*>.

(*>) :: f a -> f b -> f b infixl 4 #

Sequence actions, discarding the value of the first argument.

(<*) :: f a -> f b -> f a infixl 4 #

Sequence actions, discarding the value of the second argument.

Instances
Applicative []

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

pure :: a -> [a] #

(<*>) :: [a -> b] -> [a] -> [b] #

liftA2 :: (a -> b -> c) -> [a] -> [b] -> [c] #

(*>) :: [a] -> [b] -> [b] #

(<*) :: [a] -> [b] -> [a] #

Applicative Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

pure :: a -> Maybe a #

(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b #

liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c #

(*>) :: Maybe a -> Maybe b -> Maybe b #

(<*) :: Maybe a -> Maybe b -> Maybe a #

Applicative IO

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

pure :: a -> IO a #

(<*>) :: IO (a -> b) -> IO a -> IO b #

liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c #

(*>) :: IO a -> IO b -> IO b #

(<*) :: IO a -> IO b -> IO a #

Applicative Par1

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

pure :: a -> Par1 a #

(<*>) :: Par1 (a -> b) -> Par1 a -> Par1 b #

liftA2 :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c #

(*>) :: Par1 a -> Par1 b -> Par1 b #

(<*) :: Par1 a -> Par1 b -> Par1 a #

Applicative Min

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

pure :: a -> Min a #

(<*>) :: Min (a -> b) -> Min a -> Min b #

liftA2 :: (a -> b -> c) -> Min a -> Min b -> Min c #

(*>) :: Min a -> Min b -> Min b #

(<*) :: Min a -> Min b -> Min a #

Applicative Max

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

pure :: a -> Max a #

(<*>) :: Max (a -> b) -> Max a -> Max b #

liftA2 :: (a -> b -> c) -> Max a -> Max b -> Max c #

(*>) :: Max a -> Max b -> Max b #

(<*) :: Max a -> Max b -> Max a #

Applicative First

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

pure :: a -> First a #

(<*>) :: First (a -> b) -> First a -> First b #

liftA2 :: (a -> b -> c) -> First a -> First b -> First c #

(*>) :: First a -> First b -> First b #

(<*) :: First a -> First b -> First a #

Applicative Last

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

pure :: a -> Last a #

(<*>) :: Last (a -> b) -> Last a -> Last b #

liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c #

(*>) :: Last a -> Last b -> Last b #

(<*) :: Last a -> Last b -> Last a #

Applicative Option

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

pure :: a -> Option a #

(<*>) :: Option (a -> b) -> Option a -> Option b #

liftA2 :: (a -> b -> c) -> Option a -> Option b -> Option c #

(*>) :: Option a -> Option b -> Option b #

(<*) :: Option a -> Option b -> Option a #

Applicative ZipList
f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
    = 'ZipList' (zipWithN f xs1 ... xsN)

where zipWithN refers to the zipWith function of the appropriate arity (zipWith, zipWith3, zipWith4, ...). For example:

(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
    = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
    = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

pure :: a -> ZipList a #

(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b #

liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c #

(*>) :: ZipList a -> ZipList b -> ZipList b #

(<*) :: ZipList a -> ZipList b -> ZipList a #

Applicative Identity

Since: base-4.8.0.0

Instance details

Defined in Data.Functor.Identity

Methods

pure :: a -> Identity a #

(<*>) :: Identity (a -> b) -> Identity a -> Identity b #

liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c #

(*>) :: Identity a -> Identity b -> Identity b #

(<*) :: Identity a -> Identity b -> Identity a #

Applicative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

pure :: a -> STM a #

(<*>) :: STM (a -> b) -> STM a -> STM b #

liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c #

(*>) :: STM a -> STM b -> STM b #

(<*) :: STM a -> STM b -> STM a #

Applicative First 
Instance details

Defined in Data.Monoid

Methods

pure :: a -> First a #

(<*>) :: First (a -> b) -> First a -> First b #

liftA2 :: (a -> b -> c) -> First a -> First b -> First c #

(*>) :: First a -> First b -> First b #

(<*) :: First a -> First b -> First a #

Applicative Last 
Instance details

Defined in Data.Monoid

Methods

pure :: a -> Last a #

(<*>) :: Last (a -> b) -> Last a -> Last b #

liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c #

(*>) :: Last a -> Last b -> Last b #

(<*) :: Last a -> Last b -> Last a #

Applicative Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Dual a #

(<*>) :: Dual (a -> b) -> Dual a -> Dual b #

liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c #

(*>) :: Dual a -> Dual b -> Dual b #

(<*) :: Dual a -> Dual b -> Dual a #

Applicative Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Sum a #

(<*>) :: Sum (a -> b) -> Sum a -> Sum b #

liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c #

(*>) :: Sum a -> Sum b -> Sum b #

(<*) :: Sum a -> Sum b -> Sum a #

Applicative Product

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Product a #

(<*>) :: Product (a -> b) -> Product a -> Product b #

liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c #

(*>) :: Product a -> Product b -> Product b #

(<*) :: Product a -> Product b -> Product a #

Applicative Down

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

pure :: a -> Down a #

(<*>) :: Down (a -> b) -> Down a -> Down b #

liftA2 :: (a -> b -> c) -> Down a -> Down b -> Down c #

(*>) :: Down a -> Down b -> Down b #

(<*) :: Down a -> Down b -> Down a #

Applicative ReadP

Since: base-4.6.0.0

Instance details

Defined in Text.ParserCombinators.ReadP

Methods

pure :: a -> ReadP a #

(<*>) :: ReadP (a -> b) -> ReadP a -> ReadP b #

liftA2 :: (a -> b -> c) -> ReadP a -> ReadP b -> ReadP c #

(*>) :: ReadP a -> ReadP b -> ReadP b #

(<*) :: ReadP a -> ReadP b -> ReadP a #

Applicative NonEmpty

Since: base-4.9.0.0

Instance details

Defined in GHC.Base

Methods

pure :: a -> NonEmpty a #

(<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b #

liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #

(*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #

(<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a #

Applicative RGB 
Instance details

Defined in Data.Colour.RGB

Methods

pure :: a -> RGB a #

(<*>) :: RGB (a -> b) -> RGB a -> RGB b #

liftA2 :: (a -> b -> c) -> RGB a -> RGB b -> RGB c #

(*>) :: RGB a -> RGB b -> RGB b #

(<*) :: RGB a -> RGB b -> RGB a #

Applicative P

Since: base-4.5.0.0

Instance details

Defined in Text.ParserCombinators.ReadP

Methods

pure :: a -> P a #

(<*>) :: P (a -> b) -> P a -> P b #

liftA2 :: (a -> b -> c) -> P a -> P b -> P c #

(*>) :: P a -> P b -> P b #

(<*) :: P a -> P b -> P a #

Applicative Pattern #

pure a returns a pattern with an event with value a, which has a duration of one cycle, and repeats every cycle.

Instance details

Defined in Sound.Tidal.Pattern

Methods

pure :: a -> Pattern a #

(<*>) :: Pattern (a -> b) -> Pattern a -> Pattern b #

liftA2 :: (a -> b -> c) -> Pattern a -> Pattern b -> Pattern c #

(*>) :: Pattern a -> Pattern b -> Pattern b #

(<*) :: Pattern a -> Pattern b -> Pattern a #

Applicative Sieve # 
Instance details

Defined in Sound.Tidal.Sieve

Methods

pure :: a -> Sieve a #

(<*>) :: Sieve (a -> b) -> Sieve a -> Sieve b #

liftA2 :: (a -> b -> c) -> Sieve a -> Sieve b -> Sieve c #

(*>) :: Sieve a -> Sieve b -> Sieve b #

(<*) :: Sieve a -> Sieve b -> Sieve a #

Applicative (Either e)

Since: base-3.0

Instance details

Defined in Data.Either

Methods

pure :: a -> Either e a #

(<*>) :: Either e (a -> b) -> Either e a -> Either e b #

liftA2 :: (a -> b -> c) -> Either e a -> Either e b -> Either e c #

(*>) :: Either e a -> Either e b -> Either e b #

(<*) :: Either e a -> Either e b -> Either e a #

Applicative (U1 :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

pure :: a -> U1 a #

(<*>) :: U1 (a -> b) -> U1 a -> U1 b #

liftA2 :: (a -> b -> c) -> U1 a -> U1 b -> U1 c #

(*>) :: U1 a -> U1 b -> U1 b #

(<*) :: U1 a -> U1 b -> U1 a #

Monoid a => Applicative ((,) a)

For tuples, the Monoid constraint on a determines how the first values merge. For example, Strings concatenate:

("hello ", (+15)) <*> ("world!", 2002)
("hello world!",2017)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

pure :: a0 -> (a, a0) #

(<*>) :: (a, a0 -> b) -> (a, a0) -> (a, b) #

liftA2 :: (a0 -> b -> c) -> (a, a0) -> (a, b) -> (a, c) #

(*>) :: (a, a0) -> (a, b) -> (a, b) #

(<*) :: (a, a0) -> (a, b) -> (a, a0) #

Monad m => Applicative (WrappedMonad m)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

pure :: a -> WrappedMonad m a #

(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b #

liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c #

(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #

(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a #

Arrow a => Applicative (ArrowMonad a)

Since: base-4.6.0.0

Instance details

Defined in Control.Arrow

Methods

pure :: a0 -> ArrowMonad a a0 #

(<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b #

liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c #

(*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b #

(<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 #

Applicative (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

pure :: a -> Proxy a #

(<*>) :: Proxy (a -> b) -> Proxy a -> Proxy b #

liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c #

(*>) :: Proxy a -> Proxy b -> Proxy b #

(<*) :: Proxy a -> Proxy b -> Proxy a #

Applicative f => Applicative (Rec1 f)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

pure :: a -> Rec1 f a #

(<*>) :: Rec1 f (a -> b) -> Rec1 f a -> Rec1 f b #

liftA2 :: (a -> b -> c) -> Rec1 f a -> Rec1 f b -> Rec1 f c #

(*>) :: Rec1 f a -> Rec1 f b -> Rec1 f b #

(<*) :: Rec1 f a -> Rec1 f b -> Rec1 f a #

Arrow a => Applicative (WrappedArrow a b)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

pure :: a0 -> WrappedArrow a b a0 #

(<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 #

liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c #

(*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 #

(<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 #

Monoid m => Applicative (Const m :: * -> *)

Since: base-2.0.1

Instance details

Defined in Data.Functor.Const

Methods

pure :: a -> Const m a #

(<*>) :: Const m (a -> b) -> Const m a -> Const m b #

liftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c #

(*>) :: Const m a -> Const m b -> Const m b #

(<*) :: Const m a -> Const m b -> Const m a #

Applicative f => Applicative (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Alt f a #

(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b #

liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c #

(*>) :: Alt f a -> Alt f b -> Alt f b #

(<*) :: Alt f a -> Alt f b -> Alt f a #

(Functor m, Monad m) => Applicative (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

pure :: a -> ErrorT e m a #

(<*>) :: ErrorT e m (a -> b) -> ErrorT e m a -> ErrorT e m b #

liftA2 :: (a -> b -> c) -> ErrorT e m a -> ErrorT e m b -> ErrorT e m c #

(*>) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m b #

(<*) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m a #

Applicative ((->) a :: * -> *)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

pure :: a0 -> a -> a0 #

(<*>) :: (a -> a0 -> b) -> (a -> a0) -> a -> b #

liftA2 :: (a0 -> b -> c) -> (a -> a0) -> (a -> b) -> a -> c #

(*>) :: (a -> a0) -> (a -> b) -> a -> b #

(<*) :: (a -> a0) -> (a -> b) -> a -> a0 #

(Applicative f, Applicative g) => Applicative (f :*: g)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

pure :: a -> (f :*: g) a #

(<*>) :: (f :*: g) (a -> b) -> (f :*: g) a -> (f :*: g) b #

liftA2 :: (a -> b -> c) -> (f :*: g) a -> (f :*: g) b -> (f :*: g) c #

(*>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b #

(<*) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) a #

(Applicative f, Monad f) => Applicative (WhenMissing f k x)

Equivalent to ReaderT k (ReaderT x (MaybeT f)) .

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

pure :: a -> WhenMissing f k x a #

(<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b #

liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c #

(*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b #

(<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a #

Applicative (ParsecT s u m) 
Instance details

Defined in Text.Parsec.Prim

Methods

pure :: a -> ParsecT s u m a #

(<*>) :: ParsecT s u m (a -> b) -> ParsecT s u m a -> ParsecT s u m b #

liftA2 :: (a -> b -> c) -> ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m c #

(*>) :: ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m b #

(<*) :: ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m a #

Applicative f => Applicative (M1 i c f)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

pure :: a -> M1 i c f a #

(<*>) :: M1 i c f (a -> b) -> M1 i c f a -> M1 i c f b #

liftA2 :: (a -> b -> c0) -> M1 i c f a -> M1 i c f b -> M1 i c f c0 #

(*>) :: M1 i c f a -> M1 i c f b -> M1 i c f b #

(<*) :: M1 i c f a -> M1 i c f b -> M1 i c f a #

(Applicative f, Applicative g) => Applicative (f :.: g)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

pure :: a -> (f :.: g) a #

(<*>) :: (f :.: g) (a -> b) -> (f :.: g) a -> (f :.: g) b #

liftA2 :: (a -> b -> c) -> (f :.: g) a -> (f :.: g) b -> (f :.: g) c #

(*>) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) b #

(<*) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) a #

(Monad f, Applicative f) => Applicative (WhenMatched f k x y)

Equivalent to ReaderT k (ReaderT x (ReaderT y (MaybeT f)))

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

pure :: a -> WhenMatched f k x y a #

(<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b #

liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c #

(*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b #

(<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a #

foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b #

Right-associative fold of a structure.

In the case of lists, foldr, when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left:

foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)

Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, foldr can produce a terminating expression from an infinite list.

For a general Foldable structure this should be semantically identical to,

foldr f z = foldr f z . toList

length :: Foldable t => t a -> Int #

Returns the size/length of a finite structure as an Int. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

null :: Foldable t => t a -> Bool #

Test whether the structure is empty. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b #

Left-associative fold of a structure.

In the case of lists, foldl, when applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn

Note that to produce the outermost application of the operator the entire input list must be traversed. This means that foldl' will diverge if given an infinite list.

Also note that if you want an efficient left-fold, you probably want to use foldl' instead of foldl. The reason for this is that latter does not force the "inner" results (e.g. z f x1 in the above example) before applying them to the operator (e.g. to (f x2)). This results in a thunk chain O(n) elements long, which then must be evaluated from the outside-in.

For a general Foldable structure this should be semantically identical to,

foldl f z = foldl f z . toList

foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b #

Left-associative fold of a structure but with strict application of the operator.

This ensures that each step of the fold is forced to weak head normal form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite list to a single, monolithic result (e.g. length).

For a general Foldable structure this should be semantically identical to,

foldl f z = foldl' f z . toList

foldl1 :: Foldable t => (a -> a -> a) -> t a -> a #

A variant of foldl that has no base case, and thus may only be applied to non-empty structures.

foldl1 f = foldl1 f . toList

sum :: (Foldable t, Num a) => t a -> a #

The sum function computes the sum of the numbers of a structure.

product :: (Foldable t, Num a) => t a -> a #

The product function computes the product of the numbers of a structure.

foldr1 :: Foldable t => (a -> a -> a) -> t a -> a #

A variant of foldr that has no base case, and thus may only be applied to non-empty structures.

foldr1 f = foldr1 f . toList

maximum :: (Foldable t, Ord a) => t a -> a #

The largest element of a non-empty structure.

minimum :: (Foldable t, Ord a) => t a -> a #

The least element of a non-empty structure.

elem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 #

Does the element occur in the structure?

(<>) :: Semigroup a => a -> a -> a infixr 6 #

An associative operation.

class Semigroup a => Monoid a where #

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product.

NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

Minimal complete definition

mempty

Methods

mempty :: a #

Identity of mappend

mappend :: a -> a -> a #

An associative operation

NOTE: This method is redundant and has the default implementation mappend = '(<>)' since base-4.11.0.0.

mconcat :: [a] -> a #

Fold a list using the monoid.

For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

Instances
Monoid Ordering

Since: base-2.1

Instance details

Defined in GHC.Base

Monoid ()

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: () #

mappend :: () -> () -> () #

mconcat :: [()] -> () #

Monoid ByteString 
Instance details

Defined in Data.ByteString.Internal

Monoid ByteString 
Instance details

Defined in Data.ByteString.Lazy.Internal

Monoid All

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: All #

mappend :: All -> All -> All #

mconcat :: [All] -> All #

Monoid Any

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Any #

mappend :: Any -> Any -> Any #

mconcat :: [Any] -> Any #

Monoid [a]

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: [a] #

mappend :: [a] -> [a] -> [a] #

mconcat :: [[a]] -> [a] #

Semigroup a => Monoid (Maybe a)

Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S."

Since 4.11.0: constraint on inner a value generalised from Monoid to Semigroup.

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: Maybe a #

mappend :: Maybe a -> Maybe a -> Maybe a #

mconcat :: [Maybe a] -> Maybe a #

Monoid a => Monoid (IO a)

Since: base-4.9.0.0

Instance details

Defined in GHC.Base

Methods

mempty :: IO a #

mappend :: IO a -> IO a -> IO a #

mconcat :: [IO a] -> IO a #

(Ord a, Bounded a) => Monoid (Min a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

mempty :: Min a #

mappend :: Min a -> Min a -> Min a #

mconcat :: [Min a] -> Min a #

(Ord a, Bounded a) => Monoid (Max a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

mempty :: Max a #

mappend :: Max a -> Max a -> Max a #

mconcat :: [Max a] -> Max a #

Monoid m => Monoid (WrappedMonoid m)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Semigroup a => Monoid (Option a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

mempty :: Option a #

mappend :: Option a -> Option a -> Option a #

mconcat :: [Option a] -> Option a #

Monoid a => Monoid (Identity a) 
Instance details

Defined in Data.Functor.Identity

Methods

mempty :: Identity a #

mappend :: Identity a -> Identity a -> Identity a #

mconcat :: [Identity a] -> Identity a #

Monoid (First a)

Since: base-2.1

Instance details

Defined in Data.Monoid

Methods

mempty :: First a #

mappend :: First a -> First a -> First a #

mconcat :: [First a] -> First a #

Monoid (Last a)

Since: base-2.1

Instance details

Defined in Data.Monoid

Methods

mempty :: Last a #

mappend :: Last a -> Last a -> Last a #

mconcat :: [Last a] -> Last a #

Monoid a => Monoid (Dual a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Dual a #

mappend :: Dual a -> Dual a -> Dual a #

mconcat :: [Dual a] -> Dual a #

Monoid (Endo a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Endo a #

mappend :: Endo a -> Endo a -> Endo a #

mconcat :: [Endo a] -> Endo a #

Num a => Monoid (Sum a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Sum a #

mappend :: Sum a -> Sum a -> Sum a #

mconcat :: [Sum a] -> Sum a #

Num a => Monoid (Product a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Product a #

mappend :: Product a -> Product a -> Product a #

mconcat :: [Product a] -> Product a #

Monoid a => Monoid (Down a)

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

mempty :: Down a #

mappend :: Down a -> Down a -> Down a #

mconcat :: [Down a] -> Down a #

Num a => Monoid (Colour a) 
Instance details

Defined in Data.Colour.Internal

Methods

mempty :: Colour a #

mappend :: Colour a -> Colour a -> Colour a #

mconcat :: [Colour a] -> Colour a #

Num a => Monoid (AlphaColour a) 
Instance details

Defined in Data.Colour.Internal

Monoid b => Monoid (a -> b)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: a -> b #

mappend :: (a -> b) -> (a -> b) -> a -> b #

mconcat :: [a -> b] -> a -> b #

(Monoid a, Monoid b) => Monoid (a, b)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: (a, b) #

mappend :: (a, b) -> (a, b) -> (a, b) #

mconcat :: [(a, b)] -> (a, b) #

Monoid (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

mempty :: Proxy s #

mappend :: Proxy s -> Proxy s -> Proxy s #

mconcat :: [Proxy s] -> Proxy s #

Ord k => Monoid (Map k v) 
Instance details

Defined in Data.Map.Internal

Methods

mempty :: Map k v #

mappend :: Map k v -> Map k v -> Map k v #

mconcat :: [Map k v] -> Map k v #

(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: (a, b, c) #

mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) #

mconcat :: [(a, b, c)] -> (a, b, c) #

Monoid a => Monoid (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

mempty :: Const a b #

mappend :: Const a b -> Const a b -> Const a b #

mconcat :: [Const a b] -> Const a b #

Alternative f => Monoid (Alt f a)

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Alt f a #

mappend :: Alt f a -> Alt f a -> Alt f a #

mconcat :: [Alt f a] -> Alt f a #

(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: (a, b, c, d) #

mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #

mconcat :: [(a, b, c, d)] -> (a, b, c, d) #

(Monoid a, Semigroup (ParsecT s u m a)) => Monoid (ParsecT s u m a)

The Monoid instance for ParsecT is used for the same purposes as the Semigroup instance.

Since: parsec-3.1.12

Instance details

Defined in Text.Parsec.Prim

Methods

mempty :: ParsecT s u m a #

mappend :: ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a #

mconcat :: [ParsecT s u m a] -> ParsecT s u m a #

(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

mempty :: (a, b, c, d, e) #

mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #

mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) #

data Ratio a #

Rational numbers, with numerator and denominator of some Integral type.

Instances
Enumerable Rational Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable Rational Source # 
Instance details

Defined in Sound.Tidal.Parse

Integral a => Enum (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

succ :: Ratio a -> Ratio a #

pred :: Ratio a -> Ratio a #

toEnum :: Int -> Ratio a #

fromEnum :: Ratio a -> Int #

enumFrom :: Ratio a -> [Ratio a] #

enumFromThen :: Ratio a -> Ratio a -> [Ratio a] #

enumFromTo :: Ratio a -> Ratio a -> [Ratio a] #

enumFromThenTo :: Ratio a -> Ratio a -> Ratio a -> [Ratio a] #

Eq a => Eq (Ratio a) 
Instance details

Defined in GHC.Real

Methods

(==) :: Ratio a -> Ratio a -> Bool #

(/=) :: Ratio a -> Ratio a -> Bool #

Integral a => Fractional (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

(/) :: Ratio a -> Ratio a -> Ratio a #

recip :: Ratio a -> Ratio a #

fromRational :: Rational -> Ratio a #

Integral a => Num (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

(+) :: Ratio a -> Ratio a -> Ratio a #

(-) :: Ratio a -> Ratio a -> Ratio a #

(*) :: Ratio a -> Ratio a -> Ratio a #

negate :: Ratio a -> Ratio a #

abs :: Ratio a -> Ratio a #

signum :: Ratio a -> Ratio a #

fromInteger :: Integer -> Ratio a #

Integral a => Ord (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

compare :: Ratio a -> Ratio a -> Ordering #

(<) :: Ratio a -> Ratio a -> Bool #

(<=) :: Ratio a -> Ratio a -> Bool #

(>) :: Ratio a -> Ratio a -> Bool #

(>=) :: Ratio a -> Ratio a -> Bool #

max :: Ratio a -> Ratio a -> Ratio a #

min :: Ratio a -> Ratio a -> Ratio a #

(Integral a, Read a) => Read (Ratio a)

Since: base-2.1

Instance details

Defined in GHC.Read

Integral a => Real (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

toRational :: Ratio a -> Rational #

Integral a => RealFrac (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

properFraction :: Integral b => Ratio a -> (b, Ratio a) #

truncate :: Integral b => Ratio a -> b #

round :: Integral b => Ratio a -> b #

ceiling :: Integral b => Ratio a -> b #

floor :: Integral b => Ratio a -> b #

Show a => Show (Ratio a)

Since: base-2.0.1

Instance details

Defined in GHC.Real

Methods

showsPrec :: Int -> Ratio a -> ShowS #

show :: Ratio a -> String #

showList :: [Ratio a] -> ShowS #

Hashable a => Hashable (Ratio a) 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Ratio a -> Int #

hash :: Ratio a -> Int #

type Rational = Ratio Integer #

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.

forkOnWithUnmask :: Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId #

Like forkIOWithUnmask, but the child thread is pinned to the given CPU, as with forkOn.

Since: base-4.4.0.0

forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId #

Like forkIO, but the child thread is passed a function that can be used to unmask asynchronous exceptions. This function is typically used in the following way

 ... mask_ $ forkIOWithUnmask $ \unmask ->
                catch (unmask ...) handler

so that the exception handler in the child thread is established with asynchronous exceptions masked, meanwhile the main body of the child thread is executed in the unmasked state.

Note that the unmask function passed to the child thread should only be used in that thread; the behaviour is undefined if it is invoked in a different thread.

Since: base-4.4.0.0

forkOn :: Int -> IO () -> IO ThreadId #

Like forkIO, but lets you specify on which capability the thread should run. Unlike a forkIO thread, a thread created by forkOn will stay on the same capability for its entire lifetime (forkIO threads can migrate between capabilities according to the scheduling policy). forkOn is useful for overriding the scheduling policy when you know in advance how best to distribute the threads.

The Int argument specifies a capability number (see getNumCapabilities). Typically capabilities correspond to physical processors, but the exact behaviour is implementation-dependent. The value passed to forkOn is interpreted modulo the total number of capabilities as returned by getNumCapabilities.

GHC note: the number of capabilities is specified by the +RTS -N option when the program is started. Capabilities can be fixed to actual processor cores with +RTS -qa if the underlying operating system supports that, although in practice this is usually unnecessary (and may actually degrade performance in some cases - experimentation is recommended).

Since: base-4.4.0.0

forkOS :: IO () -> IO ThreadId #

Like forkIO, this sparks off a new thread to run the IO computation passed as the first argument, and returns the ThreadId of the newly created thread.

However, forkOS creates a bound thread, which is necessary if you need to call foreign (non-Haskell) libraries that make use of thread-local state, such as OpenGL (see Control.Concurrent).

Using forkOS instead of forkIO makes no difference at all to the scheduling behaviour of the Haskell runtime system. It is a common misconception that you need to use forkOS instead of forkIO to avoid blocking all the Haskell threads when making a foreign call; this isn't the case. To allow foreign calls to be made without blocking all the Haskell threads (with GHC), it is only necessary to use the -threaded option when linking your program, and to make sure the foreign import is not marked unsafe.

data ThreadId #

A ThreadId is an abstract type representing a handle to a thread. ThreadId is an instance of Eq, Ord and Show, where the Ord instance implements an arbitrary total ordering over ThreadIds. The Show instance lets you convert an arbitrary-valued ThreadId to string form; showing a ThreadId value is occasionally useful when debugging or diagnosing the behaviour of a concurrent program.

Note: in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature will hopefully be corrected at a later date.

Instances
Eq ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Ord ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Show ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Hashable ThreadId 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> ThreadId -> Int #

hash :: ThreadId -> Int #

class Applicative f => Alternative (f :: * -> *) where #

A monoid on applicative functors.

If defined, some and many should be the least solutions of the equations:

Minimal complete definition

empty, (<|>)

Methods

empty :: f a #

The identity of <|>

(<|>) :: f a -> f a -> f a infixl 3 #

An associative binary operation

some :: f a -> f [a] #

One or more.

many :: f a -> f [a] #

Zero or more.

Instances
Alternative []

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

empty :: [a] #

(<|>) :: [a] -> [a] -> [a] #

some :: [a] -> [[a]] #

many :: [a] -> [[a]] #

Alternative Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

Methods

empty :: Maybe a #

(<|>) :: Maybe a -> Maybe a -> Maybe a #

some :: Maybe a -> Maybe [a] #

many :: Maybe a -> Maybe [a] #

Alternative IO

Since: base-4.9.0.0

Instance details

Defined in GHC.Base

Methods

empty :: IO a #

(<|>) :: IO a -> IO a -> IO a #

some :: IO a -> IO [a] #

many :: IO a -> IO [a] #

Alternative Option

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

empty :: Option a #

(<|>) :: Option a -> Option a -> Option a #

some :: Option a -> Option [a] #

many :: Option a -> Option [a] #

Alternative ZipList

Since: base-4.11.0.0

Instance details

Defined in Control.Applicative

Methods

empty :: ZipList a #

(<|>) :: ZipList a -> ZipList a -> ZipList a #

some :: ZipList a -> ZipList [a] #

many :: ZipList a -> ZipList [a] #

Alternative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

empty :: STM a #

(<|>) :: STM a -> STM a -> STM a #

some :: STM a -> STM [a] #

many :: STM a -> STM [a] #

Alternative ReadP

Since: base-4.6.0.0

Instance details

Defined in Text.ParserCombinators.ReadP

Methods

empty :: ReadP a #

(<|>) :: ReadP a -> ReadP a -> ReadP a #

some :: ReadP a -> ReadP [a] #

many :: ReadP a -> ReadP [a] #

Alternative P

Since: base-4.5.0.0

Instance details

Defined in Text.ParserCombinators.ReadP

Methods

empty :: P a #

(<|>) :: P a -> P a -> P a #

some :: P a -> P [a] #

many :: P a -> P [a] #

Alternative (U1 :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

empty :: U1 a #

(<|>) :: U1 a -> U1 a -> U1 a #

some :: U1 a -> U1 [a] #

many :: U1 a -> U1 [a] #

MonadPlus m => Alternative (WrappedMonad m)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

empty :: WrappedMonad m a #

(<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a #

some :: WrappedMonad m a -> WrappedMonad m [a] #

many :: WrappedMonad m a -> WrappedMonad m [a] #

ArrowPlus a => Alternative (ArrowMonad a)

Since: base-4.6.0.0

Instance details

Defined in Control.Arrow

Methods

empty :: ArrowMonad a a0 #

(<|>) :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 #

some :: ArrowMonad a a0 -> ArrowMonad a [a0] #

many :: ArrowMonad a a0 -> ArrowMonad a [a0] #

Alternative (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

empty :: Proxy a #

(<|>) :: Proxy a -> Proxy a -> Proxy a #

some :: Proxy a -> Proxy [a] #

many :: Proxy a -> Proxy [a] #

Alternative f => Alternative (Rec1 f)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

empty :: Rec1 f a #

(<|>) :: Rec1 f a -> Rec1 f a -> Rec1 f a #

some :: Rec1 f a -> Rec1 f [a] #

many :: Rec1 f a -> Rec1 f [a] #

(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

empty :: WrappedArrow a b a0 #

(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 #

some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

Alternative f => Alternative (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

empty :: Alt f a #

(<|>) :: Alt f a -> Alt f a -> Alt f a #

some :: Alt f a -> Alt f [a] #

many :: Alt f a -> Alt f [a] #

(Functor m, Monad m, Error e) => Alternative (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

empty :: ErrorT e m a #

(<|>) :: ErrorT e m a -> ErrorT e m a -> ErrorT e m a #

some :: ErrorT e m a -> ErrorT e m [a] #

many :: ErrorT e m a -> ErrorT e m [a] #

(Alternative f, Alternative g) => Alternative (f :*: g)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

empty :: (f :*: g) a #

(<|>) :: (f :*: g) a -> (f :*: g) a -> (f :*: g) a #

some :: (f :*: g) a -> (f :*: g) [a] #

many :: (f :*: g) a -> (f :*: g) [a] #

Alternative (ParsecT s u m) 
Instance details

Defined in Text.Parsec.Prim

Methods

empty :: ParsecT s u m a #

(<|>) :: ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a #

some :: ParsecT s u m a -> ParsecT s u m [a] #

many :: ParsecT s u m a -> ParsecT s u m [a] #

Alternative f => Alternative (M1 i c f)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

empty :: M1 i c f a #

(<|>) :: M1 i c f a -> M1 i c f a -> M1 i c f a #

some :: M1 i c f a -> M1 i c f [a] #

many :: M1 i c f a -> M1 i c f [a] #

(Alternative f, Applicative g) => Alternative (f :.: g)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

empty :: (f :.: g) a #

(<|>) :: (f :.: g) a -> (f :.: g) a -> (f :.: g) a #

some :: (f :.: g) a -> (f :.: g) [a] #

many :: (f :.: g) a -> (f :.: g) [a] #

threadWaitWriteSTM :: Fd -> IO (STM (), IO ()) #

Returns an STM action that can be used to wait until data can be written to a file descriptor. The second returned value is an IO action that can be used to deregister interest in the file descriptor.

Since: base-4.7.0.0

threadWaitReadSTM :: Fd -> IO (STM (), IO ()) #

Returns an STM action that can be used to wait for data to read from a file descriptor. The second returned value is an IO action that can be used to deregister interest in the file descriptor.

Since: base-4.7.0.0

threadWaitWrite :: Fd -> IO () #

Block the current thread until data can be written to the given file descriptor (GHC only).

This will throw an IOError if the file descriptor was closed while this thread was blocked. To safely close a file descriptor that has been used with threadWaitWrite, use closeFdWith.

threadWaitRead :: Fd -> IO () #

Block the current thread until data is available to read on the given file descriptor (GHC only).

This will throw an IOError if the file descriptor was closed while this thread was blocked. To safely close a file descriptor that has been used with threadWaitRead, use closeFdWith.

runInUnboundThread :: IO a -> IO a #

Run the IO computation passed as the first argument. If the calling thread is bound, an unbound thread is created temporarily using forkIO. runInBoundThread doesn't finish until the IO computation finishes.

Use this function only in the rare case that you have actually observed a performance loss due to the use of bound threads. A program that doesn't need its main thread to be bound and makes heavy use of concurrency (e.g. a web server), might want to wrap its main action in runInUnboundThread.

Note that exceptions which are thrown to the current thread are thrown in turn to the thread that is executing the given computation. This ensures there's always a way of killing the forked thread.

runInBoundThread :: IO a -> IO a #

Run the IO computation passed as the first argument. If the calling thread is not bound, a bound thread is created temporarily. runInBoundThread doesn't finish until the IO computation finishes.

You can wrap a series of foreign function calls that rely on thread-local state with runInBoundThread so that you can use them without knowing whether the current thread is bound.

isCurrentThreadBound :: IO Bool #

Returns True if the calling thread is bound, that is, if it is safe to use foreign libraries that rely on thread-local state from the calling thread.

forkOSWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId #

Like forkIOWithUnmask, but the child thread is a bound thread, as with forkOS.

forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId #

Fork a thread and call the supplied function when the thread is about to terminate, with an exception or a returned value. The function is called with asynchronous exceptions masked.

forkFinally action and_then =
  mask $ \restore ->
    forkIO $ try (restore action) >>= and_then

This function is useful for informing the parent when a child terminates, for example.

Since: base-4.6.0.0

rtsSupportsBoundThreads :: Bool #

True if bound threads are supported. If rtsSupportsBoundThreads is False, isCurrentThreadBound will always return False and both forkOS and runInBoundThread will fail.

writeList2Chan :: Chan a -> [a] -> IO () #

Write an entire list of items to a Chan.

getChanContents :: Chan a -> IO [a] #

Return a lazy list representing the contents of the supplied Chan, much like hGetContents.

dupChan :: Chan a -> IO (Chan a) #

Duplicate a Chan: the duplicate channel begins empty, but data written to either channel from then on will be available from both. Hence this creates a kind of broadcast channel, where data written by anyone is seen by everyone else.

(Note that a duplicated channel is not equal to its original. So: fmap (c /=) $ dupChan c returns True for all c.)

readChan :: Chan a -> IO a #

Read the next value from the Chan. Blocks when the channel is empty. Since the read end of a channel is an MVar, this operation inherits fairness guarantees of MVars (e.g. threads blocked in this operation are woken up in FIFO order).

Throws BlockedIndefinitelyOnMVar when the channel is empty and no other thread holds a reference to the channel.

writeChan :: Chan a -> a -> IO () #

Write a value to a Chan.

newChan :: IO (Chan a) #

Build and returns a new instance of Chan.

data Chan a #

Chan is an abstract type representing an unbounded FIFO channel.

Instances
Eq (Chan a) 
Instance details

Defined in Control.Concurrent.Chan

Methods

(==) :: Chan a -> Chan a -> Bool #

(/=) :: Chan a -> Chan a -> Bool #

signalQSem :: QSem -> IO () #

Signal that a unit of the QSem is available

waitQSem :: QSem -> IO () #

Wait for a unit to become available

newQSem :: Int -> IO QSem #

Build a new QSem with a supplied initial quantity. The initial quantity must be at least 0.

data QSem #

QSem is a quantity semaphore in which the resource is aqcuired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSem calls.

The pattern

  bracket_ waitQSem signalQSem (...)

is safe; it never loses a unit of the resource.

signalQSemN :: QSemN -> Int -> IO () #

Signal that a given quantity is now available from the QSemN.

waitQSemN :: QSemN -> Int -> IO () #

Wait for the specified quantity to become available

newQSemN :: Int -> IO QSemN #

Build a new QSemN with a supplied initial quantity. The initial quantity must be at least 0.

data QSemN #

QSemN is a quantity semaphore in which the resource is aqcuired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSemN calls.

The pattern

  bracket_ (waitQSemN n) (signalQSemN n) (...)

is safe; it never loses any of the resource.

approxRational :: RealFrac a => a -> a -> Rational #

approxRational, applied to two real fractional numbers x and epsilon, returns the simplest rational number within epsilon of x. A rational number y is said to be simpler than another y' if

Any real interval contains a unique simplest rational; in particular, note that 0/1 is the simplest rational of all.

isSubsequenceOf :: Eq a => [a] -> [a] -> Bool #

The isSubsequenceOf function takes two lists and returns True if all the elements of the first list occur, in order, in the second. The elements do not have to occur consecutively.

isSubsequenceOf x y is equivalent to elem x (subsequences y).

Examples

Expand
>>> isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
True
>>> isSubsequenceOf ['a','d'..'z'] ['a'..'z']
True
>>> isSubsequenceOf [1..10] [10,9..0]
False

Since: base-4.8.0.0

mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) #

The mapAccumR function behaves like a combination of fmap and foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.

mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) #

The mapAccumL function behaves like a combination of fmap and foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.

optional :: Alternative f => f a -> f (Maybe a) #

One or none.

newtype WrappedMonad (m :: * -> *) a #

Constructors

WrapMonad 

Fields

Instances
Monad m => Monad (WrappedMonad m) 
Instance details

Defined in Control.Applicative

Methods

(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b #

(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #

return :: a -> WrappedMonad m a #

fail :: String -> WrappedMonad m a #

Monad m => Functor (WrappedMonad m)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b #

(<$) :: a -> WrappedMonad m b -> WrappedMonad m a #

Monad m => Applicative (WrappedMonad m)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

pure :: a -> WrappedMonad m a #

(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b #

liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c #

(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #

(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a #

MonadPlus m => Alternative (WrappedMonad m)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

empty :: WrappedMonad m a #

(<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a #

some :: WrappedMonad m a -> WrappedMonad m [a] #

many :: WrappedMonad m a -> WrappedMonad m [a] #

Generic1 (WrappedMonad m :: * -> *) 
Instance details

Defined in Control.Applicative

Associated Types

type Rep1 (WrappedMonad m) :: k -> * #

Methods

from1 :: WrappedMonad m a -> Rep1 (WrappedMonad m) a #

to1 :: Rep1 (WrappedMonad m) a -> WrappedMonad m a #

Generic (WrappedMonad m a) 
Instance details

Defined in Control.Applicative

Associated Types

type Rep (WrappedMonad m a) :: * -> * #

Methods

from :: WrappedMonad m a -> Rep (WrappedMonad m a) x #

to :: Rep (WrappedMonad m a) x -> WrappedMonad m a #

type Rep1 (WrappedMonad m :: * -> *) 
Instance details

Defined in Control.Applicative

type Rep1 (WrappedMonad m :: * -> *) = D1 (MetaData "WrappedMonad" "Control.Applicative" "base" True) (C1 (MetaCons "WrapMonad" PrefixI True) (S1 (MetaSel (Just "unwrapMonad") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 m)))
type Rep (WrappedMonad m a) 
Instance details

Defined in Control.Applicative

type Rep (WrappedMonad m a) = D1 (MetaData "WrappedMonad" "Control.Applicative" "base" True) (C1 (MetaCons "WrapMonad" PrefixI True) (S1 (MetaSel (Just "unwrapMonad") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (m a))))

newtype WrappedArrow (a :: * -> * -> *) b c #

Constructors

WrapArrow 

Fields

Instances
Generic1 (WrappedArrow a b :: * -> *) 
Instance details

Defined in Control.Applicative

Associated Types

type Rep1 (WrappedArrow a b) :: k -> * #

Methods

from1 :: WrappedArrow a b a0 -> Rep1 (WrappedArrow a b) a0 #

to1 :: Rep1 (WrappedArrow a b) a0 -> WrappedArrow a b a0 #

Arrow a => Functor (WrappedArrow a b)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 #

(<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 #

Arrow a => Applicative (WrappedArrow a b)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

pure :: a0 -> WrappedArrow a b a0 #

(<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 #

liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c #

(*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 #

(<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 #

(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

empty :: WrappedArrow a b a0 #

(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 #

some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

Generic (WrappedArrow a b c) 
Instance details

Defined in Control.Applicative

Associated Types

type Rep (WrappedArrow a b c) :: * -> * #

Methods

from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x #

to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c #

type Rep1 (WrappedArrow a b :: * -> *) 
Instance details

Defined in Control.Applicative

type Rep1 (WrappedArrow a b :: * -> *) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (a b))))
type Rep (WrappedArrow a b c) 
Instance details

Defined in Control.Applicative

type Rep (WrappedArrow a b c) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (a b c))))

newtype ZipList a #

Lists, but with an Applicative functor based on zipping.

Constructors

ZipList 

Fields

Instances
Functor ZipList 
Instance details

Defined in Control.Applicative

Methods

fmap :: (a -> b) -> ZipList a -> ZipList b #

(<$) :: a -> ZipList b -> ZipList a #

Applicative ZipList
f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
    = 'ZipList' (zipWithN f xs1 ... xsN)

where zipWithN refers to the zipWith function of the appropriate arity (zipWith, zipWith3, zipWith4, ...). For example:

(\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
    = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
    = ZipList {getZipList = ["a5","b6b6","c7c7c7"]}

Since: base-2.1

Instance details

Defined in Control.Applicative

Methods

pure :: a -> ZipList a #

(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b #

liftA2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c #

(*>) :: ZipList a -> ZipList b -> ZipList b #

(<*) :: ZipList a -> ZipList b -> ZipList a #

Foldable ZipList 
Instance details

Defined in Control.Applicative

Methods

fold :: Monoid m => ZipList m -> m #

foldMap :: Monoid m => (a -> m) -> ZipList a -> m #

foldr :: (a -> b -> b) -> b -> ZipList a -> b #

foldr' :: (a -> b -> b) -> b -> ZipList a -> b #

foldl :: (b -> a -> b) -> b -> ZipList a -> b #

foldl' :: (b -> a -> b) -> b -> ZipList a -> b #

foldr1 :: (a -> a -> a) -> ZipList a -> a #

foldl1 :: (a -> a -> a) -> ZipList a -> a #

toList :: ZipList a -> [a] #

null :: ZipList a -> Bool #

length :: ZipList a -> Int #

elem :: Eq a => a -> ZipList a -> Bool #

maximum :: Ord a => ZipList a -> a #

minimum :: Ord a => ZipList a -> a #

sum :: Num a => ZipList a -> a #

product :: Num a => ZipList a -> a #

Traversable ZipList

Since: base-4.9.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> ZipList a -> f (ZipList b) #

sequenceA :: Applicative f => ZipList (f a) -> f (ZipList a) #

mapM :: Monad m => (a -> m b) -> ZipList a -> m (ZipList b) #

sequence :: Monad m => ZipList (m a) -> m (ZipList a) #

Alternative ZipList

Since: base-4.11.0.0

Instance details

Defined in Control.Applicative

Methods

empty :: ZipList a #

(<|>) :: ZipList a -> ZipList a -> ZipList a #

some :: ZipList a -> ZipList [a] #

many :: ZipList a -> ZipList [a] #

Eq a => Eq (ZipList a) 
Instance details

Defined in Control.Applicative

Methods

(==) :: ZipList a -> ZipList a -> Bool #

(/=) :: ZipList a -> ZipList a -> Bool #

Ord a => Ord (ZipList a) 
Instance details

Defined in Control.Applicative

Methods

compare :: ZipList a -> ZipList a -> Ordering #

(<) :: ZipList a -> ZipList a -> Bool #

(<=) :: ZipList a -> ZipList a -> Bool #

(>) :: ZipList a -> ZipList a -> Bool #

(>=) :: ZipList a -> ZipList a -> Bool #

max :: ZipList a -> ZipList a -> ZipList a #

min :: ZipList a -> ZipList a -> ZipList a #

Read a => Read (ZipList a) 
Instance details

Defined in Control.Applicative

Show a => Show (ZipList a) 
Instance details

Defined in Control.Applicative

Methods

showsPrec :: Int -> ZipList a -> ShowS #

show :: ZipList a -> String #

showList :: [ZipList a] -> ShowS #

Generic (ZipList a) 
Instance details

Defined in Control.Applicative

Associated Types

type Rep (ZipList a) :: * -> * #

Methods

from :: ZipList a -> Rep (ZipList a) x #

to :: Rep (ZipList a) x -> ZipList a #

Generic1 ZipList 
Instance details

Defined in Control.Applicative

Associated Types

type Rep1 ZipList :: k -> * #

Methods

from1 :: ZipList a -> Rep1 ZipList a #

to1 :: Rep1 ZipList a -> ZipList a #

type Rep (ZipList a) 
Instance details

Defined in Control.Applicative

type Rep (ZipList a) = D1 (MetaData "ZipList" "Control.Applicative" "base" True) (C1 (MetaCons "ZipList" PrefixI True) (S1 (MetaSel (Just "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [a])))
type Rep1 ZipList 
Instance details

Defined in Control.Applicative

type Rep1 ZipList = D1 (MetaData "ZipList" "Control.Applicative" "base" True) (C1 (MetaCons "ZipList" PrefixI True) (S1 (MetaSel (Just "getZipList") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 [])))

threadDelay :: Int -> IO () #

Suspends the current thread for a given number of microseconds (GHC only).

There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will never continue to run earlier than specified.

mkWeakMVar :: MVar a -> IO () -> IO (Weak (MVar a)) #

Make a Weak pointer to an MVar, using the second argument as a finalizer to run when MVar is garbage-collected

Since: base-4.6.0.0

addMVarFinalizer :: MVar a -> IO () -> IO () #

modifyMVarMasked :: MVar a -> (a -> IO (a, b)) -> IO b #

Like modifyMVar, but the IO action in the second argument is executed with asynchronous exceptions masked.

Since: base-4.6.0.0

modifyMVarMasked_ :: MVar a -> (a -> IO a) -> IO () #

Like modifyMVar_, but the IO action in the second argument is executed with asynchronous exceptions masked.

Since: base-4.6.0.0

modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b #

A slight variation on modifyMVar_ that allows a value to be returned (b) in addition to the modified value of the MVar.

modifyMVar_ :: MVar a -> (a -> IO a) -> IO () #

An exception-safe wrapper for modifying the contents of an MVar. Like withMVar, modifyMVar will replace the original contents of the MVar if an exception is raised during the operation. This function is only atomic if there are no other producers for this MVar.

withMVarMasked :: MVar a -> (a -> IO b) -> IO b #

Like withMVar, but the IO action in the second argument is executed with asynchronous exceptions masked.

Since: base-4.7.0.0

withMVar :: MVar a -> (a -> IO b) -> IO b #

withMVar is an exception-safe wrapper for operating on the contents of an MVar. This operation is exception-safe: it will replace the original contents of the MVar if an exception is raised (see Control.Exception). However, it is only atomic if there are no other producers for this MVar.

swapMVar :: MVar a -> a -> IO a #

Take a value from an MVar, put a new value into the MVar and return the value taken. This function is atomic only if there are no other producers for this MVar.

mkWeakThreadId :: ThreadId -> IO (Weak ThreadId) #

Make a weak pointer to a ThreadId. It can be important to do this if you want to hold a reference to a ThreadId while still allowing the thread to receive the BlockedIndefinitely family of exceptions (e.g. BlockedIndefinitelyOnMVar). Holding a normal ThreadId reference will prevent the delivery of BlockedIndefinitely exceptions because the reference could be used as the target of throwTo at any time, which would unblock the thread.

Holding a Weak ThreadId, on the other hand, will not prevent the thread from receiving BlockedIndefinitely exceptions. It is still possible to throw an exception to a Weak ThreadId, but the caller must use deRefWeak first to determine whether the thread still exists.

Since: base-4.6.0.0

threadCapability :: ThreadId -> IO (Int, Bool) #

Returns the number of the capability on which the thread is currently running, and a boolean indicating whether the thread is locked to that capability or not. A thread is locked to a capability if it was created with forkOn.

Since: base-4.4.0.0

yield :: IO () #

The yield action allows (forces, in a co-operative multitasking implementation) a context-switch to any other currently runnable threads (if any), and is occasionally useful when implementing concurrency abstractions.

myThreadId :: IO ThreadId #

Returns the ThreadId of the calling thread (GHC only).

throwTo :: Exception e => ThreadId -> e -> IO () #

throwTo raises an arbitrary exception in the target thread (GHC only).

Exception delivery synchronizes between the source and target thread: throwTo does not return until the exception has been raised in the target thread. The calling thread can thus be certain that the target thread has received the exception. Exception delivery is also atomic with respect to other exceptions. Atomicity is a useful property to have when dealing with race conditions: e.g. if there are two threads that can kill each other, it is guaranteed that only one of the threads will get to kill the other.

Whatever work the target thread was doing when the exception was raised is not lost: the computation is suspended until required by another thread.

If the target thread is currently making a foreign call, then the exception will not be raised (and hence throwTo will not return) until the call has completed. This is the case regardless of whether the call is inside a mask or not. However, in GHC a foreign call can be annotated as interruptible, in which case a throwTo will cause the RTS to attempt to cause the call to return; see the GHC documentation for more details.

Important note: the behaviour of throwTo differs from that described in the paper "Asynchronous exceptions in Haskell" (http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm). In the paper, throwTo is non-blocking; but the library implementation adopts a more synchronous design in which throwTo does not return until the exception is received by the target thread. The trade-off is discussed in Section 9 of the paper. Like any blocking operation, throwTo is therefore interruptible (see Section 5.3 of the paper). Unlike other interruptible operations, however, throwTo is always interruptible, even if it does not actually block.

There is no guarantee that the exception will be delivered promptly, although the runtime will endeavour to ensure that arbitrary delays don't occur. In GHC, an exception can only be raised when a thread reaches a safe point, where a safe point is where memory allocation occurs. Some loops do not perform any memory allocation inside the loop and therefore cannot be interrupted by a throwTo.

If the target of throwTo is the calling thread, then the behaviour is the same as throwIO, except that the exception is thrown as an asynchronous exception. This means that if there is an enclosing pure computation, which would be the case if the current IO operation is inside unsafePerformIO or unsafeInterleaveIO, that computation is not permanently replaced by the exception, but is suspended as if it had received an asynchronous exception.

Note that if throwTo is called with the current thread as the target, the exception will be thrown even if the thread is currently inside mask or uninterruptibleMask.

killThread :: ThreadId -> IO () #

killThread raises the ThreadKilled exception in the given thread (GHC only).

killThread tid = throwTo tid ThreadKilled

setNumCapabilities :: Int -> IO () #

Set the number of Haskell threads that can run truly simultaneously (on separate physical processors) at any given time. The number passed to forkOn is interpreted modulo this value. The initial value is given by the +RTS -N runtime flag.

This is also the number of threads that will participate in parallel garbage collection. It is strongly recommended that the number of capabilities is not set larger than the number of physical processor cores, and it may often be beneficial to leave one or more cores free to avoid contention with other processes in the machine.

Since: base-4.5.0.0

getNumCapabilities :: IO Int #

Returns the number of Haskell threads that can run truly simultaneously (on separate physical processors) at any given time. To change this value, use setNumCapabilities.

Since: base-4.4.0.0

forkIO :: IO () -> IO ThreadId #

Creates a new thread to run the IO computation passed as the first argument, and returns the ThreadId of the newly created thread.

The new thread will be a lightweight, unbound thread. Foreign calls made by this thread are not guaranteed to be made by any particular OS thread; if you need foreign calls to be made by a particular OS thread, then use forkOS instead.

The new thread inherits the masked state of the parent (see mask).

The newly created thread has an exception handler that discards the exceptions BlockedIndefinitelyOnMVar, BlockedIndefinitelyOnSTM, and ThreadKilled, and passes all other exceptions to the uncaught exception handler.

newtype Const a (b :: k) :: forall k. * -> k -> * #

The Const functor.

Constructors

Const 

Fields

Instances
Generic1 (Const a :: k -> *) 
Instance details

Defined in Data.Functor.Const

Associated Types

type Rep1 (Const a) :: k -> * #

Methods

from1 :: Const a a0 -> Rep1 (Const a) a0 #

to1 :: Rep1 (Const a) a0 -> Const a a0 #

Eq2 (Const :: * -> * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Const a c -> Const b d -> Bool #

Ord2 (Const :: * -> * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Const a c -> Const b d -> Ordering #

Read2 (Const :: * -> * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Const a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Const a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Const a b] #

Show2 (Const :: * -> * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Const a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Const a b] -> ShowS #

Hashable2 (Const :: * -> * -> *) 
Instance details

Defined in Data.Hashable.Class

Methods

liftHashWithSalt2 :: (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> Const a b -> Int #

Functor (Const m :: * -> *)

Since: base-2.1

Instance details

Defined in Data.Functor.Const

Methods

fmap :: (a -> b) -> Const m a -> Const m b #

(<$) :: a -> Const m b -> Const m a #

Monoid m => Applicative (Const m :: * -> *)

Since: base-2.0.1

Instance details

Defined in Data.Functor.Const

Methods

pure :: a -> Const m a #

(<*>) :: Const m (a -> b) -> Const m a -> Const m b #

liftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m c #

(*>) :: Const m a -> Const m b -> Const m b #

(<*) :: Const m a -> Const m b -> Const m a #

Foldable (Const m :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Functor.Const

Methods

fold :: Monoid m0 => Const m m0 -> m0 #

foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 #

foldr :: (a -> b -> b) -> b -> Const m a -> b #

foldr' :: (a -> b -> b) -> b -> Const m a -> b #

foldl :: (b -> a -> b) -> b -> Const m a -> b #

foldl' :: (b -> a -> b) -> b -> Const m a -> b #

foldr1 :: (a -> a -> a) -> Const m a -> a #

foldl1 :: (a -> a -> a) -> Const m a -> a #

toList :: Const m a -> [a] #

null :: Const m a -> Bool #

length :: Const m a -> Int #

elem :: Eq a => a -> Const m a -> Bool #

maximum :: Ord a => Const m a -> a #

minimum :: Ord a => Const m a -> a #

sum :: Num a => Const m a -> a #

product :: Num a => Const m a -> a #

Traversable (Const m :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Const m a -> f (Const m b) #

sequenceA :: Applicative f => Const m (f a) -> f (Const m a) #

mapM :: Monad m0 => (a -> m0 b) -> Const m a -> m0 (Const m b) #

sequence :: Monad m0 => Const m (m0 a) -> m0 (Const m a) #

Eq a => Eq1 (Const a :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a0 -> b -> Bool) -> Const a a0 -> Const a b -> Bool #

Ord a => Ord1 (Const a :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a0 -> b -> Ordering) -> Const a a0 -> Const a b -> Ordering #

Read a => Read1 (Const a :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Const a a0) #

liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Const a a0] #

liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Const a a0) #

liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Const a a0] #

Show a => Show1 (Const a :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Const a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Const a a0] -> ShowS #

Hashable a => Hashable1 (Const a :: * -> *) 
Instance details

Defined in Data.Hashable.Class

Methods

liftHashWithSalt :: (Int -> a0 -> Int) -> Int -> Const a a0 -> Int #

Bounded a => Bounded (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

minBound :: Const a b #

maxBound :: Const a b #

Enum a => Enum (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

succ :: Const a b -> Const a b #

pred :: Const a b -> Const a b #

toEnum :: Int -> Const a b #

fromEnum :: Const a b -> Int #

enumFrom :: Const a b -> [Const a b] #

enumFromThen :: Const a b -> Const a b -> [Const a b] #

enumFromTo :: Const a b -> Const a b -> [Const a b] #

enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] #

Eq a => Eq (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

(==) :: Const a b -> Const a b -> Bool #

(/=) :: Const a b -> Const a b -> Bool #

Floating a => Floating (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

pi :: Const a b #

exp :: Const a b -> Const a b #

log :: Const a b -> Const a b #

sqrt :: Const a b -> Const a b #

(**) :: Const a b -> Const a b -> Const a b #

logBase :: Const a b -> Const a b -> Const a b #

sin :: Const a b -> Const a b #

cos :: Const a b -> Const a b #

tan :: Const a b -> Const a b #

asin :: Const a b -> Const a b #

acos :: Const a b -> Const a b #

atan :: Const a b -> Const a b #

sinh :: Const a b -> Const a b #

cosh :: Const a b -> Const a b #

tanh :: Const a b -> Const a b #

asinh :: Const a b -> Const a b #

acosh :: Const a b -> Const a b #

atanh :: Const a b -> Const a b #

log1p :: Const a b -> Const a b #

expm1 :: Const a b -> Const a b #

log1pexp :: Const a b -> Const a b #

log1mexp :: Const a b -> Const a b #

Fractional a => Fractional (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

(/) :: Const a b -> Const a b -> Const a b #

recip :: Const a b -> Const a b #

fromRational :: Rational -> Const a b #

Integral a => Integral (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

quot :: Const a b -> Const a b -> Const a b #

rem :: Const a b -> Const a b -> Const a b #

div :: Const a b -> Const a b -> Const a b #

mod :: Const a b -> Const a b -> Const a b #

quotRem :: Const a b -> Const a b -> (Const a b, Const a b) #

divMod :: Const a b -> Const a b -> (Const a b, Const a b) #

toInteger :: Const a b -> Integer #

Num a => Num (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

(+) :: Const a b -> Const a b -> Const a b #

(-) :: Const a b -> Const a b -> Const a b #

(*) :: Const a b -> Const a b -> Const a b #

negate :: Const a b -> Const a b #

abs :: Const a b -> Const a b #

signum :: Const a b -> Const a b #

fromInteger :: Integer -> Const a b #

Ord a => Ord (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

compare :: Const a b -> Const a b -> Ordering #

(<) :: Const a b -> Const a b -> Bool #

(<=) :: Const a b -> Const a b -> Bool #

(>) :: Const a b -> Const a b -> Bool #

(>=) :: Const a b -> Const a b -> Bool #

max :: Const a b -> Const a b -> Const a b #

min :: Const a b -> Const a b -> Const a b #

Read a => Read (Const a b)

This instance would be equivalent to the derived instances of the Const newtype if the runConst field were removed

Since: base-4.8.0.0

Instance details

Defined in Data.Functor.Const

Real a => Real (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

toRational :: Const a b -> Rational #

RealFloat a => RealFloat (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

floatRadix :: Const a b -> Integer #

floatDigits :: Const a b -> Int #

floatRange :: Const a b -> (Int, Int) #

decodeFloat :: Const a b -> (Integer, Int) #

encodeFloat :: Integer -> Int -> Const a b #

exponent :: Const a b -> Int #

significand :: Const a b -> Const a b #

scaleFloat :: Int -> Const a b -> Const a b #

isNaN :: Const a b -> Bool #

isInfinite :: Const a b -> Bool #

isDenormalized :: Const a b -> Bool #

isNegativeZero :: Const a b -> Bool #

isIEEE :: Const a b -> Bool #

atan2 :: Const a b -> Const a b -> Const a b #

RealFrac a => RealFrac (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

properFraction :: Integral b0 => Const a b -> (b0, Const a b) #

truncate :: Integral b0 => Const a b -> b0 #

round :: Integral b0 => Const a b -> b0 #

ceiling :: Integral b0 => Const a b -> b0 #

floor :: Integral b0 => Const a b -> b0 #

Show a => Show (Const a b)

This instance would be equivalent to the derived instances of the Const newtype if the runConst field were removed

Since: base-4.8.0.0

Instance details

Defined in Data.Functor.Const

Methods

showsPrec :: Int -> Const a b -> ShowS #

show :: Const a b -> String #

showList :: [Const a b] -> ShowS #

Ix a => Ix (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

range :: (Const a b, Const a b) -> [Const a b] #

index :: (Const a b, Const a b) -> Const a b -> Int #

unsafeIndex :: (Const a b, Const a b) -> Const a b -> Int

inRange :: (Const a b, Const a b) -> Const a b -> Bool #

rangeSize :: (Const a b, Const a b) -> Int #

unsafeRangeSize :: (Const a b, Const a b) -> Int

IsString a => IsString (Const a b)

Since: base-4.9.0.0

Instance details

Defined in Data.String

Methods

fromString :: String -> Const a b #

Generic (Const a b) 
Instance details

Defined in Data.Functor.Const

Associated Types

type Rep (Const a b) :: * -> * #

Methods

from :: Const a b -> Rep (Const a b) x #

to :: Rep (Const a b) x -> Const a b #

Semigroup a => Semigroup (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

(<>) :: Const a b -> Const a b -> Const a b #

sconcat :: NonEmpty (Const a b) -> Const a b #

stimes :: Integral b0 => b0 -> Const a b -> Const a b #

Monoid a => Monoid (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

mempty :: Const a b #

mappend :: Const a b -> Const a b -> Const a b #

mconcat :: [Const a b] -> Const a b #

Storable a => Storable (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

sizeOf :: Const a b -> Int #

alignment :: Const a b -> Int #

peekElemOff :: Ptr (Const a b) -> Int -> IO (Const a b) #

pokeElemOff :: Ptr (Const a b) -> Int -> Const a b -> IO () #

peekByteOff :: Ptr b0 -> Int -> IO (Const a b) #

pokeByteOff :: Ptr b0 -> Int -> Const a b -> IO () #

peek :: Ptr (Const a b) -> IO (Const a b) #

poke :: Ptr (Const a b) -> Const a b -> IO () #

Bits a => Bits (Const a b) 
Instance details

Defined in Data.Functor.Const

Methods

(.&.) :: Const a b -> Const a b -> Const a b #

(.|.) :: Const a b -> Const a b -> Const a b #

xor :: Const a b -> Const a b -> Const a b #

complement :: Const a b -> Const a b #

shift :: Const a b -> Int -> Const a b #

rotate :: Const a b -> Int -> Const a b #

zeroBits :: Const a b #

bit :: Int -> Const a b #

setBit :: Const a b -> Int -> Const a b #

clearBit :: Const a b -> Int -> Const a b #

complementBit :: Const a b -> Int -> Const a b #

testBit :: Const a b -> Int -> Bool #

bitSizeMaybe :: Const a b -> Maybe Int #

bitSize :: Const a b -> Int #

isSigned :: Const a b -> Bool #

shiftL :: Const a b -> Int -> Const a b #

unsafeShiftL :: Const a b -> Int -> Const a b #

shiftR :: Const a b -> Int -> Const a b #

unsafeShiftR :: Const a b -> Int -> Const a b #

rotateL :: Const a b -> Int -> Const a b #

rotateR :: Const a b -> Int -> Const a b #

popCount :: Const a b -> Int #

FiniteBits a => FiniteBits (Const a b) 
Instance details

Defined in Data.Functor.Const

Hashable a => Hashable (Const a b) 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Const a b -> Int #

hash :: Const a b -> Int #

type Rep1 (Const a :: k -> *) 
Instance details

Defined in Data.Functor.Const

type Rep1 (Const a :: k -> *) = D1 (MetaData "Const" "Data.Functor.Const" "base" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Rep (Const a b) 
Instance details

Defined in Data.Functor.Const

type Rep (Const a b) = D1 (MetaData "Const" "Data.Functor.Const" "base" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

find :: Foldable t => (a -> Bool) -> t a -> Maybe a #

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.

notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 #

notElem is the negation of elem.

minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a #

The least element of a non-empty structure with respect to the given comparison function.

maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a #

The largest element of a non-empty structure with respect to the given comparison function.

all :: Foldable t => (a -> Bool) -> t a -> Bool #

Determines whether all elements of the structure satisfy the predicate.

any :: Foldable t => (a -> Bool) -> t a -> Bool #

Determines whether any element of the structure satisfies the predicate.

or :: Foldable t => t Bool -> Bool #

or returns the disjunction of a container of Bools. For the result to be False, the container must be finite; True, however, results from a True value finitely far from the left end.

and :: Foldable t => t Bool -> Bool #

and returns the conjunction of a container of Bools. For the result to be True, the container must be finite; False, however, results from a False value finitely far from the left end.

concatMap :: Foldable t => (a -> [b]) -> t a -> [b] #

Map a function over all the elements of a container and concatenate the resulting lists.

concat :: Foldable t => t [a] -> [a] #

The concatenation of all the elements of a container of lists.

newtype First a #

Maybe monoid returning the leftmost non-Nothing value.

First a is isomorphic to Alt Maybe a, but precedes it historically.

>>> getFirst (First (Just "hello") <> First Nothing <> First (Just "world"))
Just "hello"

Constructors

First 

Fields

Instances
Monad First 
Instance details

Defined in Data.Monoid

Methods

(>>=) :: First a -> (a -> First b) -> First b #

(>>) :: First a -> First b -> First b #

return :: a -> First a #

fail :: String -> First a #

Functor First 
Instance details

Defined in Data.Monoid

Methods

fmap :: (a -> b) -> First a -> First b #

(<$) :: a -> First b -> First a #

Applicative First 
Instance details

Defined in Data.Monoid

Methods

pure :: a -> First a #

(<*>) :: First (a -> b) -> First a -> First b #

liftA2 :: (a -> b -> c) -> First a -> First b -> First c #

(*>) :: First a -> First b -> First b #

(<*) :: First a -> First b -> First a #

Foldable First

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => First m -> m #

foldMap :: Monoid m => (a -> m) -> First a -> m #

foldr :: (a -> b -> b) -> b -> First a -> b #

foldr' :: (a -> b -> b) -> b -> First a -> b #

foldl :: (b -> a -> b) -> b -> First a -> b #

foldl' :: (b -> a -> b) -> b -> First a -> b #

foldr1 :: (a -> a -> a) -> First a -> a #

foldl1 :: (a -> a -> a) -> First a -> a #

toList :: First a -> [a] #

null :: First a -> Bool #

length :: First a -> Int #

elem :: Eq a => a -> First a -> Bool #

maximum :: Ord a => First a -> a #

minimum :: Ord a => First a -> a #

sum :: Num a => First a -> a #

product :: Num a => First a -> a #

Traversable First

Since: base-4.8.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> First a -> f (First b) #

sequenceA :: Applicative f => First (f a) -> f (First a) #

mapM :: Monad m => (a -> m b) -> First a -> m (First b) #

sequence :: Monad m => First (m a) -> m (First a) #

Eq a => Eq (First a) 
Instance details

Defined in Data.Monoid

Methods

(==) :: First a -> First a -> Bool #

(/=) :: First a -> First a -> Bool #

Ord a => Ord (First a) 
Instance details

Defined in Data.Monoid

Methods

compare :: First a -> First a -> Ordering #

(<) :: First a -> First a -> Bool #

(<=) :: First a -> First a -> Bool #

(>) :: First a -> First a -> Bool #

(>=) :: First a -> First a -> Bool #

max :: First a -> First a -> First a #

min :: First a -> First a -> First a #

Read a => Read (First a) 
Instance details

Defined in Data.Monoid

Show a => Show (First a) 
Instance details

Defined in Data.Monoid

Methods

showsPrec :: Int -> First a -> ShowS #

show :: First a -> String #

showList :: [First a] -> ShowS #

Generic (First a) 
Instance details

Defined in Data.Monoid

Associated Types

type Rep (First a) :: * -> * #

Methods

from :: First a -> Rep (First a) x #

to :: Rep (First a) x -> First a #

Semigroup (First a)

Since: base-4.9.0.0

Instance details

Defined in Data.Monoid

Methods

(<>) :: First a -> First a -> First a #

sconcat :: NonEmpty (First a) -> First a #

stimes :: Integral b => b -> First a -> First a #

Monoid (First a)

Since: base-2.1

Instance details

Defined in Data.Monoid

Methods

mempty :: First a #

mappend :: First a -> First a -> First a #

mconcat :: [First a] -> First a #

Generic1 First 
Instance details

Defined in Data.Monoid

Associated Types

type Rep1 First :: k -> * #

Methods

from1 :: First a -> Rep1 First a #

to1 :: Rep1 First a -> First a #

type Rep (First a) 
Instance details

Defined in Data.Monoid

type Rep (First a) = D1 (MetaData "First" "Data.Monoid" "base" True) (C1 (MetaCons "First" PrefixI True) (S1 (MetaSel (Just "getFirst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe a))))
type Rep1 First 
Instance details

Defined in Data.Monoid

type Rep1 First = D1 (MetaData "First" "Data.Monoid" "base" True) (C1 (MetaCons "First" PrefixI True) (S1 (MetaSel (Just "getFirst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 Maybe)))

newtype Last a #

Maybe monoid returning the rightmost non-Nothing value.

Last a is isomorphic to Dual (First a), and thus to Dual (Alt Maybe a)

>>> getLast (Last (Just "hello") <> Last Nothing <> Last (Just "world"))
Just "world"

Constructors

Last 

Fields

Instances
Monad Last 
Instance details

Defined in Data.Monoid

Methods

(>>=) :: Last a -> (a -> Last b) -> Last b #

(>>) :: Last a -> Last b -> Last b #

return :: a -> Last a #

fail :: String -> Last a #

Functor Last 
Instance details

Defined in Data.Monoid

Methods

fmap :: (a -> b) -> Last a -> Last b #

(<$) :: a -> Last b -> Last a #

Applicative Last 
Instance details

Defined in Data.Monoid

Methods

pure :: a -> Last a #

(<*>) :: Last (a -> b) -> Last a -> Last b #

liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c #

(*>) :: Last a -> Last b -> Last b #

(<*) :: Last a -> Last b -> Last a #

Foldable Last

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Last m -> m #

foldMap :: Monoid m => (a -> m) -> Last a -> m #

foldr :: (a -> b -> b) -> b -> Last a -> b #

foldr' :: (a -> b -> b) -> b -> Last a -> b #

foldl :: (b -> a -> b) -> b -> Last a -> b #

foldl' :: (b -> a -> b) -> b -> Last a -> b #

foldr1 :: (a -> a -> a) -> Last a -> a #

foldl1 :: (a -> a -> a) -> Last a -> a #

toList :: Last a -> [a] #

null :: Last a -> Bool #

length :: Last a -> Int #

elem :: Eq a => a -> Last a -> Bool #

maximum :: Ord a => Last a -> a #

minimum :: Ord a => Last a -> a #

sum :: Num a => Last a -> a #

product :: Num a => Last a -> a #

Traversable Last

Since: base-4.8.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Last a -> f (Last b) #

sequenceA :: Applicative f => Last (f a) -> f (Last a) #

mapM :: Monad m => (a -> m b) -> Last a -> m (Last b) #

sequence :: Monad m => Last (m a) -> m (Last a) #

Eq a => Eq (Last a) 
Instance details

Defined in Data.Monoid

Methods

(==) :: Last a -> Last a -> Bool #

(/=) :: Last a -> Last a -> Bool #

Ord a => Ord (Last a) 
Instance details

Defined in Data.Monoid

Methods

compare :: Last a -> Last a -> Ordering #

(<) :: Last a -> Last a -> Bool #

(<=) :: Last a -> Last a -> Bool #

(>) :: Last a -> Last a -> Bool #

(>=) :: Last a -> Last a -> Bool #

max :: Last a -> Last a -> Last a #

min :: Last a -> Last a -> Last a #

Read a => Read (Last a) 
Instance details

Defined in Data.Monoid

Show a => Show (Last a) 
Instance details

Defined in Data.Monoid

Methods

showsPrec :: Int -> Last a -> ShowS #

show :: Last a -> String #

showList :: [Last a] -> ShowS #

Generic (Last a) 
Instance details

Defined in Data.Monoid

Associated Types

type Rep (Last a) :: * -> * #

Methods

from :: Last a -> Rep (Last a) x #

to :: Rep (Last a) x -> Last a #

Semigroup (Last a)

Since: base-4.9.0.0

Instance details

Defined in Data.Monoid

Methods

(<>) :: Last a -> Last a -> Last a #

sconcat :: NonEmpty (Last a) -> Last a #

stimes :: Integral b => b -> Last a -> Last a #

Monoid (Last a)

Since: base-2.1

Instance details

Defined in Data.Monoid

Methods

mempty :: Last a #

mappend :: Last a -> Last a -> Last a #

mconcat :: [Last a] -> Last a #

Generic1 Last 
Instance details

Defined in Data.Monoid

Associated Types

type Rep1 Last :: k -> * #

Methods

from1 :: Last a -> Rep1 Last a #

to1 :: Rep1 Last a -> Last a #

type Rep (Last a) 
Instance details

Defined in Data.Monoid

type Rep (Last a) = D1 (MetaData "Last" "Data.Monoid" "base" True) (C1 (MetaCons "Last" PrefixI True) (S1 (MetaSel (Just "getLast") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe a))))
type Rep1 Last 
Instance details

Defined in Data.Monoid

type Rep1 Last = D1 (MetaData "Last" "Data.Monoid" "base" True) (C1 (MetaCons "Last" PrefixI True) (S1 (MetaSel (Just "getLast") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 Maybe)))

newtype Dual a #

The dual of a Monoid, obtained by swapping the arguments of mappend.

>>> getDual (mappend (Dual "Hello") (Dual "World"))
"WorldHello"

Constructors

Dual 

Fields

Instances
Monad Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(>>=) :: Dual a -> (a -> Dual b) -> Dual b #

(>>) :: Dual a -> Dual b -> Dual b #

return :: a -> Dual a #

fail :: String -> Dual a #

Functor Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

fmap :: (a -> b) -> Dual a -> Dual b #

(<$) :: a -> Dual b -> Dual a #

Applicative Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Dual a #

(<*>) :: Dual (a -> b) -> Dual a -> Dual b #

liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c #

(*>) :: Dual a -> Dual b -> Dual b #

(<*) :: Dual a -> Dual b -> Dual a #

Foldable Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Dual m -> m #

foldMap :: Monoid m => (a -> m) -> Dual a -> m #

foldr :: (a -> b -> b) -> b -> Dual a -> b #

foldr' :: (a -> b -> b) -> b -> Dual a -> b #

foldl :: (b -> a -> b) -> b -> Dual a -> b #

foldl' :: (b -> a -> b) -> b -> Dual a -> b #

foldr1 :: (a -> a -> a) -> Dual a -> a #

foldl1 :: (a -> a -> a) -> Dual a -> a #

toList :: Dual a -> [a] #

null :: Dual a -> Bool #

length :: Dual a -> Int #

elem :: Eq a => a -> Dual a -> Bool #

maximum :: Ord a => Dual a -> a #

minimum :: Ord a => Dual a -> a #

sum :: Num a => Dual a -> a #

product :: Num a => Dual a -> a #

Traversable Dual

Since: base-4.8.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Dual a -> f (Dual b) #

sequenceA :: Applicative f => Dual (f a) -> f (Dual a) #

mapM :: Monad m => (a -> m b) -> Dual a -> m (Dual b) #

sequence :: Monad m => Dual (m a) -> m (Dual a) #

Bounded a => Bounded (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

minBound :: Dual a #

maxBound :: Dual a #

Eq a => Eq (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(==) :: Dual a -> Dual a -> Bool #

(/=) :: Dual a -> Dual a -> Bool #

Ord a => Ord (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: Dual a -> Dual a -> Ordering #

(<) :: Dual a -> Dual a -> Bool #

(<=) :: Dual a -> Dual a -> Bool #

(>) :: Dual a -> Dual a -> Bool #

(>=) :: Dual a -> Dual a -> Bool #

max :: Dual a -> Dual a -> Dual a #

min :: Dual a -> Dual a -> Dual a #

Read a => Read (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

Show a => Show (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

showsPrec :: Int -> Dual a -> ShowS #

show :: Dual a -> String #

showList :: [Dual a] -> ShowS #

Generic (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep (Dual a) :: * -> * #

Methods

from :: Dual a -> Rep (Dual a) x #

to :: Rep (Dual a) x -> Dual a #

Semigroup a => Semigroup (Dual a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: Dual a -> Dual a -> Dual a #

sconcat :: NonEmpty (Dual a) -> Dual a #

stimes :: Integral b => b -> Dual a -> Dual a #

Monoid a => Monoid (Dual a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Dual a #

mappend :: Dual a -> Dual a -> Dual a #

mconcat :: [Dual a] -> Dual a #

Generic1 Dual 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep1 Dual :: k -> * #

Methods

from1 :: Dual a -> Rep1 Dual a #

to1 :: Rep1 Dual a -> Dual a #

type Rep (Dual a) 
Instance details

Defined in Data.Semigroup.Internal

type Rep (Dual a) = D1 (MetaData "Dual" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Dual" PrefixI True) (S1 (MetaSel (Just "getDual") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Rep1 Dual 
Instance details

Defined in Data.Semigroup.Internal

type Rep1 Dual = D1 (MetaData "Dual" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Dual" PrefixI True) (S1 (MetaSel (Just "getDual") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

newtype Endo a #

The monoid of endomorphisms under composition.

>>> let computation = Endo ("Hello, " ++) <> Endo (++ "!")
>>> appEndo computation "Haskell"
"Hello, Haskell!"

Constructors

Endo 

Fields

Instances
Generic (Endo a) 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep (Endo a) :: * -> * #

Methods

from :: Endo a -> Rep (Endo a) x #

to :: Rep (Endo a) x -> Endo a #

Semigroup (Endo a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: Endo a -> Endo a -> Endo a #

sconcat :: NonEmpty (Endo a) -> Endo a #

stimes :: Integral b => b -> Endo a -> Endo a #

Monoid (Endo a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Endo a #

mappend :: Endo a -> Endo a -> Endo a #

mconcat :: [Endo a] -> Endo a #

type Rep (Endo a) 
Instance details

Defined in Data.Semigroup.Internal

type Rep (Endo a) = D1 (MetaData "Endo" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Endo" PrefixI True) (S1 (MetaSel (Just "appEndo") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (a -> a))))

newtype All #

Boolean monoid under conjunction (&&).

>>> getAll (All True <> mempty <> All False)
False
>>> getAll (mconcat (map (\x -> All (even x)) [2,4,6,7,8]))
False

Constructors

All 

Fields

Instances
Bounded All 
Instance details

Defined in Data.Semigroup.Internal

Methods

minBound :: All #

maxBound :: All #

Eq All 
Instance details

Defined in Data.Semigroup.Internal

Methods

(==) :: All -> All -> Bool #

(/=) :: All -> All -> Bool #

Ord All 
Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: All -> All -> Ordering #

(<) :: All -> All -> Bool #

(<=) :: All -> All -> Bool #

(>) :: All -> All -> Bool #

(>=) :: All -> All -> Bool #

max :: All -> All -> All #

min :: All -> All -> All #

Read All 
Instance details

Defined in Data.Semigroup.Internal

Show All 
Instance details

Defined in Data.Semigroup.Internal

Methods

showsPrec :: Int -> All -> ShowS #

show :: All -> String #

showList :: [All] -> ShowS #

Generic All 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep All :: * -> * #

Methods

from :: All -> Rep All x #

to :: Rep All x -> All #

Semigroup All

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: All -> All -> All #

sconcat :: NonEmpty All -> All #

stimes :: Integral b => b -> All -> All #

Monoid All

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: All #

mappend :: All -> All -> All #

mconcat :: [All] -> All #

type Rep All 
Instance details

Defined in Data.Semigroup.Internal

type Rep All = D1 (MetaData "All" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "All" PrefixI True) (S1 (MetaSel (Just "getAll") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

newtype Any #

Boolean monoid under disjunction (||).

>>> getAny (Any True <> mempty <> Any False)
True
>>> getAny (mconcat (map (\x -> Any (even x)) [2,4,6,7,8]))
True

Constructors

Any 

Fields

Instances
Bounded Any 
Instance details

Defined in Data.Semigroup.Internal

Methods

minBound :: Any #

maxBound :: Any #

Eq Any 
Instance details

Defined in Data.Semigroup.Internal

Methods

(==) :: Any -> Any -> Bool #

(/=) :: Any -> Any -> Bool #

Ord Any 
Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: Any -> Any -> Ordering #

(<) :: Any -> Any -> Bool #

(<=) :: Any -> Any -> Bool #

(>) :: Any -> Any -> Bool #

(>=) :: Any -> Any -> Bool #

max :: Any -> Any -> Any #

min :: Any -> Any -> Any #

Read Any 
Instance details

Defined in Data.Semigroup.Internal

Show Any 
Instance details

Defined in Data.Semigroup.Internal

Methods

showsPrec :: Int -> Any -> ShowS #

show :: Any -> String #

showList :: [Any] -> ShowS #

Generic Any 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep Any :: * -> * #

Methods

from :: Any -> Rep Any x #

to :: Rep Any x -> Any #

Semigroup Any

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: Any -> Any -> Any #

sconcat :: NonEmpty Any -> Any #

stimes :: Integral b => b -> Any -> Any #

Monoid Any

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Any #

mappend :: Any -> Any -> Any #

mconcat :: [Any] -> Any #

type Rep Any 
Instance details

Defined in Data.Semigroup.Internal

type Rep Any = D1 (MetaData "Any" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Any" PrefixI True) (S1 (MetaSel (Just "getAny") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

newtype Sum a #

Monoid under addition.

>>> getSum (Sum 1 <> Sum 2 <> mempty)
3

Constructors

Sum 

Fields

Instances
Monad Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(>>=) :: Sum a -> (a -> Sum b) -> Sum b #

(>>) :: Sum a -> Sum b -> Sum b #

return :: a -> Sum a #

fail :: String -> Sum a #

Functor Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

fmap :: (a -> b) -> Sum a -> Sum b #

(<$) :: a -> Sum b -> Sum a #

Applicative Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Sum a #

(<*>) :: Sum (a -> b) -> Sum a -> Sum b #

liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c #

(*>) :: Sum a -> Sum b -> Sum b #

(<*) :: Sum a -> Sum b -> Sum a #

Foldable Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Sum m -> m #

foldMap :: Monoid m => (a -> m) -> Sum a -> m #

foldr :: (a -> b -> b) -> b -> Sum a -> b #

foldr' :: (a -> b -> b) -> b -> Sum a -> b #

foldl :: (b -> a -> b) -> b -> Sum a -> b #

foldl' :: (b -> a -> b) -> b -> Sum a -> b #

foldr1 :: (a -> a -> a) -> Sum a -> a #

foldl1 :: (a -> a -> a) -> Sum a -> a #

toList :: Sum a -> [a] #

null :: Sum a -> Bool #

length :: Sum a -> Int #

elem :: Eq a => a -> Sum a -> Bool #

maximum :: Ord a => Sum a -> a #

minimum :: Ord a => Sum a -> a #

sum :: Num a => Sum a -> a #

product :: Num a => Sum a -> a #

Traversable Sum

Since: base-4.8.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Sum a -> f (Sum b) #

sequenceA :: Applicative f => Sum (f a) -> f (Sum a) #

mapM :: Monad m => (a -> m b) -> Sum a -> m (Sum b) #

sequence :: Monad m => Sum (m a) -> m (Sum a) #

Bounded a => Bounded (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

minBound :: Sum a #

maxBound :: Sum a #

Eq a => Eq (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(==) :: Sum a -> Sum a -> Bool #

(/=) :: Sum a -> Sum a -> Bool #

Num a => Num (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(+) :: Sum a -> Sum a -> Sum a #

(-) :: Sum a -> Sum a -> Sum a #

(*) :: Sum a -> Sum a -> Sum a #

negate :: Sum a -> Sum a #

abs :: Sum a -> Sum a #

signum :: Sum a -> Sum a #

fromInteger :: Integer -> Sum a #

Ord a => Ord (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: Sum a -> Sum a -> Ordering #

(<) :: Sum a -> Sum a -> Bool #

(<=) :: Sum a -> Sum a -> Bool #

(>) :: Sum a -> Sum a -> Bool #

(>=) :: Sum a -> Sum a -> Bool #

max :: Sum a -> Sum a -> Sum a #

min :: Sum a -> Sum a -> Sum a #

Read a => Read (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Show a => Show (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

showsPrec :: Int -> Sum a -> ShowS #

show :: Sum a -> String #

showList :: [Sum a] -> ShowS #

Generic (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep (Sum a) :: * -> * #

Methods

from :: Sum a -> Rep (Sum a) x #

to :: Rep (Sum a) x -> Sum a #

Num a => Semigroup (Sum a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: Sum a -> Sum a -> Sum a #

sconcat :: NonEmpty (Sum a) -> Sum a #

stimes :: Integral b => b -> Sum a -> Sum a #

Num a => Monoid (Sum a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Sum a #

mappend :: Sum a -> Sum a -> Sum a #

mconcat :: [Sum a] -> Sum a #

Generic1 Sum 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep1 Sum :: k -> * #

Methods

from1 :: Sum a -> Rep1 Sum a #

to1 :: Rep1 Sum a -> Sum a #

type Rep (Sum a) 
Instance details

Defined in Data.Semigroup.Internal

type Rep (Sum a) = D1 (MetaData "Sum" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Sum" PrefixI True) (S1 (MetaSel (Just "getSum") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Rep1 Sum 
Instance details

Defined in Data.Semigroup.Internal

type Rep1 Sum = D1 (MetaData "Sum" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Sum" PrefixI True) (S1 (MetaSel (Just "getSum") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

newtype Product a #

Monoid under multiplication.

>>> getProduct (Product 3 <> Product 4 <> mempty)
12

Constructors

Product 

Fields

Instances
Monad Product

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(>>=) :: Product a -> (a -> Product b) -> Product b #

(>>) :: Product a -> Product b -> Product b #

return :: a -> Product a #

fail :: String -> Product a #

Functor Product

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

fmap :: (a -> b) -> Product a -> Product b #

(<$) :: a -> Product b -> Product a #

Applicative Product

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Product a #

(<*>) :: Product (a -> b) -> Product a -> Product b #

liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c #

(*>) :: Product a -> Product b -> Product b #

(<*) :: Product a -> Product b -> Product a #

Foldable Product

Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Product m -> m #

foldMap :: Monoid m => (a -> m) -> Product a -> m #

foldr :: (a -> b -> b) -> b -> Product a -> b #

foldr' :: (a -> b -> b) -> b -> Product a -> b #

foldl :: (b -> a -> b) -> b -> Product a -> b #

foldl' :: (b -> a -> b) -> b -> Product a -> b #

foldr1 :: (a -> a -> a) -> Product a -> a #

foldl1 :: (a -> a -> a) -> Product a -> a #

toList :: Product a -> [a] #

null :: Product a -> Bool #

length :: Product a -> Int #

elem :: Eq a => a -> Product a -> Bool #

maximum :: Ord a => Product a -> a #

minimum :: Ord a => Product a -> a #

sum :: Num a => Product a -> a #

product :: Num a => Product a -> a #

Traversable Product

Since: base-4.8.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Product a -> f (Product b) #

sequenceA :: Applicative f => Product (f a) -> f (Product a) #

mapM :: Monad m => (a -> m b) -> Product a -> m (Product b) #

sequence :: Monad m => Product (m a) -> m (Product a) #

Bounded a => Bounded (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Eq a => Eq (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(==) :: Product a -> Product a -> Bool #

(/=) :: Product a -> Product a -> Bool #

Num a => Num (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(+) :: Product a -> Product a -> Product a #

(-) :: Product a -> Product a -> Product a #

(*) :: Product a -> Product a -> Product a #

negate :: Product a -> Product a #

abs :: Product a -> Product a #

signum :: Product a -> Product a #

fromInteger :: Integer -> Product a #

Ord a => Ord (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: Product a -> Product a -> Ordering #

(<) :: Product a -> Product a -> Bool #

(<=) :: Product a -> Product a -> Bool #

(>) :: Product a -> Product a -> Bool #

(>=) :: Product a -> Product a -> Bool #

max :: Product a -> Product a -> Product a #

min :: Product a -> Product a -> Product a #

Read a => Read (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Show a => Show (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

showsPrec :: Int -> Product a -> ShowS #

show :: Product a -> String #

showList :: [Product a] -> ShowS #

Generic (Product a) 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep (Product a) :: * -> * #

Methods

from :: Product a -> Rep (Product a) x #

to :: Rep (Product a) x -> Product a #

Num a => Semigroup (Product a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: Product a -> Product a -> Product a #

sconcat :: NonEmpty (Product a) -> Product a #

stimes :: Integral b => b -> Product a -> Product a #

Num a => Monoid (Product a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Product a #

mappend :: Product a -> Product a -> Product a #

mconcat :: [Product a] -> Product a #

Generic1 Product 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep1 Product :: k -> * #

Methods

from1 :: Product a -> Rep1 Product a #

to1 :: Rep1 Product a -> Product a #

type Rep (Product a) 
Instance details

Defined in Data.Semigroup.Internal

type Rep (Product a) = D1 (MetaData "Product" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Product" PrefixI True) (S1 (MetaSel (Just "getProduct") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Rep1 Product 
Instance details

Defined in Data.Semigroup.Internal

type Rep1 Product = D1 (MetaData "Product" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Product" PrefixI True) (S1 (MetaSel (Just "getProduct") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

newtype Alt (f :: k -> *) (a :: k) :: forall k. (k -> *) -> k -> * #

Monoid under <|>.

Since: base-4.8.0.0

Constructors

Alt 

Fields

Instances
Generic1 (Alt f :: k -> *) 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep1 (Alt f) :: k -> * #

Methods

from1 :: Alt f a -> Rep1 (Alt f) a #

to1 :: Rep1 (Alt f) a -> Alt f a #

Monad f => Monad (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(>>=) :: Alt f a -> (a -> Alt f b) -> Alt f b #

(>>) :: Alt f a -> Alt f b -> Alt f b #

return :: a -> Alt f a #

fail :: String -> Alt f a #

Functor f => Functor (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

fmap :: (a -> b) -> Alt f a -> Alt f b #

(<$) :: a -> Alt f b -> Alt f a #

Applicative f => Applicative (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

pure :: a -> Alt f a #

(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b #

liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c #

(*>) :: Alt f a -> Alt f b -> Alt f b #

(<*) :: Alt f a -> Alt f b -> Alt f a #

Alternative f => Alternative (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

empty :: Alt f a #

(<|>) :: Alt f a -> Alt f a -> Alt f a #

some :: Alt f a -> Alt f [a] #

many :: Alt f a -> Alt f [a] #

MonadPlus f => MonadPlus (Alt f) 
Instance details

Defined in Data.Semigroup.Internal

Methods

mzero :: Alt f a #

mplus :: Alt f a -> Alt f a -> Alt f a #

Enum (f a) => Enum (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

succ :: Alt f a -> Alt f a #

pred :: Alt f a -> Alt f a #

toEnum :: Int -> Alt f a #

fromEnum :: Alt f a -> Int #

enumFrom :: Alt f a -> [Alt f a] #

enumFromThen :: Alt f a -> Alt f a -> [Alt f a] #

enumFromTo :: Alt f a -> Alt f a -> [Alt f a] #

enumFromThenTo :: Alt f a -> Alt f a -> Alt f a -> [Alt f a] #

Eq (f a) => Eq (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(==) :: Alt f a -> Alt f a -> Bool #

(/=) :: Alt f a -> Alt f a -> Bool #

Num (f a) => Num (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

(+) :: Alt f a -> Alt f a -> Alt f a #

(-) :: Alt f a -> Alt f a -> Alt f a #

(*) :: Alt f a -> Alt f a -> Alt f a #

negate :: Alt f a -> Alt f a #

abs :: Alt f a -> Alt f a #

signum :: Alt f a -> Alt f a #

fromInteger :: Integer -> Alt f a #

Ord (f a) => Ord (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: Alt f a -> Alt f a -> Ordering #

(<) :: Alt f a -> Alt f a -> Bool #

(<=) :: Alt f a -> Alt f a -> Bool #

(>) :: Alt f a -> Alt f a -> Bool #

(>=) :: Alt f a -> Alt f a -> Bool #

max :: Alt f a -> Alt f a -> Alt f a #

min :: Alt f a -> Alt f a -> Alt f a #

Read (f a) => Read (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

readsPrec :: Int -> ReadS (Alt f a) #

readList :: ReadS [Alt f a] #

readPrec :: ReadPrec (Alt f a) #

readListPrec :: ReadPrec [Alt f a] #

Show (f a) => Show (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Methods

showsPrec :: Int -> Alt f a -> ShowS #

show :: Alt f a -> String #

showList :: [Alt f a] -> ShowS #

Generic (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

Associated Types

type Rep (Alt f a) :: * -> * #

Methods

from :: Alt f a -> Rep (Alt f a) x #

to :: Rep (Alt f a) x -> Alt f a #

Alternative f => Semigroup (Alt f a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

(<>) :: Alt f a -> Alt f a -> Alt f a #

sconcat :: NonEmpty (Alt f a) -> Alt f a #

stimes :: Integral b => b -> Alt f a -> Alt f a #

Alternative f => Monoid (Alt f a)

Since: base-4.8.0.0

Instance details

Defined in Data.Semigroup.Internal

Methods

mempty :: Alt f a #

mappend :: Alt f a -> Alt f a -> Alt f a #

mconcat :: [Alt f a] -> Alt f a #

type Rep1 (Alt f :: k -> *) 
Instance details

Defined in Data.Semigroup.Internal

type Rep1 (Alt f :: k -> *) = D1 (MetaData "Alt" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Alt" PrefixI True) (S1 (MetaSel (Just "getAlt") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f)))
type Rep (Alt f a) 
Instance details

Defined in Data.Semigroup.Internal

type Rep (Alt f a) = D1 (MetaData "Alt" "Data.Semigroup.Internal" "base" True) (C1 (MetaCons "Alt" PrefixI True) (S1 (MetaSel (Just "getAlt") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f a))))

unwords :: [String] -> String #

unwords is an inverse operation to words. It joins words with separating spaces.

>>> unwords ["Lorem", "ipsum", "dolor"]
"Lorem ipsum dolor"

words :: String -> [String] #

words breaks a string up into a list of words, which were delimited by white space.

>>> words "Lorem ipsum\ndolor"
["Lorem","ipsum","dolor"]

unlines :: [String] -> String #

unlines is an inverse operation to lines. It joins lines, after appending a terminating newline to each.

>>> unlines ["Hello", "World", "!"]
"Hello\nWorld\n!\n"

lines :: String -> [String] #

lines breaks a string up into a list of strings at newline characters. The resulting strings do not contain newlines.

Note that after splitting the string at newline characters, the last part of the string is considered a line even if it doesn't end with a newline. For example,

>>> lines ""
[]
>>> lines "\n"
[""]
>>> lines "one"
["one"]
>>> lines "one\n"
["one"]
>>> lines "one\n\n"
["one",""]
>>> lines "one\ntwo"
["one","two"]
>>> lines "one\ntwo\n"
["one","two"]

Thus lines s contains at least as many elements as newlines in s.

unfoldr :: (b -> Maybe (a, b)) -> b -> [a] #

The unfoldr function is a `dual' to foldr: while foldr reduces a list to a summary value, unfoldr builds a list from a seed value. The function takes the element and returns Nothing if it is done producing the list or returns Just (a,b), in which case, a is a prepended to the list and b is used as the next element in a recursive call. For example,

iterate f == unfoldr (\x -> Just (x, f x))

In some cases, unfoldr can undo a foldr operation:

unfoldr f' (foldr f z xs) == xs

if the following holds:

f' (f x y) = Just (x,y)
f' z       = Nothing

A simple use of unfoldr:

>>> unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10
[10,9,8,7,6,5,4,3,2,1]

sortOn :: Ord b => (a -> b) -> [a] -> [a] #

Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (comparing f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform.

Elements are arranged from from lowest to highest, keeping duplicates in the order they appeared in the input.

>>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
[(1,"Hello"),(2,"world"),(4,"!")]

Since: base-4.8.0.0

sortBy :: (a -> a -> Ordering) -> [a] -> [a] #

The sortBy function is the non-overloaded version of sort.

>>> sortBy (\(a,_) (b,_) -> compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
[(1,"Hello"),(2,"world"),(4,"!")]

sort :: Ord a => [a] -> [a] #

The sort function implements a stable sorting algorithm. It is a special case of sortBy, which allows the programmer to supply their own comparison function.

Elements are arranged from from lowest to highest, keeping duplicates in the order they appeared in the input.

>>> sort [1,6,4,3,2,5]
[1,2,3,4,5,6]

permutations :: [a] -> [[a]] #

The permutations function returns the list of all permutations of the argument.

>>> permutations "abc"
["abc","bac","cba","bca","cab","acb"]

subsequences :: [a] -> [[a]] #

The subsequences function returns the list of all subsequences of the argument.

>>> subsequences "abc"
["","a","b","ab","c","ac","bc","abc"]

tails :: [a] -> [[a]] #

The tails function returns all final segments of the argument, longest first. For example,

>>> tails "abc"
["abc","bc","c",""]

Note that tails has the following strictness property: tails _|_ = _|_ : _|_

inits :: [a] -> [[a]] #

The inits function returns all initial segments of the argument, shortest first. For example,

>>> inits "abc"
["","a","ab","abc"]

Note that inits has the following strictness property: inits (xs ++ _|_) = inits xs ++ _|_

In particular, inits _|_ = [] : _|_

groupBy :: (a -> a -> Bool) -> [a] -> [[a]] #

The groupBy function is the non-overloaded version of group.

group :: Eq a => [a] -> [[a]] #

The group function takes a list and returns a list of lists such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. For example,

>>> group "Mississippi"
["M","i","ss","i","ss","i","pp","i"]

It is a special case of groupBy, which allows the programmer to supply their own equality test.

deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] #

The deleteFirstsBy function takes a predicate and two lists and returns the first list with the first occurrence of each element of the second list removed.

unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g]) #

The unzip7 function takes a list of seven-tuples and returns seven lists, analogous to unzip.

unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f]) #

The unzip6 function takes a list of six-tuples and returns six lists, analogous to unzip.

unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e]) #

The unzip5 function takes a list of five-tuples and returns five lists, analogous to unzip.

unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d]) #

The unzip4 function takes a list of quadruples and returns four lists, analogous to unzip.

zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h] #

The zipWith7 function takes a function which combines seven elements, as well as seven lists and returns a list of their point-wise combination, analogous to zipWith.

zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] #

The zipWith6 function takes a function which combines six elements, as well as six lists and returns a list of their point-wise combination, analogous to zipWith.

zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] #

The zipWith5 function takes a function which combines five elements, as well as five lists and returns a list of their point-wise combination, analogous to zipWith.

zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e] #

The zipWith4 function takes a function which combines four elements, as well as four lists and returns a list of their point-wise combination, analogous to zipWith.

zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)] #

The zip7 function takes seven lists and returns a list of seven-tuples, analogous to zip.

zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)] #

The zip6 function takes six lists and returns a list of six-tuples, analogous to zip.

zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)] #

The zip5 function takes five lists and returns a list of five-tuples, analogous to zip.

zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)] #

The zip4 function takes four lists and returns a list of quadruples, analogous to zip.

genericReplicate :: Integral i => i -> a -> [a] #

The genericReplicate function is an overloaded version of replicate, which accepts any Integral value as the number of repetitions to make.

genericIndex :: Integral i => [a] -> i -> a #

The genericIndex function is an overloaded version of !!, which accepts any Integral value as the index.

genericSplitAt :: Integral i => i -> [a] -> ([a], [a]) #

The genericSplitAt function is an overloaded version of splitAt, which accepts any Integral value as the position at which to split.

genericDrop :: Integral i => i -> [a] -> [a] #

The genericDrop function is an overloaded version of drop, which accepts any Integral value as the number of elements to drop.

genericTake :: Integral i => i -> [a] -> [a] #

The genericTake function is an overloaded version of take, which accepts any Integral value as the number of elements to take.

genericLength :: Num i => [a] -> i #

The genericLength function is an overloaded version of length. In particular, instead of returning an Int, it returns any type which is an instance of Num. It is, however, less efficient than length.

insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a] #

The non-overloaded version of insert.

insert :: Ord a => a -> [a] -> [a] #

The insert function takes an element and a list and inserts the element into the list at the first position where it is less than or equal to the next element. In particular, if the list is sorted before the call, the result will also be sorted. It is a special case of insertBy, which allows the programmer to supply their own comparison function.

>>> insert 4 [1,2,3,5,6,7]
[1,2,3,4,5,6,7]

partition :: (a -> Bool) -> [a] -> ([a], [a]) #

The partition function takes a predicate a list and returns the pair of lists of elements which do and do not satisfy the predicate, respectively; i.e.,

partition p xs == (filter p xs, filter (not . p) xs)
>>> partition (`elem` "aeiou") "Hello World!"
("eoo","Hll Wrld!")

transpose :: [[a]] -> [[a]] #

The transpose function transposes the rows and columns of its argument. For example,

>>> transpose [[1,2,3],[4,5,6]]
[[1,4],[2,5],[3,6]]

If some of the rows are shorter than the following rows, their elements are skipped:

>>> transpose [[10,11],[20],[],[30,31,32]]
[[10,20,30],[11,31],[32]]

intercalate :: [a] -> [[a]] -> [a] #

intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.

>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"

intersperse :: a -> [a] -> [a] #

The intersperse function takes an element and a list and `intersperses' that element between the elements of the list. For example,

>>> intersperse ',' "abcde"
"a,b,c,d,e"

intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] #

The intersectBy function is the non-overloaded version of intersect.

intersect :: Eq a => [a] -> [a] -> [a] #

The intersect function takes the list intersection of two lists. For example,

>>> [1,2,3,4] `intersect` [2,4,6,8]
[2,4]

If the first list contains duplicates, so will the result.

>>> [1,2,2,3,4] `intersect` [6,4,4,2]
[2,2,4]

It is a special case of intersectBy, which allows the programmer to supply their own equality test. If the element is found in both the first and the second list, the element from the first list will be used.

unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] #

The unionBy function is the non-overloaded version of union.

union :: Eq a => [a] -> [a] -> [a] #

The union function returns the list union of the two lists. For example,

>>> "dog" `union` "cow"
"dogcw"

Duplicates, and elements of the first list, are removed from the the second list, but if the first list contains duplicates, so will the result. It is a special case of unionBy, which allows the programmer to supply their own equality test.

(\\) :: Eq a => [a] -> [a] -> [a] infix 5 #

The \\ function is list difference (non-associative). In the result of xs \\ ys, the first occurrence of each element of ys in turn (if any) has been removed from xs. Thus

(xs ++ ys) \\ xs == ys.
>>> "Hello World!" \\ "ell W"
"Hoorld!"

It is a special case of deleteFirstsBy, which allows the programmer to supply their own equality test.

deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a] #

The deleteBy function behaves like delete, but takes a user-supplied equality predicate.

>>> deleteBy (<=) 4 [1..10]
[1,2,3,5,6,7,8,9,10]

delete :: Eq a => a -> [a] -> [a] #

delete x removes the first occurrence of x from its list argument. For example,

>>> delete 'a' "banana"
"bnana"

It is a special case of deleteBy, which allows the programmer to supply their own equality test.

nubBy :: (a -> a -> Bool) -> [a] -> [a] #

The nubBy function behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded == function.

>>> nubBy (\x y -> mod x 3 == mod y 3) [1,2,4,5,6]
[1,2,6]

nub :: Eq a => [a] -> [a] #

O(n^2). The nub function removes duplicate elements from a list. In particular, it keeps only the first occurrence of each element. (The name nub means `essence'.) It is a special case of nubBy, which allows the programmer to supply their own equality test.

>>> nub [1,2,3,4,3,2,1,2,4,3,5]
[1,2,3,4,5]

isInfixOf :: Eq a => [a] -> [a] -> Bool #

The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere within the second.

>>> isInfixOf "Haskell" "I really like Haskell."
True
>>> isInfixOf "Ial" "I really like Haskell."
False

isSuffixOf :: Eq a => [a] -> [a] -> Bool #

The isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second. The second list must be finite.

>>> "ld!" `isSuffixOf` "Hello World!"
True
>>> "World" `isSuffixOf` "Hello World!"
False

isPrefixOf :: Eq a => [a] -> [a] -> Bool #

The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.

>>> "Hello" `isPrefixOf` "Hello World!"
True
>>> "Hello" `isPrefixOf` "Wello Horld!"
False

findIndices :: (a -> Bool) -> [a] -> [Int] #

The findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.

>>> findIndices (`elem` "aeiou") "Hello World!"
[1,4,7]

findIndex :: (a -> Bool) -> [a] -> Maybe Int #

The findIndex function takes a predicate and a list and returns the index of the first element in the list satisfying the predicate, or Nothing if there is no such element.

>>> findIndex isSpace "Hello World!"
Just 5

elemIndices :: Eq a => a -> [a] -> [Int] #

The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.

>>> elemIndices 'o' "Hello World"
[4,7]

elemIndex :: Eq a => a -> [a] -> Maybe Int #

The elemIndex function returns the index of the first element in the given list which is equal (by ==) to the query element, or Nothing if there is no such element.

>>> elemIndex 4 [0..]
Just 4

stripPrefix :: Eq a => [a] -> [a] -> Maybe [a] #

The stripPrefix function drops the given prefix from a list. It returns Nothing if the list did not start with the prefix given, or Just the list after the prefix, if it does.

>>> stripPrefix "foo" "foobar"
Just "bar"
>>> stripPrefix "foo" "foo"
Just ""
>>> stripPrefix "foo" "barfoo"
Nothing
>>> stripPrefix "foo" "barfoobaz"
Nothing

dropWhileEnd :: (a -> Bool) -> [a] -> [a] #

The dropWhileEnd function drops the largest suffix of a list in which the given predicate holds for all elements. For example:

>>> dropWhileEnd isSpace "foo\n"
"foo"
>>> dropWhileEnd isSpace "foo bar"
"foo bar"
dropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined

Since: base-4.5.0.0

(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #

An infix synonym for fmap.

The name of this operator is an allusion to $. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b
(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas $ is function application, <$> is function application lifted over a Functor.

Examples

Expand

Convert from a Maybe Int to a Maybe String using show:

>>> show <$> Nothing
Nothing
>>> show <$> Just 3
Just "3"

Convert from an Either Int Int to an Either Int String using show:

>>> show <$> Left 17
Left 17
>>> show <$> Right 17
Right "17"

Double each element of a list:

>>> (*2) <$> [1,2,3]
[2,4,6]

Apply even to the second element of a pair:

>>> even <$> (2,2)
(2,True)

denominator :: Ratio a -> a #

Extract the denominator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.

numerator :: Ratio a -> a #

Extract the numerator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.

(%) :: Integral a => a -> a -> Ratio a infixl 7 #

Forms the ratio of two integral numbers.

unzip3 :: [(a, b, c)] -> ([a], [b], [c]) #

The unzip3 function takes a list of triples and returns three lists, analogous to unzip.

unzip :: [(a, b)] -> ([a], [b]) #

unzip transforms a list of pairs into a list of first components and a list of second components.

zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] #

The zipWith3 function takes a function which combines three elements, as well as three lists and returns a list of their point-wise combination, analogous to zipWith.

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] #

zipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two lists to produce the list of corresponding sums.

zipWith is right-lazy:

zipWith f [] _|_ = []

zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] #

zip3 takes three lists and returns a list of triples, analogous to zip.

(!!) :: [a] -> Int -> a infixl 9 #

List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.

lookup :: Eq a => a -> [(a, b)] -> Maybe b #

lookup key assocs looks up a key in an association list.

reverse :: [a] -> [a] #

reverse xs returns the elements of xs in reverse order. xs must be finite.

break :: (a -> Bool) -> [a] -> ([a], [a]) #

break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list:

break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
break (< 9) [1,2,3] == ([],[1,2,3])
break (> 9) [1,2,3] == ([1,2,3],[])

break p is equivalent to span (not . p).

span :: (a -> Bool) -> [a] -> ([a], [a]) #

span, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that satisfy p and second element is the remainder of the list:

span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
span (< 9) [1,2,3] == ([1,2,3],[])
span (< 0) [1,2,3] == ([],[1,2,3])

span p xs is equivalent to (takeWhile p xs, dropWhile p xs)

splitAt :: Int -> [a] -> ([a], [a]) #

splitAt n xs returns a tuple where first element is xs prefix of length n and second element is the remainder of the list:

splitAt 6 "Hello World!" == ("Hello ","World!")
splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
splitAt 1 [1,2,3] == ([1],[2,3])
splitAt 3 [1,2,3] == ([1,2,3],[])
splitAt 4 [1,2,3] == ([1,2,3],[])
splitAt 0 [1,2,3] == ([],[1,2,3])
splitAt (-1) [1,2,3] == ([],[1,2,3])

It is equivalent to (take n xs, drop n xs) when n is not _|_ (splitAt _|_ xs = _|_). splitAt is an instance of the more general genericSplitAt, in which n may be of any integral type.

drop :: Int -> [a] -> [a] #

drop n xs returns the suffix of xs after the first n elements, or [] if n > length xs:

drop 6 "Hello World!" == "World!"
drop 3 [1,2,3,4,5] == [4,5]
drop 3 [1,2] == []
drop 3 [] == []
drop (-1) [1,2] == [1,2]
drop 0 [1,2] == [1,2]

It is an instance of the more general genericDrop, in which n may be of any integral type.

take :: Int -> [a] -> [a] #

take n, applied to a list xs, returns the prefix of xs of length n, or xs itself if n > length xs:

take 5 "Hello World!" == "Hello"
take 3 [1,2,3,4,5] == [1,2,3]
take 3 [1,2] == [1,2]
take 3 [] == []
take (-1) [1,2] == []
take 0 [1,2] == []

It is an instance of the more general genericTake, in which n may be of any integral type.

dropWhile :: (a -> Bool) -> [a] -> [a] #

dropWhile p xs returns the suffix remaining after takeWhile p xs:

dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
dropWhile (< 9) [1,2,3] == []
dropWhile (< 0) [1,2,3] == [1,2,3]

takeWhile :: (a -> Bool) -> [a] -> [a] #

takeWhile, applied to a predicate p and a list xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p:

takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2]
takeWhile (< 9) [1,2,3] == [1,2,3]
takeWhile (< 0) [1,2,3] == []

cycle :: [a] -> [a] #

cycle ties a finite list into a circular one, or equivalently, the infinite repetition of the original list. It is the identity on infinite lists.

replicate :: Int -> a -> [a] #

replicate n x is a list of length n with x the value of every element. It is an instance of the more general genericReplicate, in which n may be of any integral type.

repeat :: a -> [a] #

repeat x is an infinite list, with x the value of every element.

iterate' :: (a -> a) -> a -> [a] #

'iterate\'' is the strict version of iterate.

It ensures that the result of each application of force to weak head normal form before proceeding.

iterate :: (a -> a) -> a -> [a] #

iterate f x returns an infinite list of repeated applications of f to x:

iterate f x == [x, f x, f (f x), ...]

Note that iterate is lazy, potentially leading to thunk build-up if the consumer doesn't force each iterate. See 'iterate\'' for a strict variant of this function.

scanr1 :: (a -> a -> a) -> [a] -> [a] #

scanr1 is a variant of scanr that has no starting value argument.

scanr :: (a -> b -> b) -> b -> [a] -> [b] #

scanr is the right-to-left dual of scanl. Note that

head (scanr f z xs) == foldr f z xs.

scanl' :: (b -> a -> b) -> b -> [a] -> [b] #

A strictly accumulating version of scanl

scanl1 :: (a -> a -> a) -> [a] -> [a] #

scanl1 is a variant of scanl that has no starting value argument:

scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]

scanl :: (b -> a -> b) -> b -> [a] -> [b] #

scanl is similar to foldl, but returns a list of successive reduced values from the left:

scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]

Note that

last (scanl f z xs) == foldl f z xs.

foldl1' :: (a -> a -> a) -> [a] -> a #

A strict version of foldl1

init :: [a] -> [a] #

Return all the elements of a list except the last one. The list must be non-empty.

last :: [a] -> a #

Extract the last element of a list, which must be finite and non-empty.

tail :: [a] -> [a] #

Extract the elements after the head of a list, which must be non-empty.

uncons :: [a] -> Maybe (a, [a]) #

Decompose a list into its head and tail. If the list is empty, returns Nothing. If the list is non-empty, returns Just (x, xs), where x is the head of the list and xs its tail.

Since: base-4.8.0.0

head :: [a] -> a #

Extract the first element of a list, which must be non-empty.

isEmptyMVar :: MVar a -> IO Bool #

Check whether a given MVar is empty.

Notice that the boolean value returned is just a snapshot of the state of the MVar. By the time you get to react on its result, the MVar may have been filled (or emptied) - so be extremely careful when using this operation. Use tryTakeMVar instead if possible.

tryReadMVar :: MVar a -> IO (Maybe a) #

A non-blocking version of readMVar. The tryReadMVar function returns immediately, with Nothing if the MVar was empty, or Just a if the MVar was full with contents a.

Since: base-4.7.0.0

tryPutMVar :: MVar a -> a -> IO Bool #

A non-blocking version of putMVar. The tryPutMVar function attempts to put the value a into the MVar, returning True if it was successful, or False otherwise.

tryTakeMVar :: MVar a -> IO (Maybe a) #

A non-blocking version of takeMVar. The tryTakeMVar function returns immediately, with Nothing if the MVar was empty, or Just a if the MVar was full with contents a. After tryTakeMVar, the MVar is left empty.

putMVar :: MVar a -> a -> IO () #

Put a value into an MVar. If the MVar is currently full, putMVar will wait until it becomes empty.

There are two further important properties of putMVar:

  • putMVar is single-wakeup. That is, if there are multiple threads blocked in putMVar, and the MVar becomes empty, only one thread will be woken up. The runtime guarantees that the woken thread completes its putMVar operation.
  • When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.

readMVar :: MVar a -> IO a #

Atomically read the contents of an MVar. If the MVar is currently empty, readMVar will wait until it is full. readMVar is guaranteed to receive the next putMVar.

readMVar is multiple-wakeup, so when multiple readers are blocked on an MVar, all of them are woken up at the same time.

Compatibility note: Prior to base 4.7, readMVar was a combination of takeMVar and putMVar. This mean that in the presence of other threads attempting to putMVar, readMVar could block. Furthermore, readMVar would not receive the next putMVar if there was already a pending thread blocked on takeMVar. The old behavior can be recovered by implementing 'readMVar as follows:

 readMVar :: MVar a -> IO a
 readMVar m =
   mask_ $ do
     a <- takeMVar m
     putMVar m a
     return a

takeMVar :: MVar a -> IO a #

Return the contents of the MVar. If the MVar is currently empty, takeMVar will wait until it is full. After a takeMVar, the MVar is left empty.

There are two further important properties of takeMVar:

  • takeMVar is single-wakeup. That is, if there are multiple threads blocked in takeMVar, and the MVar becomes full, only one thread will be woken up. The runtime guarantees that the woken thread completes its takeMVar operation.
  • When multiple threads are blocked on an MVar, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using MVars.

newMVar :: a -> IO (MVar a) #

Create an MVar which contains the supplied value.

newEmptyMVar :: IO (MVar a) #

Create an MVar which is initially empty.

data MVar a #

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a a box, which may be empty or full.

Instances
Eq (MVar a)

Since: base-4.1.0.0

Instance details

Defined in GHC.MVar

Methods

(==) :: MVar a -> MVar a -> Bool #

(/=) :: MVar a -> MVar a -> Bool #

liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d #

Lift a ternary function to actions.

liftA :: Applicative f => (a -> b) -> f a -> f b #

Lift a function to actions. This function may be used as a value for fmap in a Functor instance.

(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 #

A variant of <*> with the arguments reversed.

type Event a = (Arc, Arc, a) Source #

An Event is a value that occurs during the period given by the first Arc. The second one indicates the event's "domain of influence". These will often be the same, but many temporal transformations, such as rotation and scaling time, may result in arcs being split or truncated. In such cases, the first arc is preserved, but the second arc reflects the portion of the event which is relevant.

type Arc = (Time, Time) Source #

(s,e) :: Arc represents a time interval with a start and end value. { t : s <= t && t < e }

type Time = Rational Source #

Time is represented by a rational number. Each natural number represents both the start of the next rhythmic cycle, and the end of the previous one. Rational numbers are used so that subdivisions of each cycle can be accurately represented.

sam :: Time -> Time Source #

The starting point of the current cycle. A cycle occurs from each natural number to the next, so this is equivalent to floor.

nextSam :: Time -> Time Source #

The end point of the current cycle (and starting point of the next cycle)

cyclePos :: Time -> Time Source #

The position of a time value relative to the start of its cycle.

isIn :: Arc -> Time -> Bool Source #

isIn a t is True if t is inside the arc represented by a.

arcCycles :: Arc -> [Arc] Source #

Splits the given Arc into a list of Arcs, at cycle boundaries.

arcCycles' :: Arc -> [Arc] Source #

Splits the given Arc into a list of Arcs, at cycle boundaries, but wrapping the arcs within the same cycle.

subArc :: Arc -> Arc -> Maybe Arc Source #

subArc i j is the arc that is the intersection of i and j.

mapArc :: (Time -> Time) -> Arc -> Arc Source #

Map the given function over both the start and end Time values of the given Arc.

mapCycle :: (Time -> Time) -> Arc -> Arc Source #

Similar to mapArc but time is relative to the cycle (i.e. the sam of the start of the arc)

mirrorArc :: Time -> Arc -> Arc Source #

Returns the `mirror image' of an Arc around the given point intime, used by Sound.Tidal.Pattern.rev.

eventStart :: Event a -> Time Source #

The start time of the given Event

eventOnset :: Event a -> Time Source #

The original onset of the given Event

eventOffset :: Event a -> Time Source #

The original offset of the given Event

eventArc :: Event a -> Arc Source #

The arc of the given Event

midPoint :: Arc -> Time Source #

The midpoint of an Arc

hasOnset :: Event a -> Bool Source #

True if an Event's first and second Arc's start times match

hasOffset :: Event a -> Bool Source #

True if an Event's first and second Arc's end times match

onsetIn :: Arc -> Event a -> Bool Source #

True if an Event's starts is within given Arc

offsetIn :: Arc -> Event a -> Bool Source #

True if an Event's ends is within given Arc

data TConnection Source #

Instances
Eq TConnection Source # 
Instance details

Defined in Sound.Tidal.Tempo

data ServerMode Source #

Constructors

Master 
Slave UDP 
Instances
Show ServerMode Source # 
Instance details

Defined in Sound.Tidal.Tempo

data Tempo Source #

Constructors

Tempo 
Instances
Show Tempo Source # 
Instance details

Defined in Sound.Tidal.Tempo

Methods

showsPrec :: Int -> Tempo -> ShowS #

show :: Tempo -> String #

showList :: [Tempo] -> ShowS #

clocked :: (Tempo -> Int -> IO ()) -> IO () Source #

clockedTick :: Int -> (Tempo -> Int -> IO ()) -> IO () Source #

newtype Pattern a Source #

The pattern datatype, a function from a time Arc to Event values. For discrete patterns, this returns the events which are active during that time. For continuous patterns, events with values for the midpoint of the given Arc is returned.

Constructors

Pattern 

Fields

Instances
Monad Pattern Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

(>>=) :: Pattern a -> (a -> Pattern b) -> Pattern b #

(>>) :: Pattern a -> Pattern b -> Pattern b #

return :: a -> Pattern a #

fail :: String -> Pattern a #

Functor Pattern Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

fmap :: (a -> b) -> Pattern a -> Pattern b #

(<$) :: a -> Pattern b -> Pattern a #

Applicative Pattern Source #

pure a returns a pattern with an event with value a, which has a duration of one cycle, and repeats every cycle.

Instance details

Defined in Sound.Tidal.Pattern

Methods

pure :: a -> Pattern a #

(<*>) :: Pattern (a -> b) -> Pattern a -> Pattern b #

liftA2 :: (a -> b -> c) -> Pattern a -> Pattern b -> Pattern c #

(*>) :: Pattern a -> Pattern b -> Pattern b #

(<*) :: Pattern a -> Pattern b -> Pattern a #

Enum a => Enum (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

succ :: Pattern a -> Pattern a #

pred :: Pattern a -> Pattern a #

toEnum :: Int -> Pattern a #

fromEnum :: Pattern a -> Int #

enumFrom :: Pattern a -> [Pattern a] #

enumFromThen :: Pattern a -> Pattern a -> [Pattern a] #

enumFromTo :: Pattern a -> Pattern a -> [Pattern a] #

enumFromThenTo :: Pattern a -> Pattern a -> Pattern a -> [Pattern a] #

Eq (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

(==) :: Pattern a -> Pattern a -> Bool #

(/=) :: Pattern a -> Pattern a -> Bool #

Floating a => Floating (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

pi :: Pattern a #

exp :: Pattern a -> Pattern a #

log :: Pattern a -> Pattern a #

sqrt :: Pattern a -> Pattern a #

(**) :: Pattern a -> Pattern a -> Pattern a #

logBase :: Pattern a -> Pattern a -> Pattern a #

sin :: Pattern a -> Pattern a #

cos :: Pattern a -> Pattern a #

tan :: Pattern a -> Pattern a #

asin :: Pattern a -> Pattern a #

acos :: Pattern a -> Pattern a #

atan :: Pattern a -> Pattern a #

sinh :: Pattern a -> Pattern a #

cosh :: Pattern a -> Pattern a #

tanh :: Pattern a -> Pattern a #

asinh :: Pattern a -> Pattern a #

acosh :: Pattern a -> Pattern a #

atanh :: Pattern a -> Pattern a #

log1p :: Pattern a -> Pattern a #

expm1 :: Pattern a -> Pattern a #

log1pexp :: Pattern a -> Pattern a #

log1mexp :: Pattern a -> Pattern a #

Fractional a => Fractional (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

(/) :: Pattern a -> Pattern a -> Pattern a #

recip :: Pattern a -> Pattern a #

fromRational :: Rational -> Pattern a #

Integral a => Integral (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

quot :: Pattern a -> Pattern a -> Pattern a #

rem :: Pattern a -> Pattern a -> Pattern a #

div :: Pattern a -> Pattern a -> Pattern a #

mod :: Pattern a -> Pattern a -> Pattern a #

quotRem :: Pattern a -> Pattern a -> (Pattern a, Pattern a) #

divMod :: Pattern a -> Pattern a -> (Pattern a, Pattern a) #

toInteger :: Pattern a -> Integer #

Num a => Num (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

(+) :: Pattern a -> Pattern a -> Pattern a #

(-) :: Pattern a -> Pattern a -> Pattern a #

(*) :: Pattern a -> Pattern a -> Pattern a #

negate :: Pattern a -> Pattern a #

abs :: Pattern a -> Pattern a #

signum :: Pattern a -> Pattern a #

fromInteger :: Integer -> Pattern a #

Ord a => Ord (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

compare :: Pattern a -> Pattern a -> Ordering #

(<) :: Pattern a -> Pattern a -> Bool #

(<=) :: Pattern a -> Pattern a -> Bool #

(>) :: Pattern a -> Pattern a -> Bool #

(>=) :: Pattern a -> Pattern a -> Bool #

max :: Pattern a -> Pattern a -> Pattern a #

min :: Pattern a -> Pattern a -> Pattern a #

(Num a, Ord a) => Real (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

toRational :: Pattern a -> Rational #

RealFloat a => RealFloat (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

RealFrac a => RealFrac (Pattern a) Source # 
Instance details

Defined in Sound.Tidal.Pattern

Methods

properFraction :: Integral b => Pattern a -> (b, Pattern a) #

truncate :: Integral b => Pattern a -> b #

round :: Integral b => Pattern a -> b #

ceiling :: Integral b => Pattern a -> b #

floor :: Integral b => Pattern a -> b #

Show a => Show (Pattern a) Source #

show (p :: Pattern) returns a text string representing the event values active during the first cycle of the given pattern.

Instance details

Defined in Sound.Tidal.Pattern

Methods

showsPrec :: Int -> Pattern a -> ShowS #

show :: Pattern a -> String #

showList :: [Pattern a] -> ShowS #

(Enumerable a, Parseable a) => IsString (Pattern a) # 
Instance details

Defined in Sound.Tidal.Parse

Methods

fromString :: String -> Pattern a #

showTime :: (Show a, Integral a) => Ratio a -> String Source #

converts a ratio into human readable string, e.g. 1/3

showArc :: Arc -> String Source #

converts a time arc into human readable string, e.g. 13 34

showEvent :: Show a => Event a -> String Source #

converts an event into human readable string, e.g. ("bd" 14 23)

atom :: a -> Pattern a Source #

atom is a synonym for pure.

silence :: Pattern a Source #

silence returns a pattern with no events.

withQueryArc :: (Arc -> Arc) -> Pattern a -> Pattern a Source #

withQueryArc f p returns a new Pattern with function f applied to the Arc values passed to the original Pattern p.

withQueryTime :: (Time -> Time) -> Pattern a -> Pattern a Source #

withQueryTime f p returns a new Pattern with function f applied to the both the start and end Time of the Arc passed to Pattern p.

withResultArc :: (Arc -> Arc) -> Pattern a -> Pattern a Source #

withResultArc f p returns a new Pattern with function f applied to the Arc values in the events returned from the original Pattern p.

withResultTime :: (Time -> Time) -> Pattern a -> Pattern a Source #

withResultTime f p returns a new Pattern with function f applied to the both the start and end Time of the Arc values in the events returned from the original Pattern p.

withEvent :: (Event a -> Event b) -> Pattern a -> Pattern b Source #

withEvent f p returns a new Pattern with events mapped over function f.

timedValues :: Pattern a -> Pattern (Arc, a) Source #

timedValues p returns a new Pattern where values are turned into tuples of Arc and value.

overlay :: Pattern a -> Pattern a -> Pattern a Source #

overlay combines two Patterns into a new pattern, so that their events are combined over time. This is the same as the infix operator <>.

stack :: [Pattern a] -> Pattern a Source #

stack combines a list of Patterns into a new pattern, so that their events are combined over time.

append :: Pattern a -> Pattern a -> Pattern a Source #

append combines two patterns Patterns into a new pattern, so that the events of the second pattern are appended to those of the first pattern, within a single cycle

append' :: Pattern a -> Pattern a -> Pattern a Source #

append' does the same as append, but over two cycles, so that the cycles alternate between the two patterns.

fastcat :: [Pattern a] -> Pattern a Source #

fastcat returns a new pattern which interlaces the cycles of the given patterns, within a single cycle. It's the equivalent of append, but with a list of patterns.

slowcat :: [Pattern a] -> Pattern a Source #

slowcat does the same as fastcat, but maintaining the duration of the original patterns. It is the equivalent of append', but with a list of patterns.

cat :: [Pattern a] -> Pattern a Source #

cat is an alias of slowcat

listToPat :: [a] -> Pattern a Source #

listToPat turns the given list of values to a Pattern, which cycles through the list.

maybeListToPat :: [Maybe a] -> Pattern a Source #

maybeListToPat is similar to listToPat, but allows values to be optional using the Maybe type, so that Nothing results in gaps in the pattern.

run :: (Enum a, Num a) => Pattern a -> Pattern a Source #

run n returns a pattern representing a cycle of numbers from 0 to n-1.

_run :: (Enum a, Num a) => a -> Pattern a Source #

scan :: (Enum a, Num a) => Pattern a -> Pattern a Source #

_scan :: (Enum a, Num a) => a -> Pattern a Source #

temporalParam :: (a -> Pattern b -> Pattern c) -> Pattern a -> Pattern b -> Pattern c Source #

temporalParam2 :: (a -> b -> Pattern c -> Pattern d) -> Pattern a -> Pattern b -> Pattern c -> Pattern d Source #

temporalParam3 :: (a -> b -> c -> Pattern d -> Pattern e) -> Pattern a -> Pattern b -> Pattern c -> Pattern d -> Pattern e Source #

temporalParam' :: (a -> Pattern b -> Pattern c) -> Pattern a -> Pattern b -> Pattern c Source #

temporalParam2' :: (a -> b -> Pattern c -> Pattern d) -> Pattern a -> Pattern b -> Pattern c -> Pattern d Source #

temporalParam3' :: (a -> b -> c -> Pattern d -> Pattern e) -> Pattern a -> Pattern b -> Pattern c -> Pattern d -> Pattern e Source #

fast :: Pattern Time -> Pattern a -> Pattern a Source #

fast (also known as density) returns the given pattern with speed (or density) increased by the given Time factor. Therefore fast 2 p will return a pattern that is twice as fast, and fast (1/3) p will return one three times as slow.

density :: Pattern Time -> Pattern a -> Pattern a Source #

density is an alias of fast. fast is quicker to type, but density is its old name so is used in a lot of examples.

fastGap :: Time -> Pattern a -> Pattern a Source #

fastGap (also known as densityGap is similar to fast but maintains its cyclic alignment. For example, fastGap 2 p would squash the events in pattern p into the first half of each cycle (and the second halves would be empty).

slow :: Pattern Time -> Pattern a -> Pattern a Source #

slow does the opposite of fast, i.e. slow 2 p will return a pattern that is half the speed.

rotL :: Time -> Pattern a -> Pattern a Source #

The <~ operator shifts (or rotates) a pattern to the left (or counter-clockwise) by the given Time value. For example (1%16) <~ p will return a pattern with all the events moved one 16th of a cycle to the left.

rotR :: Time -> Pattern a -> Pattern a Source #

The ~> operator does the same as <~ but shifts events to the right (or clockwise) rather than to the left.

brak :: Pattern a -> Pattern a Source #

(The above means that brak is a function from patterns of any type, to a pattern of the same type.)

Make a pattern sound a bit like a breakbeat

Example:

d1 $ sound (brak "bd sn kurt")

iter :: Pattern Int -> Pattern c -> Pattern c Source #

Divides a pattern into a given number of subdivisions, plays the subdivisions in order, but increments the starting subdivision each cycle. The pattern wraps to the first subdivision after the last subdivision is played.

Example:

d1 $ iter 4 $ sound "bd hh sn cp"

This will produce the following over four cycles:

bd hh sn cp
hh sn cp bd
sn cp bd hh
cp bd hh sn

There is also iter', which shifts the pattern in the opposite direction.

iter' :: Pattern Int -> Pattern c -> Pattern c Source #

iter' is the same as iter, but decrements the starting subdivision instead of incrementing it.

rev :: Pattern a -> Pattern a Source #

rev p returns p with the event positions in each cycle reversed (or mirrored).

palindrome :: Pattern a -> Pattern a Source #

palindrome p applies rev to p every other cycle, so that the pattern alternates between forwards and backwards.

when :: (Int -> Bool) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

Only when the given test function returns True the given pattern transformation is applied. The test function will be called with the current cycle as a number.

d1 $ when ((elem '4').show)
  (striate 4)
  $ sound "hh hc"

The above will only apply `striate 4` to the pattern if the current cycle number contains the number 4. So the fourth cycle will be striated and the fourteenth and so on. Expect lots of striates after cycle number 399.

whenT :: (Time -> Bool) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

seqP :: [(Time, Time, Pattern a)] -> Pattern a Source #

The function seqP allows you to define when a sound within a list starts and ends. The code below contains three separate patterns in a stack, but each has different start times (zero cycles, eight cycles, and sixteen cycles, respectively). All patterns stop after 128 cycles:

d1 $ seqP [
  (0, 128, sound "bd bd*2"),
  (8, 128, sound "hh*2 [sn cp] cp future*4"),
  (16, 128, sound (samples "arpy*8" (run 16)))
]

every :: Pattern Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

every n f p applies the function f to p, but only affects every n cycles.

_every :: Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

every' :: Pattern Int -> Pattern Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

every n o f' is like every n f with an offset of o cycles

_every' :: Int -> Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

foldEvery :: [Int] -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

foldEvery ns f p applies the function f to p, and is applied for each cycle in ns.

sig :: (Time -> a) -> Pattern a Source #

sig f takes a function from time to values, and turns it into a Pattern.

sinewave :: Fractional a => Pattern a Source #

sinewave returns a Pattern of continuous Fractional values following a sinewave with frequency of one cycle, and amplitude from 0 to 1.

sine :: Fractional a => Pattern a Source #

sine is a synonym for sinewave.

cosine :: Fractional a => Pattern a Source #

sine is a synonym for 0.25 ~> sine.

sineAmp :: Fractional a => a -> Pattern a Source #

sineAmp d returns sinewave with its amplitude offset by d. Deprecated, as these days you can simply do e.g. (sine + 0.5)

sawwave :: (Fractional a, Real a) => Pattern a Source #

sawwave is the equivalent of sinewave for (ascending) sawtooth waves.

saw :: (Fractional a, Real a) => Pattern a Source #

saw is a synonym for sawwave.

triwave :: (Fractional a, Real a) => Pattern a Source #

triwave is the equivalent of sinewave for triangular waves.

tri :: (Fractional a, Real a) => Pattern a Source #

tri is a synonym for triwave.

squarewave :: (Fractional a, Real a) => Pattern a Source #

squarewave1 is the equivalent of sinewave for square waves.

square :: (Fractional a, Real a) => Pattern a Source #

square is a synonym for squarewave.

envL :: Pattern Double Source #

envL is a Pattern of continuous Double values, representing a linear interpolation between 0 and 1 during the first cycle, then staying constant at 1 for all following cycles. Possibly only useful if you're using something like the retrig function defined in tidal.el.

spread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b Source #

(The above is difficult to describe, if you don't understand Haskell, just ignore it and read the below..)

The spread function allows you to take a pattern transformation which takes a parameter, such as slow, and provide several parameters which are switched between. In other words it spreads a function across several values.

Taking a simple high hat loop as an example:

d1 $ sound "ho ho:2 ho:3 hc"

We can slow it down by different amounts, such as by a half:

d1 $ slow 2 $ sound "ho ho:2 ho:3 hc"

Or by four thirds (i.e. speeding it up by a third; `4%3` means four over three):

d1 $ slow (4%3) $ sound "ho ho:2 ho:3 hc"

But if we use spread, we can make a pattern which alternates between the two speeds:

d1 $ spread slow [2,4%3] $ sound "ho ho:2 ho:3 hc"

Note that if you pass ($) as the function to spread values over, you can put functions as the list of values. For example:

d1 $ spread ($) [density 2, rev, slow 2, striate 3, (# speed "0.8")]
    $ sound "[bd*2 [~ bd]] [sn future]*2 cp jvbass*4"

Above, the pattern will have these transforms applied to it, one at a time, per cycle:

  • cycle 1: `density 2` - pattern will increase in speed
  • cycle 2: rev - pattern will be reversed
  • cycle 3: `slow 2` - pattern will decrease in speed
  • cycle 4: `striate 3` - pattern will be granualized
  • cycle 5: `(# speed "0.8")` - pattern samples will be played back more slowly

After `(# speed "0.8")`, the transforms will repeat and start at `density 2` again.

slowspread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b Source #

fastspread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b Source #

fastspread works the same as spread, but the result is squashed into a single cycle. If you gave four values to spread, then the result would seem to speed up by a factor of four. Compare these two:

d1 $ spread chop [4,64,32,16] $ sound "ho ho:2 ho:3 hc"

d1 $ fastspread chop [4,64,32,16] $ sound "ho ho:2 ho:3 hc"

There is also slowspread, which is an alias of spread.

spread' :: Monad m => (a -> b -> m c) -> m a -> b -> m c Source #

There's a version of this function, spread' (pronounced "spread prime"), which takes a *pattern* of parameters, instead of a list:

d1 $ spread' slow "2 4%3" $ sound "ho ho:2 ho:3 hc"

This is quite a messy area of Tidal - due to a slight difference of implementation this sounds completely different! One advantage of using spread' though is that you can provide polyphonic parameters, e.g.:

d1 $ spread' slow "[2 4%3, 3]" $ sound "ho ho:2 ho:3 hc"

spreadChoose :: (t -> t1 -> Pattern b) -> [t] -> t1 -> Pattern b Source #

`spreadChoose f xs p` is similar to slowspread but picks values from xs at random, rather than cycling through them in order. It has a shorter alias spreadr.

spreadr :: (t -> t1 -> Pattern b) -> [t] -> t1 -> Pattern b Source #

filterValues :: (a -> Bool) -> Pattern a -> Pattern a Source #

segment' :: [Event a] -> [Event a] Source #

split :: Time -> [Event a] -> [Event a] Source #

points :: [Event a] -> [Time] Source #

groupByTime :: [Event a] -> [Event [a]] Source #

ifp :: (Int -> Bool) -> (Pattern a -> Pattern a) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

Decide whether to apply one or another function depending on the result of a test function that is passed the current cycle as a number.

d1 $ ifp ((== 0).(flip mod 2))
  (striate 4)
  (# coarse "24 48") $
  sound "hh hc"

This will apply `striate 4` for every _even_ cycle and aply `# coarse "24 48"` for every _odd_.

Detail: As you can see the test function is arbitrary and does not rely on anything tidal specific. In fact it uses only plain haskell functionality, that is: it calculates the modulo of 2 of the current cycle which is either 0 (for even cycles) or 1. It then compares this value against 0 and returns the result, which is either True or False. This is what the ifp signature's first part signifies `(Int -> Bool)`, a function that takes a whole number and returns either True or False.

rand :: Pattern Double Source #

rand generates a continuous pattern of (pseudo-)random, floating point numbers between `0` and `1`.

d1 $ sound "bd*8" # pan rand

pans bass drums randomly

d1 $ sound "sn sn ~ sn" # gain rand

makes the snares' randomly loud and quiet.

Numbers coming from this pattern are random, but dependent on time. So if you reset time via `cps (-1)` the random pattern will emit the exact same _random_ numbers again.

In cases where you need two different random patterns, you can shift one of them around to change the time from which the _random_ pattern is read, note the difference:

d1 $ jux (|+| gain rand) $ sound "sn sn ~ sn" # gain rand

and with the juxed version shifted backwards for 1024 cycles:

d1 $ jux (|+| ((1024 <~) $ gain rand)) $ sound "sn sn ~ sn" # gain rand

irand :: Num a => Int -> Pattern a Source #

Just like rand but for whole numbers, `irand n` generates a pattern of (pseudo-) random whole numbers between `0` to `n-1` inclusive. Notably used to pick a random samples from a folder:

d1 $ n (irand 5) # sound "drum"

choose :: [a] -> Pattern a Source #

Randomly picks an element from the given list

d1 $ sound (samples "xx(3,8)" (tom $ choose ["a", "e", "g", "c"]))

plays a melody randomly choosing one of the four notes "a", "e", "g", "c".

degradeBy :: Pattern Double -> Pattern a -> Pattern a Source #

Similar to degrade degradeBy allows you to control the percentage of events that are removed. For example, to remove events 90% of the time:

d1 $ slow 2 $ degradeBy 0.9 $ sound "[[[feel:5*8,feel*3] feel:3*8], feel*4]"
   # accelerate "-6"
   # speed "2"

sometimesBy :: Double -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

Use sometimesBy to apply a given function "sometimes". For example, the following code results in `density 2` being applied about 25% of the time:

d1 $ sometimesBy 0.25 (density 2) $ sound "bd*8"

There are some aliases as well:

sometimes = sometimesBy 0.5
often = sometimesBy 0.75
rarely = sometimesBy 0.25
almostNever = sometimesBy 0.1
almostAlways = sometimesBy 0.9

sometimes :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

sometimes is an alias for sometimesBy 0.5.

often :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

often is an alias for sometimesBy 0.75.

rarely :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

rarely is an alias for sometimesBy 0.25.

almostNever :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

almostNever is an alias for sometimesBy 0.1

almostAlways :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

almostAlways is an alias for sometimesBy 0.9

never :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

always :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

someCyclesBy :: Double -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

someCyclesBy is a cycle-by-cycle version of sometimesBy. It has a `someCycles = someCyclesBy 0.5` alias

degrade :: Pattern a -> Pattern a Source #

degrade randomly removes events from a pattern 50% of the time:

d1 $ slow 2 $ degrade $ sound "[[[feel:5*8,feel*3] feel:3*8], feel*4]"
   # accelerate "-6"
   # speed "2"

The shorthand syntax for degrade is a question mark: ?. Using ? will allow you to randomly remove events from a portion of a pattern:

d1 $ slow 2 $ sound "bd ~ sn bd ~ bd? [sn bd?] ~"

You can also use ? to randomly remove events from entire sub-patterns:

d1 $ slow 2 $ sound "[[[feel:5*8,feel*3] feel:3*8]?, feel*4]"

wedge :: Time -> Pattern a -> Pattern a -> Pattern a Source #

wedge t p p' combines patterns p and p' by squashing the p into the portion of each cycle given by t, and p' into the remainer of each cycle.

whenmod :: Int -> Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

whenmod has a similar form and behavior to every, but requires an additional number. Applies the function to the pattern, when the remainder of the current loop number divided by the first parameter, is greater or equal than the second parameter.

For example the following makes every other block of four loops twice as dense:

d1 $ whenmod 8 4 (density 2) (sound "bd sn kurt")

superimpose :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

superimpose f p = stack [p, f p]

superimpose plays a modified version of a pattern at the same time as the original pattern, resulting in two patterns being played at the same time.

d1 $ superimpose (density 2) $ sound "bd sn [cp ht] hh"
d1 $ superimpose ((# speed "2") . (0.125 <~)) $ sound "bd sn cp hh"

splitQueries :: Pattern a -> Pattern a Source #

splitQueries p wraps p to ensure that it does not get queries that span arcs. For example `arc p (0.5, 1.5)` would be turned into two queries, `(0.5,1)` and `(1,1.5)`, and the results combined. Being able to assume queries don't span cycles often makes transformations easier to specify.

trunc :: Pattern Time -> Pattern a -> Pattern a Source #

trunc truncates a pattern so that only a fraction of the pattern is played. The following example plays only the first quarter of the pattern:

d1 $ trunc 0.25 $ sound "bd sn*2 cp hh*4 arpy bd*2 cp bd*2"

linger :: Pattern Time -> Pattern a -> Pattern a Source #

linger is similar to trunc but the truncated part of the pattern loops until the end of the cycle

d1 $ linger 0.25 $ sound "bd sn*2 cp hh*4 arpy bd*2 cp bd*2"

zoom :: Arc -> Pattern a -> Pattern a Source #

Plays a portion of a pattern, specified by a beginning and end arc of time. The new resulting pattern is played over the time period of the original pattern:

d1 $ zoom (0.25, 0.75) $ sound "bd*2 hh*3 [sn bd]*2 drum"

In the pattern above, zoom is used with an arc from 25% to 75%. It is equivalent to this pattern:

d1 $ sound "hh*3 [sn bd]*2"

within :: Arc -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

Use within to apply a function to only a part of a pattern. For example, to apply `density 2` to only the first half of a pattern:

d1 $ within (0, 0.5) (density 2) $ sound "bd*2 sn lt mt hh hh hh hh"

Or, to apply `(# speed "0.5") to only the last quarter of a pattern:

d1 $ within (0.75, 1) (# speed "0.5") $ sound "bd*2 sn lt mt hh hh hh hh"

within' :: Arc -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

For many cases, within' will function exactly as within. The difference between the two occurs when applying functions that change the timing of notes such as fast or <~. within first applies the function to all notes in the cycle, then keeps the results in the specified interval, and then combines it with the old cycle (an "apply split combine" paradigm). within' first keeps notes in the specified interval, then applies the function to these notes, and then combines it with the old cycle (a "split apply combine" paradigm).

For example, whereas using the standard version of within

d1 $ within (0, 0.25) (fast 2) $ sound "bd hh cp sd"

sounds like:

d1 $ sound "[bd hh] hh cp sd"

using this alternative version, within'

d1 $ within' (0, 0.25) (fast 2) $ sound "bd hh cp sd"

sounds like:

d1 $ sound "[bd bd] hh cp sd"

e :: Pattern Int -> Pattern Int -> Pattern a -> Pattern a Source #

You can use the e function to apply a Euclidean algorithm over a complex pattern, although the structure of that pattern will be lost:

d1 $ e 3 8 $ sound "bd*2 [sn cp]"

In the above, three sounds are picked from the pattern on the right according to the structure given by the `e 3 8`. It ends up picking two bd sounds, a cp and missing the sn entirely.

These types of sequences use "Bjorklund's algorithm", which wasn't made for music but for an application in nuclear physics, which is exciting. More exciting still is that it is very similar in structure to the one of the first known algorithms written in Euclid's book of elements in 300 BC. You can read more about this in the paper [The Euclidean Algorithm Generates Traditional Musical Rhythms](http:/cgm.cs.mcgill.ca~godfriedpublicationsbanff.pdf) by Toussaint. Some examples from this paper are included below, including rotation in some cases.

- (2,5) : A thirteenth century Persian rhythm called Khafif-e-ramal.
- (3,4) : The archetypal pattern of the Cumbia from Colombia, as well as a Calypso rhythm from Trinidad.
- (3,5,2) : Another thirteenth century Persian rhythm by the name of Khafif-e-ramal, as well as a Rumanian folk-dance rhythm.
- (3,7) : A Ruchenitza rhythm used in a Bulgarian folk-dance.
- (3,8) : The Cuban tresillo pattern.
- (4,7) : Another Ruchenitza Bulgarian folk-dance rhythm.
- (4,9) : The Aksak rhythm of Turkey.
- (4,11) : The metric pattern used by Frank Zappa in his piece titled Outside Now.
- (5,6) : Yields the York-Samai pattern, a popular Arab rhythm.
- (5,7) : The Nawakhat pattern, another popular Arab rhythm.
- (5,8) : The Cuban cinquillo pattern.
- (5,9) : A popular Arab rhythm called Agsag-Samai.
- (5,11) : The metric pattern used by Moussorgsky in Pictures at an Exhibition.
- (5,12) : The Venda clapping pattern of a South African children’s song.
- (5,16) : The Bossa-Nova rhythm necklace of Brazil.
- (7,8) : A typical rhythm played on the Bendir (frame drum).
- (7,12) : A common West African bell pattern.
- (7,16,14) : A Samba rhythm necklace from Brazil.
- (9,16) : A rhythm necklace used in the Central African Republic.
- (11,24,14) : A rhythm necklace of the Aka Pygmies of Central Africa.
- (13,24,5) : Another rhythm necklace of the Aka Pygmies of the upper Sangha.

_e :: Int -> Int -> Pattern a -> Pattern a Source #

_e' :: Int -> Int -> Pattern a -> Pattern a Source #

einv :: Pattern Int -> Pattern Int -> Pattern a -> Pattern a Source #

einv fills in the blanks left by e - e 3 8 "x" -> "x ~ ~ x ~ ~ x ~"

einv 3 8 "x" -> "~ x x ~ x x ~ x"

_einv :: Int -> Int -> Pattern a -> Pattern a Source #

efull :: Pattern Int -> Pattern Int -> Pattern a -> Pattern a -> Pattern a Source #

`efull n k pa pb` stacks e n k pa with einv n k pb

index :: Real b => b -> Pattern b -> Pattern c -> Pattern c Source #

prrw :: (a -> b -> c) -> Int -> (Time, Time) -> Pattern a -> Pattern b -> Pattern c Source #

prrw f rot (blen, vlen) beatPattern valuePattern: pattern rotate/replace.

prr :: Int -> (Time, Time) -> Pattern String -> Pattern b -> Pattern b Source #

prr rot (blen, vlen) beatPattern valuePattern: pattern rotate/replace.

preplace :: (Time, Time) -> Pattern String -> Pattern b -> Pattern b Source #

preplace (blen, plen) beats values combines the timing of beats with the values of values. Other ways of saying this are: * sequential convolution * values quantized to beats.

Examples:

d1 $ sound $ preplace (1,1) "x [~ x] x x" "bd sn"
d1 $ sound $ preplace (1,1) "x(3,8)" "bd sn"
d1 $ sound $ "x(3,8)" ~ "bd sn"
d1 $ sound "[jvbass jvbass:5]*3" |+| (shape $ "1 1 1 1 1" ~ "0.2 0.9")

It is assumed the pattern fits into a single cycle. This works well with pattern literals, but not always with patterns defined elsewhere. In those cases use preplace and provide desired pattern lengths: @ let p = slow 2 $ "x x x"

d1 $ sound $ preplace (2,1) p "bd sn" @

prep :: (Time, Time) -> Pattern String -> Pattern b -> Pattern b Source #

prep is an alias for preplace.

preplaceWith :: (a -> b -> c) -> (Time, Time) -> Pattern a -> Pattern b -> Pattern c Source #

prw :: (a -> b -> c) -> (Time, Time) -> Pattern a -> Pattern b -> Pattern c Source #

preplaceWith1 :: (a -> b -> c) -> Pattern a -> Pattern b -> Pattern c Source #

prw1 :: (a -> b -> c) -> Pattern a -> Pattern b -> Pattern c Source #

protate :: Time -> Int -> Pattern a -> Pattern a Source #

protate len rot p rotates pattern p by rot beats to the left. len: length of the pattern, in cycles. Example: d1 $ every 4 (protate 2 (-1)) $ slow 2 $ sound "bd hh hh hh"

prot :: Time -> Int -> Pattern a -> Pattern a Source #

(<<~) :: Int -> Pattern a -> Pattern a Source #

The <<~ operator rotates a unit pattern to the left, similar to <~, but by events rather than linear time. The timing of the pattern remains constant:

d1 $ (1 <<~) $ sound "bd ~ sn hh"
-- will become
d1 $ sound "sn ~ hh bd"

(~>>) :: Int -> Pattern a -> Pattern a Source #

~>> is like <<~ but for shifting to the right.

pequal :: Ord a => Time -> Pattern a -> Pattern a -> Bool Source #

pequal cycles p1 p2: quickly test if p1 and p2 are the same.

discretise :: Time -> Pattern a -> Pattern a Source #

discretise n p: samples the pattern p at a rate of n events per cycle. Useful for turning a continuous pattern into a discrete one.

randcat :: [Pattern a] -> Pattern a Source #

randcat ps: does a slowcat on the list of patterns ps but randomises the order in which they are played.

fit :: Int -> [a] -> Pattern Int -> Pattern a Source #

The fit function takes a pattern of integer numbers, which are used to select values from the given list. What makes this a bit strange is that only a given number of values are selected each cycle. For example:

d1 $ sound (fit 3 ["bd", "sn", "arpy", "arpy:1", "casio"] "0 [~ 1] 2 1")

The above fits three samples into the pattern, i.e. for the first cycle this will be `"bd"`, `"sn"` and `"arpy"`, giving the result `"bd [~ sn] arpy sn"` (note that we start counting at zero, so that `0` picks the first value). The following cycle the *next* three values in the list will be picked, i.e. `"arpy:1"`, `"casio"` and `"bd"`, giving the pattern `"arpy:1 [~ casio] bd casio"` (note that the list wraps round here).

permstep :: RealFrac b => Int -> [a] -> Pattern b -> Pattern a Source #

struct :: Pattern String -> Pattern a -> Pattern a Source #

struct a b: structures pattern b in terms of a.

substruct :: Pattern String -> Pattern b -> Pattern b Source #

substruct a b: similar to struct, but each event in pattern a gets replaced with pattern b, compressed to fit the timespan of the event.

stripe :: Pattern Int -> Pattern a -> Pattern a Source #

stripe n p: repeats pattern p, n times per cycle. So similar to fast, but with random durations. The repetitions will be continguous (touching, but not overlapping) and the durations will add up to a single cycle. n can be supplied as a pattern of integers.

slowstripe :: Pattern Int -> Pattern a -> Pattern a Source #

slowstripe n p: The same as stripe, but the result is also n times slower, so that the mean average duration of the stripes is exactly one cycle, and every nth stripe starts on a cycle boundary (in indian classical terms, the sam).

lindenmayer :: Int -> String -> String -> String Source #

returns the nth iteration of a Lindenmayer System with given start sequence.

for example:

lindenmayer 1 "a:b,b:ab" "ab" -> "bab"

lindenmayerI :: Num b => Int -> String -> String -> [b] Source #

lindenmayerI converts the resulting string into a a list of integers with fromIntegral applied (so they can be used seamlessly where floats or rationals are required)

mask :: Pattern a -> Pattern b -> Pattern b Source #

Removes events from second pattern that don't start during an event from first.

Consider this, kind of messy rhythm without any rests.

d1 $ sound (slowcat ["sn*8", "[cp*4 bd*4, hc*5]"]) # n (run 8)

If we apply a mask to it

d1 $ s (mask ("1 1 1 ~ 1 1 ~ 1" :: Pattern Bool)
  (slowcat ["sn*8", "[cp*4 bd*4, bass*5]"] ))
  # n (run 8)

Due to the use of slowcat here, the same mask is first applied to `"sn*8"` and in the next cycle to `"[cp*4 bd*4, hc*5]".

You could achieve the same effect by adding rests within the slowcat patterns, but mask allows you to do this more easily. It kind of keeps the rhythmic structure and you can change the used samples independently, e.g.

d1 $ s (mask ("1 ~ 1 ~ 1 1 ~ 1" :: Pattern Bool)
  (slowcat ["can*8", "[cp*4 sn*4, jvbass*16]"] ))
  # n (run 8)

Detail: It is currently needed to explicitly _tell_ Tidal that the mask itself is a `Pattern Bool` as it cannot infer this by itself, otherwise it will complain as it does not know how to interpret your input.

fit' :: Pattern Time -> Int -> Pattern Int -> Pattern Int -> Pattern a -> Pattern a Source #

fit' is a generalization of fit, where the list is instead constructed by using another integer pattern to slice up a given pattern. The first argument is the number of cycles of that latter pattern to use when slicing. It's easier to understand this with a few examples:

d1 $ sound (fit' 1 2 "0 1" "1 0" "bd sn")

So what does this do? The first `1` just tells it to slice up a single cycle of `"bd sn"`. The `2` tells it to select two values each cycle, just like the first argument to fit. The next pattern `"0 1"` is the "from" pattern which tells it how to slice, which in this case means `"0"` maps to `"bd"`, and `"1"` maps to `"sn"`. The next pattern `"1 0"` is the "to" pattern, which tells it how to rearrange those slices. So the final result is the pattern `"sn bd"`.

A more useful example might be something like

d1 $ fit' 1 4 (run 4) "[0 3*2 2 1 0 3*2 2 [1*8 ~]]/2" $ chop 4 $ (sound "breaks152" # unit "c")

which uses chop to break a single sample into individual pieces, which fit' then puts into a list (using the `run 4` pattern) and reassembles according to the complicated integer pattern.

chunk :: Integer -> (Pattern b -> Pattern b) -> Pattern b -> Pattern b Source #

chunk n f p treats the given pattern p as having n chunks, and applies the function f to one of those sections per cycle, running from left to right.

d1 $ chunk 4 (density 4) $ sound "cp sn arpy [mt lt]"

chunk' :: Integral a => a -> (Pattern b -> Pattern b) -> Pattern b -> Pattern b Source #

chunk' works much the same as chunk, but runs from right to left.

runWith' :: Integral a => a -> (Pattern b -> Pattern b) -> Pattern b -> Pattern b Source #

inside :: Pattern Time -> (Pattern a1 -> Pattern a) -> Pattern a1 -> Pattern a Source #

toScale' :: Num a => Int -> [a] -> Pattern Int -> Pattern a Source #

toScale lets you turn a pattern of notes within a scale (expressed as a list) to note numbers. For example `toScale [0, 4, 7] "0 1 2 3"` will turn into the pattern `"0 4 7 12"`. It assumes your scale fits within an octave; to change this use toScale size`. Example: toScale 24 [0,4,7,10,14,17] (run 8)` turns into `"0 4 7 10 14 17 24 28"`

toScale :: Num a => [a] -> Pattern Int -> Pattern a Source #

swingBy :: Pattern Time -> Pattern Time -> Pattern a -> Pattern a Source #

`swingBy x n` divides a cycle into n slices and delays the notes in the second half of each slice by x fraction of a slice . swing is an alias for `swingBy (1%3)`

cycleChoose :: [a] -> Pattern a Source #

cycleChoose is like choose but only picks a new item from the list once each cycle

shuffle :: Int -> Pattern a -> Pattern a Source #

`shuffle n p` evenly divides one cycle of the pattern p into n parts, and returns a random permutation of the parts each cycle. For example, `shuffle 3 "a b c"` could return `"a b c"`, `"a c b"`, `"b a c"`, `"b c a"`, `"c a b"`, or `"c b a"`. But it will **never** return `"a a a"`, because that is not a permutation of the parts.

scramble :: Int -> Pattern a -> Pattern a Source #

`scramble n p` is like shuffle but randomly selects from the parts of p instead of making permutations. For example, `scramble 3 "a b c"` will randomly select 3 parts from `"a"` `"b"` and `"c"`, possibly repeating a single part.

ur :: Time -> Pattern String -> [(String, Pattern a)] -> [(String, Pattern a -> Pattern a)] -> Pattern a Source #

spaceOut :: [Time] -> Pattern a -> Pattern a Source #

spaceOut xs p repeats a pattern p at different durations given by the list of time values in xs

flatpat :: Pattern [a] -> Pattern a Source #

flatpat takes a Pattern of lists and pulls the list elements as separate Events

layer :: [a -> Pattern b] -> a -> Pattern b Source #

layer takes a Pattern of lists and pulls the list elements as separate Events

breakUp :: Pattern a -> Pattern a Source #

breakUp finds events that share the same timespan, and spreads them out during that timespan, so for example breakUp "[bd,sn]" gets turned into "bd sn"

fill :: Pattern a -> Pattern a -> Pattern a Source #

fill 'fills in' gaps in one pattern with events from another. For example fill "bd" "cp ~ cp" would result in the equivalent of `"~ bd ~"`. This only finds gaps in a resulting pattern, in other words "[bd ~, sn]" doesn't contain any gaps (because sn covers it all), and "bd ~ ~ sn" only contains a single gap that bridges two steps.

data Sign Source #

Constructors

Positive 
Negative 

class Enumerable a where Source #

Minimal complete definition

fromTo, fromThenTo

Methods

fromTo :: a -> a -> Pattern a Source #

fromThenTo :: a -> a -> a -> Pattern a Source #

class Parseable a where Source #

Minimal complete definition

parseTPat

Methods

parseTPat :: String -> TPat a Source #

Instances
Parseable Bool Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable Double Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable Int Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable Integer Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable Rational Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable String Source # 
Instance details

Defined in Sound.Tidal.Parse

Parseable ColourD Source # 
Instance details

Defined in Sound.Tidal.Parse

data TPat a Source #

AST representation of patterns

Instances
Show a => Show (TPat a) Source # 
Instance details

Defined in Sound.Tidal.Parse

Methods

showsPrec :: Int -> TPat a -> ShowS #

show :: TPat a -> String #

showList :: [TPat a] -> ShowS #

durations :: [TPat a] -> [(Int, TPat a)] Source #

enumFromTo' :: (Ord a, Enum a) => a -> a -> Pattern a Source #

enumFromThenTo' :: (Ord a, Enum a, Num a) => a -> a -> a -> Pattern a Source #

applySign :: Num a => Sign -> a -> a Source #

r :: (Enumerable a, Parseable a) => String -> Pattern a -> IO (Pattern a) Source #

elongate :: [TPat a] -> TPat a Source #

splitFeet :: [TPat t] -> [[TPat t]] Source #

pE :: Parseable a => TPat a -> Parser (TPat a) Source #

_eoff :: Int -> Int -> Integer -> Pattern a -> Pattern a Source #

class ParamType a where Source #

Minimal complete definition

fromV, toV

Methods

fromV :: Value -> Maybe a Source #

toV :: a -> Value Source #

Instances
ParamType Double Source # 
Instance details

Defined in Sound.Tidal.Stream

ParamType Int Source # 
Instance details

Defined in Sound.Tidal.Stream

ParamType String Source # 
Instance details

Defined in Sound.Tidal.Stream

data Value Source #

Constructors

VS 

Fields

VF 

Fields

VI 

Fields

Instances
Eq Value Source # 
Instance details

Defined in Sound.Tidal.Stream

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Ord Value Source # 
Instance details

Defined in Sound.Tidal.Stream

Methods

compare :: Value -> Value -> Ordering #

(<) :: Value -> Value -> Bool #

(<=) :: Value -> Value -> Bool #

(>) :: Value -> Value -> Bool #

(>=) :: Value -> Value -> Bool #

max :: Value -> Value -> Value #

min :: Value -> Value -> Value #

Show Value Source # 
Instance details

Defined in Sound.Tidal.Stream

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

data Shape Source #

Constructors

Shape 

Fields

data Param Source #

Constructors

S 
F 
I 

Fields

Instances
Eq Param Source # 
Instance details

Defined in Sound.Tidal.Stream

Methods

(==) :: Param -> Param -> Bool #

(/=) :: Param -> Param -> Bool #

Ord Param Source # 
Instance details

Defined in Sound.Tidal.Stream

Methods

compare :: Param -> Param -> Ordering #

(<) :: Param -> Param -> Bool #

(<=) :: Param -> Param -> Bool #

(>) :: Param -> Param -> Bool #

(>=) :: Param -> Param -> Bool #

max :: Param -> Param -> Param #

min :: Param -> Param -> Param #

Show Param Source # 
Instance details

Defined in Sound.Tidal.Stream

Methods

showsPrec :: Int -> Param -> ShowS #

show :: Param -> String #

showList :: [Param] -> ShowS #

data Backend a Source #

Constructors

Backend 

Fields

isSubset :: Eq a => [a] -> [a] -> Bool Source #

doAt :: RealFrac a => a -> IO () -> IO () Source #

make :: (a -> Value) -> Shape -> String -> Pattern a -> ParamPattern Source #

mergeWith :: (Ord k, Applicative f) => (k -> a -> a -> a) -> f (Map k a) -> f (Map k a) -> f (Map k a) Source #

mergeNumWith :: Applicative f => (Int -> Int -> Int) -> (Double -> Double -> Double) -> f (Map Param Value) -> f (Map Param Value) -> f (Map Param Value) Source #

(###) :: Foldable t => ParamPattern -> t ParamPattern -> ParamPattern Source #

These are shorthand for merging lists of patterns with #, |*|, |+|, or |/|. Sometimes this saves a little typing and can improve readability when passing things into other functions. As an example, instead of writing d1 $ sometimes ((|*| speed "2") . (|*| cutoff "2") . (|*| shape "1.5")) $ sound "arpy*4" shape "0.3" you can write d1 $ sometimes (*** [speed "2", cutoff "2", shape "1.5"]) $ sound "arpy*4" ### [cutoff "350", shape "0.3"]

setter :: MVar (a, [a]) -> a -> IO () Source #

copyParam :: Param -> Param -> ParamPattern -> ParamPattern Source #

Copies values from one parameter to another. Used by nToOrbit in Sound.Tidal.Dirt.

chord :: Num a => Pattern String -> Pattern a Source #

chord p turns a pattern of chord names into a pattern of numbers, representing note value offsets for the chords

grp :: [Param] -> Pattern String -> ParamPattern Source #

group multiple params into one

sound :: Pattern String -> ParamPattern Source #

A pattern of strings representing sounds or synth notes.

Internally, sound or its shorter alias s is a combination of the samplebank name and number when used with samples, or synth name and note number when used with a synthesiser. For example `bd:2` specifies the third sample (not the second as you might expect, because we start counting at zero) in the bd sample folder.

  • Internally, sound/s is a combination of two parameters, the hidden parameter s' which specifies the samplebank or synth, and the n parameter which specifies the sample or note number. For example:
d1 $ sound "bd:2 sn:0"

is essentially the same as:

d1 $ s' "bd sn" # n "2 0"

n is therefore useful when you want to pattern the sample or note number separately from the samplebank or synth. For example:

d1 $ n "0 5 ~ 2" # sound "drum"

is equivalent to:

d1 $ sound "drum:0 drum:5 ~ drum:2"

accelerate :: Pattern Double -> ParamPattern Source #

a pattern of numbers that speed up (or slow down) samples while they play.

attack :: Pattern Double -> ParamPattern Source #

a pattern of numbers to specify the attack time (in seconds) of an envelope applied to each sample. Only takes effect if release is also specified.

bandf :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the center frequency of the band-pass filter.

bandq :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the q-factor of the band-pass filter.y

begin_p :: Param Source #

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.

Using `begin "-1"` combined with `cut "-1"` means that when the sample cuts itself it will begin playback from where the previous one left off, so it will sound like one seamless sample. This allows you to apply a synth param across a long sample in a way similar to chop:

cps 0.5

d1 $ sound "breaks125*8"  begin "-1"  coarse "1 2 4 8 16 32 64 128"

This will play the breaks125 sample and apply the changing coarse parameter over the sample. Compare to:

d1 $ (chop 8 $ sounds "breaks125")  coarse "1 2 4 8 16 32 64 128"

which performs a similar effect, but due to differences in implementation sounds different.

channel :: Pattern Int -> ParamPattern Source #

choose the physical channel the pattern is sent to, this is super dirt specific

channel_p :: Param Source #

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.

Using `begin "-1"` combined with `cut "-1"` means that when the sample cuts itself it will begin playback from where the previous one left off, so it will sound like one seamless sample. This allows you to apply a synth param across a long sample in a way similar to chop:

cps 0.5

d1 $ sound "breaks125*8"  begin "-1"  coarse "1 2 4 8 16 32 64 128"

This will play the breaks125 sample and apply the changing coarse parameter over the sample. Compare to:

d1 $ (chop 8 $ sounds "breaks125")  coarse "1 2 4 8 16 32 64 128"

which performs a similar effect, but due to differences in implementation sounds different.

legato_p :: Param Source #

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.

Using `begin "-1"` combined with `cut "-1"` means that when the sample cuts itself it will begin playback from where the previous one left off, so it will sound like one seamless sample. This allows you to apply a synth param across a long sample in a way similar to chop:

cps 0.5

d1 $ sound "breaks125*8"  begin "-1"  coarse "1 2 4 8 16 32 64 128"

This will play the breaks125 sample and apply the changing coarse parameter over the sample. Compare to:

d1 $ (chop 8 $ sounds "breaks125")  coarse "1 2 4 8 16 32 64 128"

which performs a similar effect, but due to differences in implementation sounds different.

clhatdecay_p :: Param Source #

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.

Using `begin "-1"` combined with `cut "-1"` means that when the sample cuts itself it will begin playback from where the previous one left off, so it will sound like one seamless sample. This allows you to apply a synth param across a long sample in a way similar to chop:

cps 0.5

d1 $ sound "breaks125*8"  begin "-1"  coarse "1 2 4 8 16 32 64 128"

This will play the breaks125 sample and apply the changing coarse parameter over the sample. Compare to:

d1 $ (chop 8 $ sounds "breaks125")  coarse "1 2 4 8 16 32 64 128"

which performs a similar effect, but due to differences in implementation sounds different.

coarse :: Pattern Int -> ParamPattern Source #

fake-resampling, a pattern of numbers for lowering the sample rate, i.e. 1 for original 2 for half, 3 for a third and so on.

coarse_p :: Param Source #

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.

Using `begin "-1"` combined with `cut "-1"` means that when the sample cuts itself it will begin playback from where the previous one left off, so it will sound like one seamless sample. This allows you to apply a synth param across a long sample in a way similar to chop:

cps 0.5

d1 $ sound "breaks125*8"  begin "-1"  coarse "1 2 4 8 16 32 64 128"

This will play the breaks125 sample and apply the changing coarse parameter over the sample. Compare to:

d1 $ (chop 8 $ sounds "breaks125")  coarse "1 2 4 8 16 32 64 128"

which performs a similar effect, but due to differences in implementation sounds different.

crush :: Pattern Double -> ParamPattern Source #

bit crushing, a pattern of numbers from 1 (for drastic reduction in bit-depth) to 16 (for barely no reduction).

crush_p :: Param Source #

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.

Using `begin "-1"` combined with `cut "-1"` means that when the sample cuts itself it will begin playback from where the previous one left off, so it will sound like one seamless sample. This allows you to apply a synth param across a long sample in a way similar to chop:

cps 0.5

d1 $ sound "breaks125*8"  begin "-1"  coarse "1 2 4 8 16 32 64 128"

This will play the breaks125 sample and apply the changing coarse parameter over the sample. Compare to:

d1 $ (chop 8 $ sounds "breaks125")  coarse "1 2 4 8 16 32 64 128"

which performs a similar effect, but due to differences in implementation sounds different.

cut :: Pattern Int -> ParamPattern Source #

In the style of classic drum-machines, cut will stop a playing sample as soon as another samples with in same cutgroup is to be played.

An example would be an open hi-hat followed by a closed one, essentially muting the open.

d1 $ stack [
  sound "bd",
  sound "~ [~ [ho:2 hc/2]]" # cut "1"
  ]

This will mute the open hi-hat every second cycle when the closed one is played.

Using cut with negative values will only cut the same sample. This is useful to cut very long samples

d1 $ sound "bev, [ho:3]" # cut "-1"

Using `cut "0"` is effectively _no_ cutgroup.

cutoff :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Applies the cutoff frequency of the low-pass filter.

delay :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the level of the delay signal.

delayfeedback :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the amount of delay feedback.

delaytime :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the length of the delay.

dry :: Pattern Double -> ParamPattern Source #

when set to `1` will disable all reverb for this pattern. See room and size for more information about reverb.

gain :: Pattern Double -> ParamPattern Source #

a pattern of numbers that specify volume. Values less than 1 make the sound quieter. Values greater than 1 make the sound louder.

hcutoff :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Applies the cutoff frequency of the high-pass filter.

hold :: Pattern Double -> ParamPattern Source #

a pattern of numbers to specify the hold time (in seconds) of an envelope applied to each sample. Only takes effect if attack and release are also specified.

hresonance :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Applies the resonance of the high-pass filter.

lock :: Pattern Double -> ParamPattern Source #

A pattern of numbers. Specifies whether delaytime is calculated relative to cps. When set to 1, delaytime is a direct multiple of a cycle.

loop :: Pattern Double -> ParamPattern Source #

loops the sample (from begin to end) the specified number of times.

n :: Pattern Double -> ParamPattern Source #

specifies the sample or note number to be used

degree :: Pattern Double -> ParamPattern Source #

Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling:

d1 $ stack [
  sound "bd bd/4",
  sound "hh(5,8)"
  ] # nudge "[0 0.04]*4"
  • -pitch model

mtranspose :: Pattern Double -> ParamPattern Source #

Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling:

d1 $ stack [
  sound "bd bd/4",
  sound "hh(5,8)"
  ] # nudge "[0 0.04]*4"
  • -pitch model

ctranspose :: Pattern Double -> ParamPattern Source #

Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling:

d1 $ stack [
  sound "bd bd/4",
  sound "hh(5,8)"
  ] # nudge "[0 0.04]*4"
  • -pitch model

harmonic :: Pattern Double -> ParamPattern Source #

Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling:

d1 $ stack [
  sound "bd bd/4",
  sound "hh(5,8)"
  ] # nudge "[0 0.04]*4"
  • -pitch model

stepsPerOctave :: Pattern Double -> ParamPattern Source #

Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling:

d1 $ stack [
  sound "bd bd/4",
  sound "hh(5,8)"
  ] # nudge "[0 0.04]*4"
  • -pitch model

octaveRatio :: Pattern Double -> ParamPattern Source #

Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling:

d1 $ stack [
  sound "bd bd/4",
  sound "hh(5,8)"
  ] # nudge "[0 0.04]*4"
  • -pitch model

orbit :: Pattern Int -> ParamPattern Source #

a pattern of numbers. An orbit is a global parameter context for patterns. Patterns with the same orbit will share hardware output bus offset and global effects, e.g. reverb and delay. The maximum number of orbits is specified in the superdirt startup, numbers higher than maximum will wrap around.

pan :: Pattern Double -> ParamPattern Source #

a pattern of numbers between 0 and 1, from left to right (assuming stereo), once round a circle (assuming multichannel)

panspan :: Pattern Double -> ParamPattern Source #

a pattern of numbers between -inf and inf, which controls how much multichannel output is fanned out (negative is backwards ordering)

pansplay :: Pattern Double -> ParamPattern Source #

a pattern of numbers between 0.0 and 1.0, which controls the multichannel spread range (multichannel only)

panwidth :: Pattern Double -> ParamPattern Source #

a pattern of numbers between 0.0 and inf, which controls how much each channel is distributed over neighbours (multichannel only)

panorient :: Pattern Double -> ParamPattern Source #

a pattern of numbers between -1.0 and 1.0, which controls the relative position of the centre pan in a pair of adjacent speakers (multichannel only)

release :: Pattern Double -> ParamPattern Source #

a pattern of numbers to specify the release time (in seconds) of an envelope applied to each sample. Only takes effect if attack is also specified.

resonance :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Specifies the resonance of the low-pass filter.

room :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the level of reverb.

shape :: Pattern Double -> ParamPattern Source #

wave shaping distortion, a pattern of numbers from 0 for no distortion up to 1 for loads of distortion.

size :: Pattern Double -> ParamPattern Source #

a pattern of numbers from 0 to 1. Sets the perceptual size (reverb time) of the room to be used in reverb.

speed :: Pattern Double -> ParamPattern Source #

a pattern of numbers which changes the speed of sample playback, i.e. a cheap way of changing pitch. Negative values will play the sample backwards!

s' :: Pattern String -> ParamPattern Source #

a pattern of strings. Selects the sample to be played.

unit :: Pattern String -> ParamPattern Source #

used in conjunction with speed, accepts values of "r" (rate, default behavior), "c" (cycles), or "s" (seconds). Using `unit "c"` means speed will be interpreted in units of cycles, e.g. `speed "1"` means samples will be stretched to fill a cycle. Using `unit "s"` means the playback speed will be adjusted so that the duration is the number of seconds specified by speed.

vowel :: Pattern String -> ParamPattern Source #

formant filter to make things sound like vowels, a pattern of either a, e, i, o or u. Use a rest (`~`) for no effect.

drumN :: Num a => String -> a Source #

histpan :: Int -> Time -> [ParamPattern] -> ParamPattern Source #

Pans the last n versions of the pattern across the field

superwash :: (Pattern a -> Pattern a) -> (Pattern a -> Pattern a) -> Time -> Time -> Time -> Time -> [Pattern a] -> Pattern a Source #

A generalization of wash. Washes away the current pattern after a certain delay by applying a function to it over time, then switching over to the next pattern to which another function is applied.

wash :: (Pattern a -> Pattern a) -> Time -> Time -> [Pattern a] -> Pattern a Source #

Wash away the current pattern by applying a function to it over time, then switching over to the next.

d1 $ sound "feel ! feel:1 feel:2"

t1 (wash (chop 8) 4) $ sound "feel*4 [feel:2 sn:2]"

Note that `chop 8` is applied to `sound "feel ! feel:1 feel:2"` for 4 cycles and then the whole pattern is replaced by `sound "feel*4 [feel:2 sn:2]`

wait :: Time -> Time -> [ParamPattern] -> ParamPattern Source #

Just stop for a bit before playing new pattern

wait' :: (Time -> [ParamPattern] -> ParamPattern) -> Time -> Time -> [ParamPattern] -> ParamPattern Source #

Just as wait, wait' stops for a bit and then applies the given transition to the playing pattern

d1 $ sound "bd"

t1 (wait' (xfadeIn 8) 4) $ sound "hh*8"

jump :: Time -> [ParamPattern] -> ParamPattern Source #

Jumps directly into the given pattern, this is essentially the _no transition_-transition.

Variants of jump provide more useful capabilities, see jumpIn and jumpMod

jumpIn :: Int -> Time -> [ParamPattern] -> ParamPattern Source #

Sharp jump transition after the specified number of cycles have passed.

t1 (jumpIn 2) $ sound "kick(3,8)"

jumpIn' :: Int -> Time -> [ParamPattern] -> ParamPattern Source #

Unlike jumpIn the variant jumpIn' will only transition at cycle boundary (e.g. when the cycle count is an integer).

jumpMod :: Int -> Time -> [ParamPattern] -> ParamPattern Source #

Sharp jump transition at next cycle boundary where cycle mod n == 0

mortal :: Time -> Time -> Time -> [ParamPattern] -> ParamPattern Source #

Degrade the new pattern over time until it ends in silence

striate :: Pattern Int -> ParamPattern -> ParamPattern Source #

Striate is a kind of granulator, for example:

d1 $ striate 3 $ sound "ho ho:2 ho:3 hc"

This plays the loop the given number of times, but triggering progressive portions of each sample. So in this case it plays the loop three times, the first time playing the first third of each sample, then the second time playing the second third of each sample, etc.. With the highhat samples in the above example it sounds a bit like reverb, but it isn't really.

You can also use striate with very long samples, to cut it into short chunks and pattern those chunks. This is where things get towards granular synthesis. The following cuts a sample into 128 parts, plays it over 8 cycles and manipulates those parts by reversing and rotating the loops.

d1 $  slow 8 $ striate 128 $ sound "bev"

striate' :: Pattern Int -> Pattern Double -> ParamPattern -> ParamPattern Source #

The striate' function is a variant of striate with an extra parameter, which specifies the length of each part. The striate' function still scans across the sample over a single cycle, but if each bit is longer, it creates a sort of stuttering effect. For example the following will cut the bev sample into 32 parts, but each will be 1/16th of a sample long:

d1 $ slow 32 $ striate' 32 (1/16) $ sound "bev"

Note that striate uses the begin and end parameters internally. This means that if you're using striate (or striate') you probably shouldn't also specify begin or end.

striateO :: Pattern Int -> Pattern Double -> ParamPattern -> ParamPattern Source #

like striate, but with an offset to the begin and end values

striateL :: Pattern Int -> Pattern Int -> ParamPattern -> ParamPattern Source #

Just like striate, but also loops each sample chunk a number of times specified in the second argument. The primed version is just like striate', where the loop count is the third argument. For example:

d1 $ striateL' 3 0.125 4 $ sound "feel sn:2"

Like striate, these use the begin and end parameters internally, as well as the loop parameter for these versions.

clutchIn :: Time -> Time -> [Pattern a] -> Pattern a Source #

Also degrades the current pattern and undegrades the next. To change the number of cycles the transition takes, you can use clutchIn like so:

d1 $ sound "bd(5,8)"

t1 (clutchIn 8) $ sound "[hh*4, odx(3,8)]"

will take 8 cycles for the transition.

clutch :: Time -> [Pattern a] -> Pattern a Source #

Degrades the current pattern while undegrading the next.

This is like xfade but not by gain of samples but by randomly removing events from the current pattern and slowly adding back in missing events from the next one.

d1 $ sound "bd(3,8)"

t1 clutch $ sound "[hh*4, odx(3,8)]"

clutch takes two cycles for the transition, essentially this is clutchIn 2.

xfadeIn :: Time -> Time -> [ParamPattern] -> ParamPattern Source #

crossfades between old and new pattern over given number of cycles, e.g.:

d1 $ sound "bd sn"

t1 (xfadeIn 16) $ sound "jvbass*3"

Will fade over 16 cycles from "bd sn" to "jvbass*3"

xfade :: Time -> [ParamPattern] -> ParamPattern Source #

Crossfade between old and new pattern over the next two cycles.

d1 $ sound "bd sn"

t1 xfade $ sound "can*3"

xfade is built with xfadeIn in this case taking two cycles for the fade.

stut :: Pattern Integer -> Pattern Double -> Pattern Rational -> ParamPattern -> ParamPattern Source #

Stut applies a type of delay to a pattern. It has three parameters, which could be called depth, feedback and time. Depth is an integer and the others floating point. This adds a bit of echo:

d1 $ stut 4 0.5 0.2 $ sound "bd sn"

The above results in 4 echos, each one 50% quieter than the last, with 1/5th of a cycle between them. It is possible to reverse the echo:

d1 $ stut 4 0.5 (-0.2) $ sound "bd sn"

stut' :: Pattern Int -> Pattern Time -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

Instead of just decreasing volume to produce echoes, stut' allows to apply a function for each step and overlays the result delayed by the given time.

d1 $ stut' 2 (1%3) (# vowel "{a e i o u}%2") $ sound "bd sn"

In this case there are two _overlays_ delayed by 1/3 of a cycle, where each has the vowel filter applied.

_stut' :: (Num n, Ord n) => n -> Time -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

durPattern :: Pattern a -> Pattern Time Source #

durPattern takes a pattern and returns the length of events in that pattern as a new pattern. For example the result of `durPattern "[a ~] b"` would be `"[0.25 ~] 0.5"`.

durPattern' :: Pattern a -> Pattern Time Source #

durPattern' is similar to durPattern, but does some lookahead to try to find the length of time to the *next* event. For example, the result of durPattern "[a ~] b"` would be `"[0.5 ~] 0.5"`.

stutx :: Pattern Int -> Pattern Time -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

stutx is like stut' but will limit the number of repeats using the duration of the original sound. This usually prevents overlapping "stutters" from subsequent sounds.

anticipateIn :: Time -> Time -> [ParamPattern] -> ParamPattern Source #

same as anticipate though it allows you to specify the number of cycles until dropping to the new pattern, e.g.:

d1 $ sound "jvbass(3,8)"

t1 (anticipateIn 4) $ sound "jvbass(5,8)"

anticipate :: Time -> [ParamPattern] -> ParamPattern Source #

anticipate is an increasing comb filter.

Build up some tension, culminating in a _drop_ to the new pattern after 8 cycles.

nToOrbit :: ParamPattern -> ParamPattern Source #

Copies the n parameter to the orbit parameter, so different sound variants or notes go to different orbits in SuperDirt.

soundToOrbit :: [String] -> ParamPattern -> ParamPattern Source #

Maps the sample or synth names to different orbits, using indexes from the given list. E.g. soundToOrbit ["bd", "sn", "cp"] $ sound "bd [cp sn]" would cause the bd, sn and cp smamples to be sent to orbit 0, 1, 2 respectively.

stutter :: Integral i => i -> Time -> Pattern a -> Pattern a Source #

jux :: (ParamPattern -> Pattern ParamMap) -> ParamPattern -> Pattern ParamMap Source #

The jux function creates strange stereo effects, by applying a function to a pattern, but only in the right-hand channel. For example, the following reverses the pattern on the righthand side:

d1 $ slow 32 $ jux (rev) $ striate' 32 (1/16) $ sound "bev"

When passing pattern transforms to functions like jux and every, it's possible to chain multiple transforms together with ., for example this both reverses and halves the playback speed of the pattern in the righthand channel:

d1 $ slow 32 $ jux ((# speed "0.5") . rev) $ striate' 32 (1/16) $ sound "bev"

jux' :: [t -> ParamPattern] -> t -> Pattern ParamMap Source #

In addition to jux, jux' allows using a list of pattern transform. resulting patterns from each transformation will be spread via pan from left to right.

For example:

d1 $ jux' [iter 4, chop 16, id, rev, palindrome] $ sound "bd sn"

will put `iter 4` of the pattern to the far left and palindrome to the far right. In the center the original pattern will play and mid left mid right the chopped and the reversed version will appear.

One could also write:

d1 $ stack [
    iter 4 $ sound "bd sn" # pan "0",
    chop 16 $ sound "bd sn" # pan "0.25",
    sound "bd sn" # pan "0.5",
    rev $ sound "bd sn" # pan "0.75",
    palindrome $ sound "bd sn" # pan "1",
    ]

jux4 :: (ParamPattern -> Pattern ParamMap) -> ParamPattern -> Pattern ParamMap Source #

Multichannel variant of jux, _not sure what it does_

juxBy :: Pattern Double -> (ParamPattern -> Pattern ParamMap) -> ParamPattern -> Pattern ParamMap Source #

With jux, the original and effected versions of the pattern are panned hard left and right (i.e., panned at 0 and 1). This can be a bit much, especially when listening on headphones. The variant juxBy has an additional parameter, which brings the channel closer to the centre. For example:

d1 $ juxBy 0.5 (density 2) $ sound "bd sn:1"

In the above, the two versions of the pattern would be panned at 0.25 and 0.75, rather than 0 and 1.

smash :: Pattern Int -> [Pattern Time] -> ParamPattern -> Pattern ParamMap Source #

Smash is a combination of spread and striate - it cuts the samples into the given number of bits, and then cuts between playing the loop at different speeds according to the values in the list.

So this:

d1 $ smash 3 [2,3,4] $ sound "ho ho:2 ho:3 hc"

Is a bit like this:

d1 $ spread (slow) [2,3,4] $ striate 3 $ sound "ho ho:2 ho:3 hc"

This is quite dancehall:

d1 $ (spread' slow "1%4 2 1 3" $ spread (striate) [2,3,4,1] $ sound
"sn:2 sid:3 cp sid:4")
  # speed "[1 2 1 1]/2"

smash' :: Int -> [Pattern Time] -> ParamPattern -> Pattern ParamMap Source #

an altenative form to smash is smash' which will use chop instead of striate.

spreadf :: p1 -> p2 -> [a -> Pattern b] -> a -> Pattern b Source #

spin :: Pattern Int -> ParamPattern -> ParamPattern Source #

spin will "spin" a layer up a pattern the given number of times, with each successive layer offset in time by an additional `1/n` of a cycle, and panned by an additional `1/n`. The result is a pattern that seems to spin around. This function works best on multichannel systems.

d1 $ slow 3 $ spin 4 $ sound "drum*3 tabla:4 [arpy:2 ~ arpy] [can:2 can:3]"

scale :: (Functor f, Num b) => b -> b -> f b -> f b Source #

scale will take a pattern which goes from 0 to 1 (like sine1), and scale it to a different range - between the first and second arguments. In the below example, `scale 1 1.5` shifts the range of sine1 from 0 - 1 to 1 - 1.5.

d1 $ jux (iter 4) $ sound "arpy arpy:2*2"
  |+| speed (slow 4 $ scale 1 1.5 sine1)

scalex :: (Functor f, Floating b) => b -> b -> f b -> f b Source #

scalex is an exponential version of scale, good for using with frequencies. Do *not* use negative numbers or zero as arguments!

chop :: Pattern Int -> ParamPattern -> ParamPattern Source #

chop granualizes every sample in place as it is played, turning a pattern of samples into a pattern of sample parts. Use an integer value to specify how many granules each sample is chopped into:

d1 $ chop 16 $ sound "arpy arp feel*4 arpy*4"

Different values of chop can yield very different results, depending on the samples used:

d1 $ chop 16 $ sound (samples "arpy*8" (run 16))
d1 $ chop 32 $ sound (samples "arpy*8" (run 16))
d1 $ chop 256 $ sound "bd*4 [sn cp] [hh future]*2 [cp feel]"

gap :: Pattern Int -> ParamPattern -> ParamPattern Source #

gap is similar to chop in that it granualizes every sample in place as it is played, but every other grain is silent. Use an integer value to specify how many granules each sample is chopped into:

d1 $ gap 8 $ sound "jvbass"
d1 $ gap 16 $ sound "[jvbass drum:4]"

chopArc :: Arc -> Int -> [Arc] Source #

weave :: Rational -> ParamPattern -> [ParamPattern] -> ParamPattern Source #

weave applies a function smoothly over an array of different patterns. It uses an OscPattern to apply the function at different levels to each pattern, creating a weaving effect.

d1 $ weave 3 (shape $ sine1) [sound "bd [sn drum:2*2] bd*2 [sn drum:1]", sound "arpy*8 ~"]

weave' :: Rational -> Pattern a -> [Pattern a -> Pattern a] -> Pattern a Source #

weave' is similar in that it blends functions at the same time at different amounts over a pattern:

d1 $ weave' 3 (sound "bd [sn drum:2*2] bd*2 [sn drum:1]") [density 2, (# speed "0.5"), chop 16]

interlace :: ParamPattern -> ParamPattern -> ParamPattern Source #

(A function that takes two OscPatterns, and blends them together into a new OscPattern. An OscPattern is basically a pattern of messages to a synthesiser.)

Shifts between the two given patterns, using distortion.

Example:

d1 $ interlace (sound  "bd sn kurt") (every 3 rev $ sound  "bd sn:2")

step :: String -> String -> Pattern String Source #

Step sequencing

step' :: [String] -> String -> Pattern String Source #

like step, but allows you to specify an array of strings to use for 0,1,2...

off :: Pattern Time -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

_off :: Time -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

up :: Pattern Double -> ParamPattern Source #

up does a poor man's pitchshift by semitones via speed.

You can easily produce melodies from a single sample with up:

d1  sound "arpy"

This will play the _arpy_ sample four times a cycle in the original pitch, pitched by 5 semitones, by 4 and then by an octave.

ghost'' :: Time -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a Source #

loopAt :: Pattern Time -> ParamPattern -> ParamPattern Source #

loopAt makes a sample fit the given number of cycles. Internally, it works by setting the unit parameter to "c", changing the playback speed of the sample with the speed parameter, and setting setting the density of the pattern to match.

d1 $ loopAt 4 $ sound "breaks125"
d1 $ juxBy 0.6 (|*| speed "2") $ slowspread (loopAt) [4,6,2,3] $ chop 12 $ sound "fm:14"

tabby :: Integer -> Pattern a -> Pattern a -> Pattern a Source #

tabby - A more literal weaving than the weave function, give number of threads per cycle and two patterns, and this function will weave them together using a plain (aka tabby) weave, with a simple over/under structure

data Sieve a Source #

Constructors

Sieve 

Fields

Instances
Functor Sieve Source # 
Instance details

Defined in Sound.Tidal.Sieve

Methods

fmap :: (a -> b) -> Sieve a -> Sieve b #

(<$) :: a -> Sieve b -> Sieve a #

Applicative Sieve Source # 
Instance details

Defined in Sound.Tidal.Sieve

Methods

pure :: a -> Sieve a #

(<*>) :: Sieve (a -> b) -> Sieve a -> Sieve b #

liftA2 :: (a -> b -> c) -> Sieve a -> Sieve b -> Sieve c #

(*>) :: Sieve a -> Sieve b -> Sieve b #

(<*) :: Sieve a -> Sieve b -> Sieve a #

Show (Sieve Bool) Source # 
Instance details

Defined in Sound.Tidal.Sieve

(@@) :: Int -> Int -> Sieve Bool infixl 9 Source #

The basic notation for and constructor of a boolean Sieve is m@@n, which represents all integers whose modulo with m is equal to n

not' :: Applicative f => f Bool -> f Bool Source #

not' gives the complement of a sieve

(#||#) :: Applicative f => f Bool -> f Bool -> f Bool infixl 2 Source #

gives the union (logical OR) of two sieves

(#&&#) :: Applicative f => f Bool -> f Bool -> f Bool infixl 3 Source #

gives the intersection (logical AND) of two sieves

(#^^#) :: Applicative f => f Bool -> f Bool -> f Bool infixl 2 Source #

#^^# gives the exclusive disjunction (logical XOR) of two sieves

sieveToList :: Int -> Sieve a -> [a] Source #

sieveToList n returns a list of the values of the sieve for each nonnegative integer less than n For example: sieveToList 10 $ 3@@1 returns `[False, True, False, False, True, False, False, True, False, False]`

sieveToString :: Int -> Sieve Bool -> [Char] Source #

sieveToString n represents the sieve as a character string, where - represents False and x represents True

sieveToInts :: Int -> Sieve Bool -> [Int] Source #

sieveToInts n returns a list of nonnegative integers less than n where the sieve is True

sieveToPat :: Int -> Sieve Bool -> Pattern String Source #

sieveToPat n returns a pattern where the cycle is divided into n beats, and there is an event whenever the matching beat number is in the sieve For example: sieveToPat 8 $ 3@@1 returns "~ x ~ ~ x ~ ~ x"

stepSieve :: Int -> String -> Sieve Bool -> Pattern String Source #

stepSieve n str works like sieveToPat but uses str in the pattern instead of x

slowstepSieve :: Pattern Time -> Int -> String -> Sieve Bool -> Pattern String Source #

slowstepSieve t is shorthand for applying slow t to the result of stepSieve

scaleSieve :: Int -> Sieve Bool -> Pattern Int -> Pattern Int Source #

scaleSieve n uses sieveToInts to turn a sieve into a list of integers, and then uses that with the toScale function to turn a pattern of numbers into a pattern of notes in the scale. For example: scaleSieve 8 (3@@1) "0 1 2 1" first converts the sieve to the scale [1, 4, 7] and then uses that with toScale to return the pattern "1 4 7 4"

sendEspTempo :: Real t => t -> IO () Source #

clockedTickEsp :: Int -> (Tempo -> Int -> IO ()) -> IO () Source #

clockedTickLoopEsp :: Int -> (Tempo -> Int -> IO ()) -> MVar Tempo -> Int -> IO Int Source #

type CpsUtils = (Double -> IO (), IO Rational) Source #

data SyncType Source #

Constructors

NoSync 
Esp 

data StreamType Source #

Constructors

Dirt 
SuperDirt