diagrams-core-1.4.0.1: Core libraries for diagrams EDSL

Copyright(c) 2011-2015 diagrams-core team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Core.Names

Contents

Description

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

Synopsis

Names

Atomic names

data AName where #

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

Constructors

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

Instances

Eq AName # 

Methods

(==) :: AName -> AName -> Bool #

(/=) :: AName -> AName -> Bool #

Ord AName # 

Methods

compare :: AName -> AName -> Ordering #

(<) :: AName -> AName -> Bool #

(<=) :: AName -> AName -> Bool #

(>) :: AName -> AName -> Bool #

(>=) :: AName -> AName -> Bool #

max :: AName -> AName -> AName #

min :: AName -> AName -> AName #

Show AName # 

Methods

showsPrec :: Int -> AName -> ShowS #

show :: AName -> String #

showList :: [AName] -> ShowS #

IsName AName # 

Methods

toName :: AName -> Name #

Each Name Name AName AName # 

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

Prism onto AName.

Names

newtype Name #

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

Constructors

Name [AName] 

Instances

Eq Name # 

Methods

(==) :: Name -> Name -> Bool #

(/=) :: Name -> Name -> Bool #

Ord Name # 

Methods

compare :: Name -> Name -> Ordering #

(<) :: Name -> Name -> Bool #

(<=) :: Name -> Name -> Bool #

(>) :: Name -> Name -> Bool #

(>=) :: Name -> Name -> Bool #

max :: Name -> Name -> Name #

min :: Name -> Name -> Name #

Show Name # 

Methods

showsPrec :: Int -> Name -> ShowS #

show :: Name -> String #

showList :: [Name] -> ShowS #

Semigroup Name # 

Methods

(<>) :: Name -> Name -> Name #

sconcat :: NonEmpty Name -> Name #

stimes :: Integral b => b -> Name -> Name #

Monoid Name # 

Methods

mempty :: Name #

mappend :: Name -> Name -> Name #

mconcat :: [Name] -> Name #

Wrapped Name # 

Associated Types

type Unwrapped Name :: * #

Qualifiable Name #

Of course, names can be qualified using (.>).

Methods

(.>>) :: IsName a => a -> Name -> Name #

IsName Name # 

Methods

toName :: Name -> Name #

Rewrapped Name Name # 
Each Name Name AName AName # 
Action Name (SubMap b v n m) #

A name acts on a name map by qualifying every name in it.

Methods

act :: Name -> SubMap b v n m -> SubMap b v n m #

type Unwrapped Name # 

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

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
  

Methods

toName :: a -> Name #

Instances

IsName Bool # 

Methods

toName :: Bool -> Name #

IsName Char # 

Methods

toName :: Char -> Name #

IsName Double # 

Methods

toName :: Double -> Name #

IsName Float # 

Methods

toName :: Float -> Name #

IsName Int # 

Methods

toName :: Int -> Name #

IsName Integer # 

Methods

toName :: Integer -> Name #

IsName () # 

Methods

toName :: () -> Name #

IsName Name # 

Methods

toName :: Name -> Name #

IsName AName # 

Methods

toName :: AName -> Name #

IsName a => IsName [a] # 

Methods

toName :: [a] -> Name #

IsName a => IsName (Maybe a) # 

Methods

toName :: Maybe a -> Name #

(IsName a, IsName b) => IsName (a, b) # 

Methods

toName :: (a, b) -> Name #

(IsName a, IsName b, IsName c) => IsName (a, b, c) # 

Methods

toName :: (a, b, c) -> Name #

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

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 #

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 #

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

Minimal complete definition

(.>>)

Methods

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

Qualify with the given name.

Instances

Qualifiable Name #

Of course, names can be qualified using (.>).

Methods

(.>>) :: IsName a => a -> Name -> Name #

Qualifiable a => Qualifiable [a] # 

Methods

(.>>) :: IsName a => a -> [a] -> [a] #

(Ord a, Qualifiable a) => Qualifiable (Set a) # 

Methods

(.>>) :: IsName a => a -> Set a -> Set a #

Qualifiable a => Qualifiable (TransInv a) # 

Methods

(.>>) :: IsName a => a -> TransInv a -> TransInv a #

Qualifiable a => Qualifiable (b -> a) # 

Methods

(.>>) :: IsName a => a -> (b -> a) -> b -> a #

(Qualifiable a, Qualifiable b) => Qualifiable (a, b) # 

Methods

(.>>) :: IsName a => a -> (a, b) -> (a, b) #

Qualifiable a => Qualifiable (Map k a) # 

Methods

(.>>) :: IsName a => a -> Map k a -> Map k a #

Qualifiable a => Qualifiable (Measured n a) # 

Methods

(.>>) :: IsName a => a -> Measured n a -> Measured n a #

(Qualifiable a, Qualifiable b, Qualifiable c) => Qualifiable (a, b, c) # 

Methods

(.>>) :: IsName a => a -> (a, b, c) -> (a, b, c) #

Qualifiable (SubMap b v n m) #

SubMaps are qualifiable: if ns is a SubMap, then a |> ns is the same SubMap except with every name qualified by a.

Methods

(.>>) :: IsName a => a -> SubMap b v n m -> SubMap b v n m #

(Metric v, OrderedField n, Semigroup m) => Qualifiable (QDiagram b v n m) #

Diagrams can be qualified so that all their named points can now be referred to using the qualification prefix.

Methods

(.>>) :: IsName a => a -> QDiagram b v n m -> QDiagram b v n m #