Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create KeyVal Annotation constructor #104

Merged
merged 1 commit into from
Dec 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Diagrams/Core/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module Diagrams.Core.Types
-- ** Annotations

-- *** Static annotations
Annotation(Href, OpacityGroup)
, applyAnnotation, href, opacityGroup, groupOpacity
Annotation(Href, OpacityGroup, KeyVal)
, applyAnnotation, href, opacityGroup, groupOpacity, keyVal

-- *** Dynamic (monoidal) annotations
, UpAnnots, DownAnnots, transfToAnnot, transfFromAnnot
Expand Down Expand Up @@ -252,6 +252,7 @@ withQDiaLeaf _ g (DelayedLeaf dgn) = g dgn
data Annotation
= Href String -- ^ Hyperlink
| OpacityGroup Double
| KeyVal (String, String)
deriving Show

-- | Apply a static annotation at the root of a diagram.
Expand All @@ -272,6 +273,10 @@ opacityGroup, groupOpacity :: (Metric v, OrderedField n, Semigroup m)
opacityGroup = applyAnnotation . OpacityGroup
groupOpacity = applyAnnotation . OpacityGroup

-- | Apply a general Key-Value annotation
keyVal :: (Metric v, OrderedField n, Semigroup m)
=> (String, String) -> QDiagram b v n m -> QDiagram b v n m
keyVal = applyAnnotation . KeyVal

-- | The fundamental diagram type. The type variables are as follows:
--
Expand Down