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

Copyright (c) 2013 diagrams-lib team (see LICENSE) BSD-style (see LICENSE) diagrams-discuss@googlegroups.com None Haskell2010

Diagrams.Query

Contents

Description

A query is a function that maps points in a vector space to values in some monoid. Queries naturally form a monoid, with two queries being combined pointwise.

Synopsis

# Queries

newtype Query (v :: Type -> Type) n m #

A query is a function that maps points in a vector space to values in some monoid. Queries naturally form a monoid, with two queries being combined pointwise.

The idea for annotating diagrams with monoidal queries came from the graphics-drawingcombinators package, http://hackage.haskell.org/package/graphics-drawingcombinators.

Constructors

 Query FieldsrunQuery :: Point v n -> m
Instances
 Functor v => Profunctor (Query v) Instance detailsDefined in Diagrams.Core.Query Methodsdimap :: (a -> b) -> (c -> d) -> Query v b c -> Query v a d #lmap :: (a -> b) -> Query v b c -> Query v a c #rmap :: (b -> c) -> Query v a b -> Query v a c #(#.) :: Coercible c b => q b c -> Query v a b -> Query v a c #(.#) :: Coercible b a => Query v b c -> q a b -> Query v a c # Functor v => Corepresentable (Query v) Instance detailsDefined in Diagrams.Core.Query Associated Typestype Corep (Query v) :: Type -> Type # Methodscotabulate :: (Corep (Query v) d -> c) -> Query v d c # Functor v => Closed (Query v) Instance detailsDefined in Diagrams.Core.Query Methodsclosed :: Query v a b -> Query v (x -> a) (x -> b) # Functor v => Costrong (Query v) Instance detailsDefined in Diagrams.Core.Query Methodsunfirst :: Query v (a, d) (b, d) -> Query v a b #unsecond :: Query v (d, a) (d, b) -> Query v a b # Functor v => Cosieve (Query v) (Point v) Instance detailsDefined in Diagrams.Core.Query Methodscosieve :: Query v a b -> Point v a -> b # Monad (Query v n) Instance detailsDefined in Diagrams.Core.Query Methods(>>=) :: Query v n a -> (a -> Query v n b) -> Query v n b #(>>) :: Query v n a -> Query v n b -> Query v n b #return :: a -> Query v n a #fail :: String -> Query v n a # Functor (Query v n) Instance detailsDefined in Diagrams.Core.Query Methodsfmap :: (a -> b) -> Query v n a -> Query v n b #(<\$) :: a -> Query v n b -> Query v n a # Applicative (Query v n) Instance detailsDefined in Diagrams.Core.Query Methodspure :: a -> Query v n a #(<*>) :: Query v n (a -> b) -> Query v n a -> Query v n b #liftA2 :: (a -> b -> c) -> Query v n a -> Query v n b -> Query v n c #(*>) :: Query v n a -> Query v n b -> Query v n b #(<*) :: Query v n a -> Query v n b -> Query v n a # Distributive (Query v n) Instance detailsDefined in Diagrams.Core.Query Methodsdistribute :: Functor f => f (Query v n a) -> Query v n (f a) #collect :: Functor f => (a -> Query v n b) -> f a -> Query v n (f b) #distributeM :: Monad m => m (Query v n a) -> Query v n (m a) #collectM :: Monad m => (a -> Query v n b) -> m a -> Query v n (m b) # Representable (Query v n) Instance detailsDefined in Diagrams.Core.Query Associated Typestype Rep (Query v n) :: Type # Methodstabulate :: (Rep (Query v n) -> a) -> Query v n a #index :: Query v n a -> Rep (Query v n) -> a # Semigroup m => Semigroup (Query v n m) Instance detailsDefined in Diagrams.Core.Query Methods(<>) :: Query v n m -> Query v n m -> Query v n m #sconcat :: NonEmpty (Query v n m) -> Query v n m #stimes :: Integral b => b -> Query v n m -> Query v n m # Monoid m => Monoid (Query v n m) Instance detailsDefined in Diagrams.Core.Query Methodsmempty :: Query v n m #mappend :: Query v n m -> Query v n m -> Query v n m #mconcat :: [Query v n m] -> Query v n m # (Additive v, Num n) => Transformable (Query v n m) Instance detailsDefined in Diagrams.Core.Query Methodstransform :: Transformation (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m # (Additive v, Num n) => HasOrigin (Query v n m) Instance detailsDefined in Diagrams.Core.Query MethodsmoveOriginTo :: Point (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m # Wrapped (Query v n m) Instance detailsDefined in Diagrams.Core.Query Associated Typestype Unwrapped (Query v n m) :: Type # Methods_Wrapped' :: Iso' (Query v n m) (Unwrapped (Query v n m)) # HasQuery (Query v n m) m # Instance detailsDefined in Diagrams.Query MethodsgetQuery :: Query v n m -> Query (V (Query v n m)) (N (Query v n m)) m # Rewrapped (Query v a m) (Query v' a' m') Instance detailsDefined in Diagrams.Core.Query type Corep (Query v) Instance detailsDefined in Diagrams.Core.Query type Corep (Query v) = Point v type Rep (Query v n) Instance detailsDefined in Diagrams.Core.Query type Rep (Query v n) = Point v n type V (Query v n m) Instance detailsDefined in Diagrams.Core.Query type V (Query v n m) = v type N (Query v n m) Instance detailsDefined in Diagrams.Core.Query type N (Query v n m) = n type Unwrapped (Query v n m) Instance detailsDefined in Diagrams.Core.Query type Unwrapped (Query v n m) = Point v n -> m

class HasQuery t m | t -> m where #

Types which can answer a Query about points inside the geometric object.

If t and m are both a Semigroups, getQuery should satisfy

getQuery (t1 <> t2) = getQuery t1 <> getQuery t2


Methods

getQuery :: t -> Query (V t) (N t) m #

Extract the query of an object.

Instances
 (Floating n, Ord n) => HasQuery (CSG n) Any # Instance detailsDefined in Diagrams.ThreeD.Shapes MethodsgetQuery :: CSG n -> Query (V (CSG n)) (N (CSG n)) Any # # Instance detailsDefined in Diagrams.ThreeD.Shapes MethodsgetQuery :: Frustum n -> Query (V (Frustum n)) (N (Frustum n)) Any # (Num n, Ord n) => HasQuery (Box n) Any # Instance detailsDefined in Diagrams.ThreeD.Shapes MethodsgetQuery :: Box n -> Query (V (Box n)) (N (Box n)) Any # (Num n, Ord n) => HasQuery (Ellipsoid n) Any # Instance detailsDefined in Diagrams.ThreeD.Shapes MethodsgetQuery :: Ellipsoid n -> Query (V (Ellipsoid n)) (N (Ellipsoid n)) Any # # Instance detailsDefined in Diagrams.TwoD.Path MethodsgetQuery :: Located (Trail V2 n) -> Query (V (Located (Trail V2 n))) (N (Located (Trail V2 n))) Crossings # # Instance detailsDefined in Diagrams.TwoD.Path MethodsgetQuery :: Located (Trail' l V2 n) -> Query (V (Located (Trail' l V2 n))) (N (Located (Trail' l V2 n))) Crossings # RealFloat n => HasQuery (Clip n) All # A point inside a clip if the point is in All invididual clipping paths. Instance detailsDefined in Diagrams.TwoD.Path MethodsgetQuery :: Clip n -> Query (V (Clip n)) (N (Clip n)) All # # Instance detailsDefined in Diagrams.TwoD.Path MethodsgetQuery :: Path V2 n -> Query (V (Path V2 n)) (N (Path V2 n)) Crossings # RealFloat n => HasQuery (DImage n a) Any # Instance detailsDefined in Diagrams.TwoD.Image MethodsgetQuery :: DImage n a -> Query (V (DImage n a)) (N (DImage n a)) Any # (Additive v, Foldable v, Ord n) => HasQuery (BoundingBox v n) Any # Instance detailsDefined in Diagrams.BoundingBox MethodsgetQuery :: BoundingBox v n -> Query (V (BoundingBox v n)) (N (BoundingBox v n)) Any # HasQuery (Query v n m) m # Instance detailsDefined in Diagrams.Query MethodsgetQuery :: Query v n m -> Query (V (Query v n m)) (N (Query v n m)) m # Monoid m => HasQuery (QDiagram b v n m) m # Instance detailsDefined in Diagrams.Query MethodsgetQuery :: QDiagram b v n m -> Query (V (QDiagram b v n m)) (N (QDiagram b v n m)) m #

sample :: HasQuery t m => t -> Point (V t) (N t) -> m #

Sample a diagram's query function at a given point.

sample :: QDiagram b v n m -> Point v n -> m
sample :: Query v n m      -> Point v n -> m
sample :: BoundingBox v n  -> Point v n -> Any
sample :: Path V2 Double   -> Point v n -> Crossings


inquire :: HasQuery t Any => t -> Point (V t) (N t) -> Bool #

Test if a point is not equal to mempty.

inquire :: QDiagram b v n Any -> Point v n -> Bool
inquire :: Query v n Any      -> Point v n -> Bool
inquire :: BoundingBox v n  -> Point v n -> Bool


## Queries on diagrams

query :: Monoid m => QDiagram b v n m -> Query v n m #

Get the query function associated with a diagram.

value :: Monoid m => m -> QDiagram b v n Any -> QDiagram b v n m #

Set the query value for True points in a diagram (i.e. points "inquire" the diagram); False points will be set to mempty.

resetValue :: (Eq m, Monoid m) => QDiagram b v n m -> QDiagram b v n Any #

Reset the query values of a diagram to True/False: any values equal to mempty are set to False; any other values are set to True.

clearValue :: QDiagram b v n m -> QDiagram b v n Any #

Set all the query values of a diagram to False.