diagrams-lib-1.3.0.8: Embedded domain-specific language for declarative graphics

Copyright | (c) 2011-2015 diagrams-lib team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None
Language | Haskell2010

Diagrams.Prelude

Contents

- Diagrams library
- Convenience re-exports from other packages

Description

A module to re-export most of the functionality of the diagrams core and standard library.

Synopsis

- module Diagrams
- module Data.Default.Class
- module Data.Colour
- module Data.Colour.Names
- module Data.Colour.SRGB
- module Data.Semigroup
- module Linear.Vector
- module Linear.Affine
- module Linear.Metric
- module Data.Active
- module Control.Lens
- class Functor f => Applicative f where
  - pure :: a -> f a
  - (<*>) :: f (a -> b) -> f a -> f b
  - (*>) :: f a -> f b -> f b
  - (<*) :: f a -> f b -> f a
- (*>) :: Applicative f => forall a b. f a -> f b -> f b
- (<*) :: Applicative f => forall a b. f a -> f b -> f a
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<$) :: Functor f => forall a b. a -> f b -> f a
- liftA :: Applicative f => (a -> b) -> f a -> f b
- liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

# Diagrams library

Exports from this library for working with diagrams.

module Diagrams

# Convenience re-exports from other packages

For working with default values. Diagrams also exports `with`, an alias for `def`.

module Data.Default.Class

For representing and operating on colors.

module Data.Colour

A large list of color names.

module Data.Colour.Names

Specify your own colours.

module Data.Colour.SRGB

Semigroups and monoids show up all over the place, so things from Data.Semigroup and Data.Monoid often come in handy.

module Data.Semigroup

For computing with vectors.

module Linear.Vector

For computing with points and vectors.

module Linear.Affine

For computing with dot products and norm.

module Linear.Metric

For working with `Active` (i.e. animated) things.

module Data.Active

Most of the lens package. The following functions are not exported from lens because they either conflict with diagrams or may conflict with other libraries:

- `at`
- `contains`
- `.>`
- `<.>`
- `index`
- `indices`
- `none`
- `coerce`
- `indexed`
- `inside`
- `levels`
- `...`
- `children`
- `transform`
- `outside`
- `argument`
- `beside`
- `singular`

module Control.Lens

class Functor f => Applicative f where

A functor with application, providing operations to

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

A minimal complete definition must include implementations of these functions satisfying the following laws:

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:

-     u *> v = pure (const id) <*> u <*> v

-     u <* v = pure const <*> u <*> v

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

-     fmap f x = pure f <*> x

If `f` is also a `Monad`, it should satisfy

-     pure = return

-     (<*>) = ap

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

Minimal complete definition

pure, (<*>)

Methods

pure :: a -> f a

Lift a value.

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

Sequential application.

(*>) :: 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 [] |
Applicative IO |
Applicative Q |
Applicative Active |
Applicative Duration |
Applicative Id |
Applicative P |
Applicative Identity |
Applicative ZipList |
Applicative STM |
Applicative First |
Applicative Last |
Applicative ReadPrec |
Applicative ReadP |
Applicative Maybe |
Applicative Get |
Applicative Put |
Applicative RGB |
Applicative Tree |
Applicative Seq |
Applicative Interval |
Applicative Vector |
Applicative Quaternion |
Applicative Plucker |
Applicative V4 |
Applicative V3 |
Applicative V2 |
Applicative V1 |
Applicative V0 |
Applicative ComplResult |
Applicative P |
Applicative Completion |
Applicative ReadM |
Applicative Parser |
Applicative ParserM |
Applicative ParserResult |
Applicative Chunk |
Applicative Min |
Applicative Max |
Applicative First |
Applicative Last |
Applicative Option |
Applicative NonEmpty |
Applicative Box |
Applicative Id |
Applicative Get |
Applicative Angle |
Applicative Id |
Applicative Stream |
Applicative ((->) a) |
Applicative (Either e) |
Monoid a => Applicative ((,) a) |
Representable f => Applicative (Co f) |
Applicative (ST s) |
Applicative (StateL s) |
Applicative (StateR s) |
Applicative (ST s) |
Monoid m => Applicative (Const m) |
Monad m => Applicative (WrappedMonad m) |
Arrow a => Applicative (ArrowMonad a) |
Applicative (Proxy *) |
Applicative (State s) |
Applicative (Measured n) |
Applicative f => Applicative (Point f) |
Applicative f => Applicative (Backwards f) | Apply `f`-actions in the reverse order.
Applicative f => Applicative (Yoneda f) |
Applicative m => Applicative (ListT m) |
(Functor m, Monad m) => Applicative (MaybeT m) |
Applicative (ReifiedGetter s) |
Applicative (ReifiedFold s) |
Applicative f => Applicative (Indexing f) |
Applicative f => Applicative (Indexing64 f) |
Monad m => Applicative (ListT m) |
Monad m => Applicative (NondetT m) |
Applicative f => Applicative (Reverse f) | Derived instance.
Applicative m => Applicative (IdentityT m) |
Monoid a => Applicative (Constant a) |
(Applicative (Rep p), Representable p) => Applicative (Prep p) |
Alternative f => Applicative (Cofree f) |
Applicative f => Applicative (WrappedApplicative f) |
Apply f => Applicative (MaybeApply f) |
Applicative (StateR s) |
Applicative (StateL s) |
Arrow a => Applicative (WrappedArrow a b) |
Applicative f => Applicative (Alt * f) |
Applicative (Query v n) |
(Applicative f, Applicative g) => Applicative (Compose f g) |
(Functor m, Monad m) => Applicative (ErrorT e m) |
Applicative (Indexed i a) |
(Monad m, Monoid s) => Applicative (Focusing m s) |
Applicative (k (May s)) => Applicative (FocusingMay k s) |
(Monad m, Monoid r) => Applicative (Effect m r) |
Dim k n => Applicative (V k n) |
Applicative (ContT r m) |
Applicative m => Applicative (ReaderT r m) |
(Functor m, Monad m) => Applicative (StateT s m) |
(Functor m, Monad m) => Applicative (StateT s m) |
(Functor m, Monad m) => Applicative (ExceptT e m) |
(Monoid w, Applicative m) => Applicative (WriterT w m) |
(Monoid w, Applicative m) => Applicative (WriterT w m) |
Applicative (Tagged k s) |
(Applicative f, Applicative g) => Applicative (Product f g) |
Applicative (Costar f a) |
Applicative (Cokleisli w a) |
Applicative f => Applicative (Star f a) |
Applicative w => Applicative (TracedT m w) |
(Monad m, Monoid s, Monoid w) => Applicative (FocusingWith w m s) |
Applicative (k (s, w)) => Applicative (FocusingPlus w k s) |
Applicative (k (f s)) => Applicative (FocusingOn f k s) |
Applicative (k (Err e s)) => Applicative (FocusingErr e k s) |
(Monoid s, Monoid w, Monad m) => Applicative (EffectRWS w st m s) |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) |
Reifies k s (ReifiedApplicative f) => Applicative (ReflectedApplicative k * f s) |

(*>) :: Applicative f => forall a b. f a -> f b -> f b

Sequence actions, discarding the value of the first argument.

(<*) :: Applicative f => forall a b. f a -> f b -> f a

Sequence actions, discarding the value of the second argument.

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

An infix synonym for `fmap`.

#### Examples

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)

(<$) :: Functor f => forall a b. a -> f b -> f a

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.

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.

liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

Lift a binary function to actions.

liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

Lift a ternary function to actions.