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

Diagrams.Prelude.ThreeD

Description

A module to re-export most of the functionality of the diagrams core and standard library, including 3D types and functions.

Synopsis

# Core library

The core definitions of transformations, diagrams, backends, and so on.

# Standard library

Attributes (color, line style, etc.) and styles.

Alignment of diagrams relative to their envelopes.

Combining multiple diagrams into one.

Giving concrete locations to translation-invariant things.

Linear and cubic bezier segments.

Trails.

Parametrization of segments and trails.

Adjusting the length of parameterized objects.

Computing tangent and normal vectors of segments and trails.

Trail-like things.

Paths.

Cubic splines.

Some additional transformation-related functions, like conjugation of transformations.

Giving names to subdiagrams and later retrieving subdiagrams by name.

Envelopes, aka functional bounding regions.

Traces, aka embedded raytracers, for finding points on the boundary of a diagram.

A query is a function that maps points in a vector space to values in some monoid; they can be used to annotate the points of a diagram with some values.

Utilities for working with points.

Angles

Convenience infix operators for working with coordinates.

things (shapes, transformations, combinators) specific to creating three-dimensional diagrams.

Tools for making animations.

Various utility definitions.

# Convenience re-exports

For representing and operating on colors.

A large list of color names.

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

For computing with vectors.

For computing with points and vectors.

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

Essential Lens Combinators

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

Passes the result of the left side to the function on the right side (forward pipe operator).

This is the flipped version of (`\$`), which is more common in languages like F# as (`|>`) where it is needed for inference. Here it is supplied for notational convenience and given a precedence that allows it to be nested inside uses of (`\$`).

````>>> ````a & f
```f a
```
````>>> ````"hello" & length & succ
```6
```

This combinator is commonly used when applying multiple `Lens` operations in sequence.

````>>> ````("hello","world") & _1.element 0 .~ 'j' & _1.element 4 .~ 'y'
```("jelly","world")
```

````>>> ````flip execState ("hello","world") \$ do _1.element 0 .= 'j'; _1.element 4 .= 'y'
```("jelly","world")
```

(.~) :: ASetter s t a b -> b -> s -> t infixr 4

Replace the target of a `Lens` or all of the targets of a `Setter` or `Traversal` with a constant value.

This is an infix version of `set`, provided for consistency with (`.=`).

```f `<\$` a ≡ `mapped` `.~` f `\$` a
```
````>>> ````(a,b,c,d) & _4 .~ e
```(a,b,c,e)
```
````>>> ````(42,"world") & _1 .~ "hello"
```("hello","world")
```
````>>> ````(a,b) & both .~ c
```(c,c)
```
```(`.~`) :: `Setter` s t a b    -> b -> s -> t
(`.~`) :: `Iso` s t a b       -> b -> s -> t
(`.~`) :: `Lens` s t a b      -> b -> s -> t
(`.~`) :: `Traversal` s t a b -> b -> s -> t
```

(%~) :: Profunctor p => Setting p s t a b -> p a b -> s -> t infixr 4

Modifies the target of a `Lens` or all of the targets of a `Setter` or `Traversal` with a user supplied function.

This is an infix version of `over`.

````fmap` f ≡ `mapped` `%~` f
`fmapDefault` f ≡ `traverse` `%~` f
```
````>>> ````(a,b,c) & _3 %~ f
```(a,b,f c)
```
````>>> ````(a,b) & both %~ f
```(f a,f b)
```
````>>> ````_2 %~ length \$ (1,"hello")
```(1,5)
```
````>>> ````traverse %~ f \$ [a,b,c]
```[f a,f b,f c]
```
````>>> ````traverse %~ even \$ [1,2,3]
```[False,True,False]
```
````>>> ````traverse.traverse %~ length \$ [["hello","world"],["!!!"]]
```[[5,5],[3]]
```
```(`%~`) :: `Setter` s t a b    -> (a -> b) -> s -> t
(`%~`) :: `Iso` s t a b       -> (a -> b) -> s -> t
(`%~`) :: `Lens` s t a b      -> (a -> b) -> s -> t
(`%~`) :: `Traversal` s t a b -> (a -> b) -> s -> t
```

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

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 Id Applicative ZipList Applicative STM Applicative ReadPrec Applicative ReadP Applicative Maybe Applicative RGB Applicative Identity Applicative Id Applicative Tree Applicative Seq Applicative Interval Applicative Vector Applicative ReadM Applicative Parser Applicative ParserM Applicative ParserResult Applicative Min Applicative Max Applicative First Applicative Last Applicative Option Applicative NonEmpty Applicative PprM Applicative Id Applicative Box Applicative Sum Applicative ((->) a) Applicative (Either e) Monoid a => Applicative ((,) a) HasTrie a => Applicative ((:->:) a) Applicative (ST s) Applicative (StateL s) Applicative (StateR s) Monoid m => Applicative (Const m) Monad m => Applicative (WrappedMonad m) Applicative (ST s) Arrow a => Applicative (ArrowMonad a) Applicative (Proxy *) Applicative m => Applicative (IdentityT m) Applicative (State s) Applicative (Query v) Applicative f => Applicative (Backwards f) Apply `f`-actions in the reverse order. 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) Applicative f => Applicative (WrappedApplicative f) Apply f => Applicative (MaybeApply f) Applicative f => Applicative (Reverse f) Derived instance. Applicative f => Applicative (Lift f) A combination is `Pure` only if both parts are. Monoid a => Applicative (Constant a) Arrow a => Applicative (WrappedArrow a b) Applicative w => Applicative (TracedT m w) Applicative (Cokleisli w a) (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) 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) (Monoid w, Applicative m) => Applicative (WriterT w m) (Monoid w, Applicative m) => Applicative (WriterT w m) (Applicative f, Applicative g) => Applicative (Compose f g) Applicative f => Applicative (UpStar f a) Applicative (DownStar f a) Applicative (Tagged k s) (Applicative f, Applicative g) => Applicative (Product f g) (Functor m, Monad m) => Applicative (ExceptT e m) Typeable ((* -> *) -> Constraint) Applicative (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)

(*>) :: 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`.

(<\$) :: 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.