Maintainer | diagrams-discuss@googlegroups.com |
---|---|
Safe Haskell | None |
A module to re-export most of the functionality of the diagrams core and standard library.
- module Diagrams.Core
- module Diagrams.Attributes
- module Diagrams.Align
- module Diagrams.Combinators
- module Diagrams.Located
- module Diagrams.Segment
- module Diagrams.Trail
- module Diagrams.Parametric
- module Diagrams.Parametric.Adjust
- module Diagrams.Tangent
- module Diagrams.TrailLike
- module Diagrams.Path
- module Diagrams.CubicSpline
- module Diagrams.Transform
- module Diagrams.Deform
- module Diagrams.Names
- module Diagrams.Envelope
- module Diagrams.Trace
- module Diagrams.Query
- module Diagrams.Points
- module Diagrams.Angle
- module Diagrams.Coordinates
- module Diagrams.TwoD
- module Diagrams.Animation
- module Diagrams.Util
- module Data.Colour
- module Data.Colour.Names
- module Data.Semigroup
- module Data.VectorSpace
- module Data.AffineSpace
- module Data.Active
- (&) :: a -> (a -> b) -> b
- (.~) :: ASetter s t a b -> b -> s -> t
- (%~) :: Profunctor p => Setting p s t a b -> p a b -> s -> t
- class Functor f => Applicative f where
- (*>) :: 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
Core library
The core definitions of transformations, diagrams, backends, and so on.
module Diagrams.Core
Standard library
Attributes (color, line style, etc.) and styles.
module Diagrams.Attributes
Alignment of diagrams relative to their envelopes.
module Diagrams.Align
Combining multiple diagrams into one.
module Diagrams.Combinators
Giving concrete locations to translation-invariant things.
module Diagrams.Located
Linear and cubic bezier segments.
module Diagrams.Segment
Trails.
module Diagrams.Trail
Parametrization of segments and trails.
module Diagrams.Parametric
Adjusting the length of parameterized objects.
module Diagrams.Parametric.Adjust
Computing tangent and normal vectors of segments and trails.
module Diagrams.Tangent
Trail-like things.
module Diagrams.TrailLike
Paths.
module Diagrams.Path
Cubic splines.
module Diagrams.CubicSpline
Some additional transformation-related functions, like conjugation of transformations.
module Diagrams.Transform
Projective transformations and other deformations lacking an inverse.
module Diagrams.Deform
Giving names to subdiagrams and later retrieving subdiagrams by name.
module Diagrams.Names
Envelopes, aka functional bounding regions.
module Diagrams.Envelope
Traces, aka embedded raytracers, for finding points on the boundary of a diagram.
module Diagrams.Trace
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.
module Diagrams.Query
Utilities for working with points.
module Diagrams.Points
Angles
module Diagrams.Angle
Convenience infix operators for working with coordinates.
module Diagrams.Coordinates
A wide range of things (shapes, transformations, combinators) specific to creating two-dimensional diagrams.
module Diagrams.TwoD
Tools for making animations.
module Diagrams.Animation
Various utility definitions.
module Diagrams.Util
Convenience re-exports
For representing and operating on colors.
module Data.Colour
A large list of color names.
module Data.Colour.Names
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 Data.VectorSpace
For computing with points and vectors.
module Data.AffineSpace
For working with Active
(i.e. animated) things.
module Data.Active
Essential Lens Combinators
(&) :: a -> (a -> b) -> b
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")
This reads somewhat similar to:
>>>
flip execState ("hello","world") $ do _1.element 0 .= 'j'; _1.element 4 .= 'y'
("jelly","world")
(.~) :: ASetter s t a b -> b -> s -> t
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
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
%~
ffmapDefault
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
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
and
pure
= return
(
(which implies that <*>
) = ap
pure
and <*>
satisfy the
applicative functor laws).
pure :: a -> f a
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b
Sequential application.
(*>) :: f a -> f b -> f b
Sequence actions, discarding the value of the first argument.
(<*) :: f a -> f b -> f a
Sequence actions, discarding the value of the second argument.
(*>) :: 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.
liftA :: Applicative f => (a -> b) -> f a -> f b
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.