diagrams-lib-1.4.6: Embedded domain-specific language for declarative graphics
Copyright(c) 2013 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Diagrams.Query

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 

Fields

Instances

Instances details
Functor v => Closed (Query v) 
Instance details

Defined in Diagrams.Core.Query

Methods

closed :: Query v a b -> Query v (x -> a) (x -> b) #

Functor v => Corepresentable (Query v) 
Instance details

Defined in Diagrams.Core.Query

Associated Types

type Corep (Query v) :: Type -> Type #

Methods

cotabulate :: (Corep (Query v) d -> c) -> Query v d c #

Functor v => Costrong (Query v) 
Instance details

Defined in Diagrams.Core.Query

Methods

unfirst :: Query v (a, d) (b, d) -> Query v a b #

unsecond :: Query v (d, a) (d, b) -> Query v a b #

Functor v => Profunctor (Query v) 
Instance details

Defined in Diagrams.Core.Query

Methods

dimap :: (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 #

(#.) :: forall a b c q. Coercible c b => q b c -> Query v a b -> Query v a c #

(.#) :: forall a b c q. Coercible b a => Query v b c -> q a b -> Query v a c #

Functor v => Cosieve (Query v) (Point v) 
Instance details

Defined in Diagrams.Core.Query

Methods

cosieve :: Query v a b -> Point v a -> b #

Representable (Query v n) 
Instance details

Defined in Diagrams.Core.Query

Associated Types

type Rep (Query v n) #

Methods

tabulate :: (Rep (Query v n) -> a) -> Query v n a #

index :: Query v n a -> Rep (Query v n) -> a #

Applicative (Query v n) 
Instance details

Defined in Diagrams.Core.Query

Methods

pure :: 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 #

Functor (Query v n) 
Instance details

Defined in Diagrams.Core.Query

Methods

fmap :: (a -> b) -> Query v n a -> Query v n b #

(<$) :: a -> Query v n b -> Query v n a #

Monad (Query v n) 
Instance details

Defined 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 #

Distributive (Query v n) 
Instance details

Defined in Diagrams.Core.Query

Methods

distribute :: 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) #

Monoid m => Monoid (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

Methods

mempty :: 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 #

Semigroup m => Semigroup (Query v n m) 
Instance details

Defined 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 #

(Additive v, Num n) => HasOrigin (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

Methods

moveOriginTo :: Point (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m #

(Additive v, Num n) => Transformable (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

Methods

transform :: Transformation (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m #

Wrapped (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

Associated Types

type Unwrapped (Query v n m) #

Methods

_Wrapped' :: Iso' (Query v n m) (Unwrapped (Query v n m)) #

HasQuery (Query v n m) m Source # 
Instance details

Defined in Diagrams.Query

Methods

getQuery :: Query v n m -> Query (V (Query v n m)) (N (Query v n m)) m Source #

Rewrapped (Query v a m) (Query v' a' m') 
Instance details

Defined in Diagrams.Core.Query

type Corep (Query v) 
Instance details

Defined in Diagrams.Core.Query

type Corep (Query v) = Point v
type Rep (Query v n) 
Instance details

Defined in Diagrams.Core.Query

type Rep (Query v n) = Point v n
type N (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

type N (Query v n m) = n
type V (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

type V (Query v n m) = v
type Unwrapped (Query v n m) 
Instance details

Defined in Diagrams.Core.Query

type Unwrapped (Query v n m) = Point v n -> m

class HasQuery t m | t -> m where Source #

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 Source #

Extract the query of an object.

Instances

Instances details
RealFloat n => HasQuery (Located (Trail V2 n)) Crossings Source # 
Instance details

Defined in Diagrams.TwoD.Path

RealFloat n => HasQuery (Located (Trail' l V2 n)) Crossings Source # 
Instance details

Defined in Diagrams.TwoD.Path

Methods

getQuery :: Located (Trail' l V2 n) -> Query (V (Located (Trail' l V2 n))) (N (Located (Trail' l V2 n))) Crossings Source #

(Num n, Ord n) => HasQuery (Box n) Any Source # 
Instance details

Defined in Diagrams.ThreeD.Shapes

Methods

getQuery :: Box n -> Query (V (Box n)) (N (Box n)) Any Source #

(Floating n, Ord n) => HasQuery (CSG n) Any Source # 
Instance details

Defined in Diagrams.ThreeD.Shapes

Methods

getQuery :: CSG n -> Query (V (CSG n)) (N (CSG n)) Any Source #

(Num n, Ord n) => HasQuery (Ellipsoid n) Any Source # 
Instance details

Defined in Diagrams.ThreeD.Shapes

Methods

getQuery :: Ellipsoid n -> Query (V (Ellipsoid n)) (N (Ellipsoid n)) Any Source #

OrderedField n => HasQuery (Frustum n) Any Source # 
Instance details

Defined in Diagrams.ThreeD.Shapes

Methods

getQuery :: Frustum n -> Query (V (Frustum n)) (N (Frustum n)) Any Source #

RealFloat n => HasQuery (Clip n) All Source #

A point inside a clip if the point is in All invididual clipping paths.

Instance details

Defined in Diagrams.TwoD.Path

Methods

getQuery :: Clip n -> Query (V (Clip n)) (N (Clip n)) All Source #

(Additive v, Foldable v, Ord n) => HasQuery (BoundingBox v n) Any Source # 
Instance details

Defined in Diagrams.BoundingBox

Methods

getQuery :: BoundingBox v n -> Query (V (BoundingBox v n)) (N (BoundingBox v n)) Any Source #

RealFloat n => HasQuery (Path V2 n) Crossings Source # 
Instance details

Defined in Diagrams.TwoD.Path

Methods

getQuery :: Path V2 n -> Query (V (Path V2 n)) (N (Path V2 n)) Crossings Source #

RealFloat n => HasQuery (DImage n a) Any Source # 
Instance details

Defined in Diagrams.TwoD.Image

Methods

getQuery :: DImage n a -> Query (V (DImage n a)) (N (DImage n a)) Any Source #

HasQuery (Query v n m) m Source # 
Instance details

Defined in Diagrams.Query

Methods

getQuery :: Query v n m -> Query (V (Query v n m)) (N (Query v n m)) m Source #

Monoid m => HasQuery (QDiagram b v n m) m Source # 
Instance details

Defined in Diagrams.Query

Methods

getQuery :: QDiagram b v n m -> Query (V (QDiagram b v n m)) (N (QDiagram b v n m)) m Source #

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

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 Source #

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 :: forall m b (v :: Type -> Type) n. 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 Source #

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 Source #

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 Source #

Set all the query values of a diagram to False.