diagrams-core-1.5.1.1: Core libraries for diagrams EDSL

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

Diagrams.Core.Names

Contents

- Names
  - Atomic names
  - Names
  - Qualifiable

Description

This module defines a type of names which can be used for referring to subdiagrams, and related types.

Synopsis

- data AName where
  - AName :: forall a. (Typeable a, Ord a, Show a) => a -> AName
- _AName :: (Typeable a, Ord a, Show a) => Prism' AName a
- newtype Name = Name [AName]
- class (Typeable a, Ord a, Show a) => IsName a where
  - toName :: a -> Name
- (.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name
- eachName :: (Typeable a, Ord a, Show a) => Traversal' Name a
- class Qualifiable q where
  - (.>>) :: IsName a => a -> q -> q

# Names

## Atomic names

data AName where Source #

Atomic names. `AName` is just an existential wrapper around things which are `Typeable`, `Ord` and `Show`.

Constructors

AName :: forall a. (Typeable a, Ord a, Show a) => a -> AName |

#### Instances

Instances details

IsName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: AName -> Name Source #
Show AName Source # |
Instance details Defined in Diagrams.Core.Names Methods showsPrec :: Int -> AName -> ShowS Source # show :: AName -> String Source # showList :: [AName] -> ShowS Source #
Eq AName Source # |
Instance details Defined in Diagrams.Core.Names Methods (==) :: AName -> AName -> Bool Source # (/=) :: AName -> AName -> Bool Source #
Ord AName Source # |
Instance details Defined in Diagrams.Core.Names Methods compare :: AName -> AName -> Ordering Source # (<) :: AName -> AName -> Bool Source # (<=) :: AName -> AName -> Bool Source # (>) :: AName -> AName -> Bool Source # (>=) :: AName -> AName -> Bool Source # max :: AName -> AName -> AName Source # min :: AName -> AName -> AName Source #
Each Name Name AName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods each :: Traversal Name Name AName AName Source #

_AName :: (Typeable a, Ord a, Show a) => Prism' AName a Source #

Prism onto `AName`.

## Names

newtype Name Source #

A (qualified) name is a (possibly empty) sequence of atomic names.

Constructors

Name [AName] |

#### Instances

Instances details

IsName Name Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Name -> Name Source #
Qualifiable Name Source # | Of course, names can be qualified using `(.>)`.
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a => a -> Name -> Name Source #
Monoid Name Source # |
Instance details Defined in Diagrams.Core.Names Methods mempty :: Name Source # mappend :: Name -> Name -> Name Source # mconcat :: [Name] -> Name Source #
Semigroup Name Source # |
Instance details Defined in Diagrams.Core.Names Methods (<>) :: Name -> Name -> Name Source # sconcat :: NonEmpty Name -> Name Source # stimes :: Integral b => b -> Name -> Name Source #
Show Name Source # |
Instance details Defined in Diagrams.Core.Names Methods showsPrec :: Int -> Name -> ShowS Source # show :: Name -> String Source # showList :: [Name] -> ShowS Source #
Eq Name Source # |
Instance details Defined in Diagrams.Core.Names Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #
Ord Name Source # |
Instance details Defined in Diagrams.Core.Names Methods compare :: Name -> Name -> Ordering Source # (<) :: Name -> Name -> Bool Source # (<=) :: Name -> Name -> Bool Source # (>) :: Name -> Name -> Bool Source # (>=) :: Name -> Name -> Bool Source # max :: Name -> Name -> Name Source # min :: Name -> Name -> Name Source #
Wrapped Name Source # |

Instance details

Defined in Diagrams.Core.Names

Associated Types

type Unwrapped Name |
Instance details Defined in Diagrams.Core.Names type Unwrapped Name = [AName]

Methods

_Wrapped' :: Iso' Name (Unwrapped Name) Source #

Rewrapped Name Name Source # |
Instance details Defined in Diagrams.Core.Names
Each Name Name AName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods each :: Traversal Name Name AName AName Source #
Action Name a => Action Name (Deletable a) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Deletable a -> Deletable a Source #
Action Name (Envelope v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Envelope v n -> Envelope v n Source #
Action Name (Trace v n) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Trace v n -> Trace v n Source #
Action Name (Query v n m) Source # |
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> Query v n m -> Query v n m Source #
Action Name (SubMap b v n m) Source # | A name acts on a name map by qualifying every name in it.
Instance details Defined in Diagrams.Core.Types Methods act :: Name -> SubMap b v n m -> SubMap b v n m Source #
type Unwrapped Name Source # |
Instance details Defined in Diagrams.Core.Names type Unwrapped Name = [AName]

class (Typeable a, Ord a, Show a) => IsName a where Source #

Class for those types which can be used as names. They must support `Typeable` (to facilitate extracting them from existential wrappers), `Ord` (for comparison and efficient storage) and `Show`.

To make an instance of `IsName`, you need not define any methods, just declare it.

WARNING: it is not recommended to use `GeneralizedNewtypeDeriving` in conjunction with `IsName`, since in that case the underlying type and the `newtype` will be considered equivalent when comparing names. For example:

        newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)

is unlikely to work as intended, since `(1 :: Int)` and `(WordN 1)` will be considered equal as names. Instead, use

        newtype WordN = WordN Int deriving (Show, Ord, Eq, Typeable, IsName)
        instance IsName WordN

Minimal complete definition

Nothing

Methods

toName :: a -> Name Source #

#### Instances

Instances details

IsName AName Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: AName -> Name Source #
IsName Name Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Name -> Name Source #
IsName Integer Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Integer -> Name Source #
IsName () Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: () -> Name Source #
IsName Bool Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Bool -> Name Source #
IsName Char Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Char -> Name Source #
IsName Double Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Double -> Name Source #
IsName Float Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Float -> Name Source #
IsName Int Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Int -> Name Source #
IsName a => IsName (Maybe a) Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: Maybe a -> Name Source #
IsName a => IsName [a] Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: [a] -> Name Source #
(IsName a, IsName b) => IsName (a, b) Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: (a, b) -> Name Source #
(IsName a, IsName b, IsName c) => IsName (a, b, c) Source # |
Instance details Defined in Diagrams.Core.Names Methods toName :: (a, b, c) -> Name Source #

(.>) :: (IsName a1, IsName a2) => a1 -> a2 -> Name infixr 5 Source #

Convenient operator for writing qualified names with atomic components of different types. Instead of writing `toName a1 <> toName a2 <> toName a3` you can just write `a1 .> a2 .> a3`.

eachName :: (Typeable a, Ord a, Show a) => Traversal' Name a Source #

Traversal over each name in a `Name` that matches the target type.

    >>> toListOf eachName (a .> False .> b) :: String
    "ab"
    >>> a .> True .> b & eachName %~ not
    a .> False .> b

Note that the type of the name is very important.

    >>> sumOf eachName ((1::Int) .> (2 :: Integer) .> (3 :: Int)) :: Int
    4
    >>> sumOf eachName ((1::Int) .> (2 :: Integer) .> (3 :: Int)) :: Integer
    2

## Qualifiable

class Qualifiable q where Source #

Instances of `Qualifiable` are things which can be qualified by prefixing them with a name.

Methods

(.>>) :: IsName a => a -> q -> q infixr 5 Source #

Qualify with the given name.

#### Instances

Instances details

Qualifiable Name Source # | Of course, names can be qualified using `(.>)`.
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a => a -> Name -> Name Source #
(Ord a, Qualifiable a) => Qualifiable (Set a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Set a -> Set a Source #
Qualifiable a => Qualifiable (TransInv a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> TransInv a -> TransInv a Source #
Qualifiable a => Qualifiable [a] Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> [a] -> [a] Source #
Qualifiable a => Qualifiable (Map k a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Map k a -> Map k a Source #
Qualifiable a => Qualifiable (Measured n a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> Measured n a -> Measured n a Source #
(Qualifiable a, Qualifiable b) => Qualifiable (a, b) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> (a, b) -> (a, b) Source #
Qualifiable a => Qualifiable (b -> a) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> (b -> a) -> b -> a Source #
(Qualifiable a, Qualifiable b, Qualifiable c) => Qualifiable (a, b, c) Source # |
Instance details Defined in Diagrams.Core.Names Methods (.>>) :: IsName a0 => a0 -> (a, b, c) -> (a, b, c) Source #
(Metric v, OrderedField n, Semigroup m) => Qualifiable (QDiagram b v n m) Source # | Diagrams can be qualified so that all their named points can now be referred to using the qualification prefix.
Instance details Defined in Diagrams.Core.Types Methods (.>>) :: IsName a => a -> QDiagram b v n m -> QDiagram b v n m Source #
Qualifiable (SubMap b v n m) Source # | `SubMap`s are qualifiable: if `ns` is a `SubMap`, then `a |> ns` is the same `SubMap` except with every name qualified by `a`.
Instance details Defined in Diagrams.Core.Types Methods (.>>) :: IsName a => a -> SubMap b v n m -> SubMap b v n m Source #